techdiagrams.net
← All templates

Digital wallet on a double-entry ledger

A wallet where every balance is a materialized view over an append-only double-entry journal — money moves effectively-once, and the books always balance.

Open in editor — free, no login Download JSON
SOURCE OF TRUTH — EVERYTHING ELSE IS PROJECTIONtransfer · Idempotency-Keypost(debit A, credit B)append postingemit committed postingsupdate viewGET balance — reads the view, never the journalassert books balanceWallet Apptransfer £20 to AshaWallet APIidempotency-key dedupeLedger Serviceposts double entriesJournalappend-only · immutablePostingCommittedat-least-onceBalance Projectorfolds postings → balancesBalances Viewrebuildable projectionTrial Balancenightly: Σdebits = Σcreditswhy money can't vanish:1. debit + credit commit in ONE posting2. balances derive from postings — no drift3. retry replays the same posting id → no-op

What this design does

The mistake most wallet MVPs make is storing balances as mutable numbers — then one crash between 'debit A' and 'credit B' invents or destroys money. Here the journal is the only writer: every transfer is one atomic double-entry posting, balances are just a projection that can be rebuilt from scratch, and a nightly trial balance asserts the invariant that debits equal credits. Import it and try to construct a crash that loses money — the design won't let you.

The patterns it composes

Import it, attach your own numbers, and verify the design against failures — or read the engineering notes.