Ledger is an event-driven order processing platform focused on production-grade distributed systems patterns:
- asynchronous workflow orchestration using Kafka-compatible messaging
- saga-based compensating transactions
- idempotent processing, retries, and DLQ handling
- schema-governed event contracts
- observability with metrics and dashboards
Phase 0 establishes local infrastructure and conventions:
- Redpanda broker
- PostgreSQL with service schemas
- Prometheus and Grafana
- Redpanda Console for topic visibility
- event/topic contract documentation
- smoke test script for producer-consumer round-trip
Phase 3 introduces production-grade reliability controls:
- transient-vs-poison failure classification
- bounded retries with exponential backoff
- per-topic dead-letter queue routing on retry exhaustion
- schema validation on producer and consumer boundaries
- DLQ inspection and replay planning via script and ops endpoint
Key tools:
python scripts/dlq_inspector.py --input <dlq-record.json>POST /ops/dlq/inspect
Phase 3 docs:
docs/phase3-reliability-runbook.mddocs/phase3-schema-versioning.mddocs/phase3-break-demo.md
Phase 4 adds a synchronous inventory precheck before order acceptance:
- proto contract:
proto/inventory.proto - generated stubs:
shared/grpc_generated/ - inventory gRPC server:
services/inventory-service/grpc_server.py - order gRPC client:
services/order-service/grpc_client.py - fail-fast API behavior:
409when stock is insufficient503when gRPC transport is unavailable
Phase 4 docs:
docs/phase4-async-vs-rpc.mddocs/phase4-grpc-debug.md
Phase 5 upgrades observability from basic infra telemetry to service-level runtime telemetry:
/metricsexposed on order, inventory, payment, and notification services- topic-labeled publish and consume counters
- p95-ready latency histograms for publish/consume/gRPC/HTTP surfaces
- consumer lag gauges by topic and partition
- DLQ publish counters and latency metrics
- structured JSON logs with correlation-id enrichment for cross-service tracing
Phase 5 docs:
docs/phase5-observability-triage-playbook.mddocs/phase5-trace-by-correlation-id.md
-
Copy environment template:
cp .env.example .env(macOS/Linux)Copy-Item .env.example .env(PowerShell)
-
Start infrastructure:
docker compose up -d
-
Validate broker round trip:
./scripts/smoke_roundtrip.ps1
redpandaatlocalhost:9092postgresatlocalhost:5432prometheusatlocalhost:9090grafanaatlocalhost:3000redpanda-consoleatlocalhost:8080schema-registryatlocalhost:8081
- order service ops UI:
GET /opsonlocalhost:8000 - service metrics:
localhost:8000/metricslocalhost:8001/metricslocalhost:8002/metricslocalhost:8003/metrics
- Prometheus targets:
http://localhost:9090/targets - Grafana dashboard UID:
ledger-phase5
Quick connectivity checks:
Invoke-WebRequest http://localhost:9090/-/healthyInvoke-WebRequest http://localhost:3000/api/healthInvoke-WebRequest http://localhost:8080Invoke-WebRequest http://localhost:8081/subjects
- Phase 0: environment scaffolding
- Phase 1: order ingest to inventory reservation pipeline
- Phase 2: payment/notification choreography and rollback
- Phase 3: retries, DLQ, schema registry
- Phase 4: gRPC synchronous boundary
- Phase 5: observability hardening
- Phase 6: load testing and release documentation
This section explains what was built, why it was built, and how to inspect it.
What:
- Dockerized Redpanda, Postgres, Prometheus, and Grafana base infrastructure.
Why:
- Establish reproducible local infrastructure for event flow and operational visibility.
How to inspect:
- Run
docker compose up -d - Open Prometheus targets view.
What:
POST /ordersingress and order-created event publication.
Why:
- Introduce the primary event-driven flow from API boundary to broker.
How to inspect:
- Open order-service OpenAPI docs and submit sample orders.
What:
- Payment + compensation path and terminal notification events.
Why:
- Ensure distributed transaction behavior is explicit and recoverable.
How to inspect:
- Use Redpanda Console to watch
order.created,inventory.*,payment.*, andorder.cancelledtopics.
What:
- Retry policies, DLQ handling, and schema validation for event contracts.
Why:
- Prevent silent corruption and provide deterministic failure routing.
How to inspect:
- Inspect Schema Registry subjects and the phase 3 runbooks.
What:
- Synchronous inventory admission precheck before asynchronous order publication.
Why:
- Fast fail for insufficient inventory while preserving async downstream choreography.
How to inspect:
- Open order ops surface and test
POST /ordersbehavior for available and unavailable stock.
What:
- Service-level metrics, lag gauges, latency histograms, and correlation-aware JSON logs.
Why:
- Make distributed execution measurable and debuggable under stress.
How to inspect:
- Open Grafana and query dashboard UID
ledger-phase5.
What:
- k6 burst + staged ramp profiles, benchmark summaries, known limitations, and release checklist.
Why:
- Provide transparent performance evidence and public-repo onboarding clarity.
How to inspect:
- Run scripts in
load-test/README.mdand compare outputs with benchmark docs.
Phase 6 support docs:
docs/phase6-benchmark-results.mddocs/phase6-known-limitations.mddocs/phase6-release-checklist.md
- If
docker compose upfails due to occupied ports, stop conflicting services or map alternate ports. - If Redpanda topic commands fail, ensure containers are healthy using
docker compose ps. - If Grafana dashboard provisioning fails, restart Grafana after fixing JSON syntax or datasource configuration.






