How mikashboks/formance-stack works
Purpose and Entry Points
This repository assembles the Formance Stack: a modular financial-services platform centered on an immutable double-entry ledger, payments data/APIs, and orchestration. Service implementations are versioned external components; this repo supplies stack composition, shared event contracts, release assembly, and validation assets.
Local entry point: docker-compose.yml, exposing the gateway API at /api. Developer-local variants use .local/docker-compose.yml and .local/process-compose.yaml. Build orchestration is rooted at Earthfile.
Stack Composition and Gateway
Docker Compose defines the runnable service topology and its dependencies; the local Caddy gateway configuration is at .local/gateway/Caddyfile. Production deployment is intended to package independently deployable service binaries/images, typically to Kubernetes via external Helm charts.
The HTTP gateway is a boundary between clients and module APIs. PostgreSQL is the primary persistent backend; Kafka or NATS provide asynchronous inter-service communication, per the stack’s documented infrastructure model.
Paths: docker-compose.yml, .local/docker-compose.yml, .local/gateway/Caddyfile.
Versioned Event Contract Library
libs/events is the shared cross-service event schema package. YAML files are canonical service/version/event definitions; generation produces JSON schemas and aggregate metadata for consumers. This is the principal compatibility boundary among Ledger, Payments, and Orchestration modules.
Supported domains include:
• Ledger transaction commits, reversals, metadata lifecycle.
• Payments connector, account, balance, payment, pool, and initiation lifecycle.
• Orchestration trigger, workflow, and workflow-stage outcomes.
Paths: libs/events/events.go, libs/events/services/payments/v3.0.0/SAVED_PAYMENT_INITIATION.yaml, libs/events/generated/all.json.
Ledger Domain
Ledger is the system of record for programmable, immutable, double-entry transactions. Its externally observable event interface evolves independently, with ledger v1 and v2 event schemas for committed transactions, reversals, and metadata changes. Numscript is the monetary-computation and transaction-modeling DSL/VM used by the broader platform, though its implementation is not present in this tree.
Paths: libs/events/services/ledger/v2.0.0/COMMITTED_TRANSACTIONS.yaml, libs/events/services/ledger/v2.0.0/REVERTED_TRANSACTION.yaml.
Payments and Orchestration Domains
Payments provides a unified payment-processing data layer, emitting versioned state-change events for connector synchronization and payment entities. Orchestration models asynchronous trigger/workflow execution and publishes started, succeeded, and failed transitions. These domains communicate at the event boundary rather than through this repository’s direct implementation code.
Paths: libs/events/services/payments/v3.0.0/CONNECTOR_RESET.yaml, libs/events/services/payments/v3.0.0/SAVED_PAYMENT.yaml, libs/events/services/orchestration/v2.0.0/FAILED_WORKFLOW.yaml.
Release and Integration Boundary
Release assets consolidate API specifications through merge and overlay configuration. Integration infrastructure provisions a multi-module environment—including auth, ledger, payments, orchestration, reconciliation, search, wallets, and webhooks—and can use Temporalite for workflow-oriented testing. This indicates services are composed and exercised as independently managed modules behind the common gateway.
Paths: releases/openapi-merge.json, releases/openapi-overlay.json, tests/integration/docker-compose.yml, tests/integration/temporalite.Dockerfile.
Operational Validation
Separate load and benchmark environments drive ledger write/read workloads and observe service behavior. Benchmark tooling includes PostgreSQL plus OpenTelemetry collection, Prometheus, and Grafana dashboard provisioning, making performance and telemetry part of the composed-stack operating model.
Paths: tests/benchmarks/tools/docker-compose.yml, tests/benchmarks/tools/otel-collector-config.yaml, tests/loadtesting/docker-compose.ledger.yml.
Main entry points: Caddyfile HTTP gateway · integration/docker-compose.yml Integration environment · all.json Generated event catalog · docker-compose.yml Stack topology
Components 19
Stack Composition
- Build orchestration
Earthfile - Stack topology
docker-compose.yml - Local stack variant
.local/docker-compose.yml - HTTP gateway · Exposes module APIs under /api.
.local/gateway/Caddyfile - PostgreSQL · Primary platform persistence backend.
- Kafka / NATS · Asynchronous inter-service transport.
Event Contracts
- Event schema generator
libs/events/events.go - Payments event definitions · Canonical versioned payment event schema.
libs/events/services/payments/v3.0.0/SAVED_PAYMENT_INITIATION.yaml - Ledger v2 event definitions · Committed and reverted transaction contract family.
libs/events/services/ledger/v2.0.0/COMMITTED_TRANSACTIONS.yaml - Generated event catalog · Aggregate metadata and schemas for consumers.
libs/events/generated/all.json
Module Domains
Independently deployed modules consume the shared contracts.
- Ledger · Immutable double-entry system of record.
- Payments · Payment-processing data layer and lifecycle publisher.
- Orchestration · Asynchronous trigger and workflow execution.
Release & Integration
- Release API assembly · Consolidates module API specifications.
releases/openapi-merge.json - Integration environment · Composes platform modules and test infrastructure.
tests/integration/docker-compose.yml - Temporalite · Workflow-oriented integration test runtime.
tests/integration/temporalite.Dockerfile
Operational Validation
- Benchmark telemetry stack · Provides PostgreSQL, telemetry, metrics, and dashboards.
tests/benchmarks/tools/docker-compose.yml - OpenTelemetry collector
tests/benchmarks/tools/otel-collector-config.yaml - Ledger load environment · Drives ledger read/write workloads.
tests/loadtesting/docker-compose.ledger.yml
Connections 25
- Build orchestration → Stack topology: builds stack
- Local stack variant → HTTP gateway: configures
- HTTP gateway → Ledger: routes API
- HTTP gateway → Payments: routes API
- HTTP gateway → Orchestration: routes API
- Stack topology → PostgreSQL: provisions
- Stack topology → Kafka / NATS: provisions
- Ledger → PostgreSQL: persists records
- Payments → PostgreSQL: persists data
- Payments event definitions → Event schema generator: canonical input
- Ledger v2 event definitions → Event schema generator: canonical input
- Event schema generator → Generated event catalog: generates
- Ledger → Kafka / NATS: publishes events
- Payments → Kafka / NATS: publishes events
- Orchestration → Kafka / NATS: publishes events
- Generated event catalog → Ledger: compatibility contract
- Generated event catalog → Payments: compatibility contract
- Generated event catalog → Orchestration: compatibility contract
- Release API assembly → HTTP gateway: assembles published API
- Integration environment → Temporalite: includes
- Integration environment → Ledger: exercises
- Integration environment → Payments: exercises
- Integration environment → Orchestration: exercises
- Benchmark telemetry stack → OpenTelemetry collector: configures
- Ledger load environment → Ledger: loads