qodebase logoqodebase
← All tracks

Unit 2 — record every cent twice and prove the books always balance

Double-Entry Ledger & Reconciliation

In Unit 1 we charged a card exactly once. But "the charge succeeded" is not the same as "the money is accounted for." That same $20 has to land in the merchant's balance, minus your fee, and every party's books have to agree — forever, across millions of transactions a day, even when a process crashes mid-write.

The data structure that makes this tractable is six centuries old: the double-entry ledger. This unit builds one, derives the invariant that guarantees it can never silently lose money, and writes the reconciliation pass that catches corruption.

Double-Entry Ledger & Reconciliation — qodebase — qodebase