Open source  /  Implementation guide

Open-source implementation · App stack integrations

Integrate an app stack on open source

What this is. A build-it-yourself path to the same outcome, made from open-source parts you host. It does not publish 5 Kings’ internal method, client data, or any third party’s confidential information — and it says plainly where the open-source path is weaker than a specialist service.

In one paragraph

An app stack is a set of platforms that each own part of the truth: catalogue, orders, stock, support, finance, marketing. Integration work is making those truths agree on a schedule, and almost none of it needs a licensed middleware product. This guide builds the glue and, more importantly, the observability that tells you when it is wrong.

What you end up with

  • One canonical identifier per object (order, product, customer) shared across systems
  • Scheduled and event-driven sync with retries, dead-letter handling and a replay path
  • A freshness monitor per system, so a stalled sync is visible within minutes
  • A reconciliation report that names the discrepancies instead of hiding them in a dashboard

The reference stack

Every project below is open source and self-hostable. Licences are the ones the project publishes today; check them against your own distribution model before you ship, because a licence can change and an AGPL project has obligations a MIT project does not.

LayerOpen-source projectLicenceWhat it does for you
OrchestrationApache AirflowApache-2.0Scheduled DAGs with retries, SLAs and a UI that shows exactly where a run failed.
Event busNATS JetStreamApache-2.0Durable event streams with replay, for order and stock events that must not be lost.
Transformationdbt-coreApache-2.0Versioned SQL for the canonical models, with tests and lineage.
ExtractionMeltanoApache-2.0Managed extractors and loaders for the platforms that have a standard connector.
Canonical storePostgreSQLPostgreSQLThe join point: every system's view keyed by the canonical id, plus a row per sync run.
MonitoringGrafana + PrometheusAGPL-3.0 / Apache-2.0Freshness, error rate and lag per integration, with alerts on the four conditions that matter.
Alert routingAlertmanagerApache-2.0Deduplication and routing, so one broken sync does not page twelve people.

Build it

1. Define the canonical id before anything else

Every system has its own id. Write the mapping table first: canonical id, system, system id, created_at. Nothing else in the project can be reconciled without it, and retrofitting it later means a data archaeology project.

2. Decide schedule versus event, per flow

Stock and orders want events. Finance and catalogue want a nightly batch. Trying to make everything real-time doubles the cost and halves the reliability. Write the choice down per flow, with the tolerable lag.

# canonical order mapping
CREATE TABLE id_map (
  canonical_id uuid PRIMARY KEY,
  system       text NOT NULL,
  system_id    text NOT NULL,
  created_at   timestamptz DEFAULT now(),
  UNIQUE (system, system_id)
);

3. Make every sync idempotent and replayable

Upsert on the canonical id, store the source payload hash, and keep the run log. A replay of yesterday’s batch must produce the same state, not double the rows. Without this, every failure becomes a manual cleanup.

4. Fail loudly in one place

One sync-run table: integration, started_at, finished_at, rows, status, error. Everything that alerts reads from it. A sync that fails silently is the default failure mode of every integration project.

5. Monitor freshness, not just success

A sync that runs successfully but returns zero rows for six hours is broken. Alert on max(source_updated_at) age per system, not only on job exit code.

6. Reconcile on a schedule and publish the delta

Orders vs fulfilled orders vs invoices vs stock movements. Publish the count of unmatched rows daily. Trend matters more than any single day: a slowly rising unmatched count is an integration degrading.

7. Document the blast radius per flow

For each integration: what stops working, what the customer sees, and who is paged. This is the document that turns an outage into a routine.

Acceptance checks

If you cannot verify a claim, it is not a finding. These are the checks that close the work; each one can be run by somebody who did not build it.

Acceptance checkHow to verify it
Every object in every system maps to a canonical idLeft join each system's table to id_map; the unmapped count must be zero or explained.
Every sync run is recorded with a statusRun log row count vs scheduled run count per day.
Replays are idempotentReplay a completed batch and assert row counts and hashes are unchanged.
Freshness alerts fire before customers noticeFreeze a source in staging and confirm the alert within the agreed window.
Daily reconciliation delta is publishedGrafana panel plus a daily message; every non-zero needs a note.
A dead-letter queue exists and is non-silentPoison message in staging lands in the DLQ and pages, not disappears.

Effort and cost

Estimate
Skill neededAdvanced: SQL, queue semantics, and API auth across several vendors
Build time3–4 days for the canonical id + run log; 2 days per integration for the sync; 2 days for monitoring
Running costAn hour a week of attention; infrastructure is a single host
What you must hostOne 8 GB host for Airflow + Postgres + NATS + Grafana; scale Postgres first.

What open source does not give you

The honest half of the comparison. Each of these is a reason somebody buys the service instead of building it, and pretending otherwise would make the rest of this page worthless.

  • Vendor rate limits and quota policies set the ceiling on freshness. No architecture beats a 2-requests-per-second limit on an API you do not control.
  • Some platforms only expose a nightly export. Real-time is impossible there, and a guide promising it would be lying.
  • Schema changes on the vendor side arrive without warning. Contract tests and schema validation detect them; they do not prevent them.
  • Reconciliation tells you something disagrees. It does not tell you which system is authoritative — that is a business rule per field.
  • Self-hosted orchestration means you own the upgrades and the failed-DAG pager.

Scope only, stated so you can compare it with the build above.

  • The canonical data model, which requires knowing which system is authoritative per field
  • Integration design sequenced by business risk rather than by API convenience
  • Reconciliation triage: which mismatches are defects and which are legitimate business events

Sources and further reading

What this page does not include. This guide documents an open-source implementation of the same outcome. It deliberately leaves out 5 Kings’ internal playbooks, client data, vendor terms and unpublished method: we publish what any competent team can reproduce, and we do not publish what belongs to a client or to a contract. Where a step depends on a decision only your business can make, the guide says so instead of guessing.

Take it with you

Integrate an app stack on open source

The full guide as an A4 PDF: the reference stack with licences, the build steps, the acceptance checks and the honest limits — in one file you can hand to an engineer or print for a planning session.

PDF · A4 · no email required · free to redistribute with attribution

Open-source Guides & PDFs