Blog: notes on backend, data and AI
Notes on backend engineering, data and building products with AI.
November 25, 2026 · 3 min read
The saga pattern: local transactions, compensation and state
A saga replaces one big distributed transaction with a chain of local ones and a compensating action per step. It needs a persisted state, idempotent steps and a sweep for stuck sagas.
distributed-systemssagapayments
November 25, 2026 · 4 min read
Idempotency keys for APIs and message consumers
Networks retry and brokers redeliver, so every operation that moves money must be safe to receive twice. A unique key and a stored result make a repeat harmless.
paymentsapiidempotency
November 25, 2026 · 4 min read
Safe transfers and double-spend prevention in one database
A correct transfer is one short transaction: record it once, lock the wallets in a fixed order, check and subtract atomically, write balanced ledger entries and commit.
paymentstransactionslocking
November 25, 2026 · 4 min read
Designing money columns and ledgers
Store money as integers in the smallest unit, keep an append-only ledger as the source of truth, and let a balance column be a cache. Double-entry makes errors easy to detect.
paymentsledgerschema-design