Building a Ledger System - Chapter 2: Transaction Lifecycle
This is the second chapter in our five-part series on building production-ready ledger systems. In Chapter 1, we covered double-entry bookkeeping, data modeling, and transaction validation. Now we’ll explore transaction state management and async processing. Layer 3: Transaction Lifecycle Real-world transactions aren’t instantaneous. They go through states: stateDiagram-v2 [*] --> Pending: Create Pending --> Validating: Submit Validating --> Rejected: Invalid Validating --> Validated: Valid Validated --> Reserving: Reserve Funds Reserving --> Failed: Insufficient Reserving --> Reserved: Reserved Reserved --> Posting: Post Posting --> Posted: Success Posted --> Reversing: Reverse Reversing --> Reversed: Reversed Rejected --> [*] Failed --> [*] Posted --> [*] Reversed --> [*] The Pending → Validated → Reserved → Posted flow matters because: ...