Building a Ledger System - Chapter 4: Production Operations
This is the fourth chapter in our five-part series on building production-ready ledger systems. In Chapter 3, we covered multi-currency handling, reconciliation, and database locking. Now we’ll focus on production operations: audit trails, balance snapshots, and settlement tracking. Audit Trail Queries: Finding the Truth Event sourcing gives you an immutable history, but you need to query it effectively. Here’s how to build audit trails that actually help. Event Store Schema erDiagram EVENTS { uuid id PK uuid aggregate_id string aggregate_type string event_type json payload int sequence_number timestamp occurred_at uuid user_id string ip_address string correlation_id } PROJECTIONS { uuid id PK string projection_name uuid last_event_id timestamp updated_at } ACCOUNT_BALANCE { uuid account_id PK decimal balance uuid last_entry_id timestamp updated_at } Query Patterns 1. Reconstruct Account History ...