
DuraLedger
A multi-currency wallet ledger that never loses or duplicates money: not under retries, races, crashes or deploys.
Key decisions
- Idempotency key claimed inside the transaction that posts the legs, so a duplicate waits on Postgres's lock and replays the stored response.
- Invariants enforced by PostgreSQL: zero-sum per currency checked at commit,
CHECK (balance ≥ 0). - Pessimistic locking by default: on hot accounts optimistic retries tripled p99. Accounts locked in id order to kill a deadlock.
- Transactional outbox for events, and scale-to-zero on Cloud Run + Neon for ≈$0 idle cost.
