MentorNode
Start free
Commerce, Payments & LedgersHarddesign-ledger-wallet

Design a Double-Entry Ledger / Wallet

Design the accounting core: an immutable journal where every transfer balances to zero, balances are derived rather than stored, and no concurrent transfer can overdraw an account.

Double-Entry AccountingAppend-Only LogBalance SnapshotsSerializable Isolation
Traffic & Capacity Estimates:

50k transfers/second · 500M accounts · balances must never drift by a cent

Functional Requirements

  • •Record every movement as balanced debit and credit entries in an append-only journal.
  • •Derive account balances from entries, using periodic snapshots to bound the read cost.
  • •Enforce balance constraints (no overdraft) atomically at transfer time.
  • •Support multi-currency accounts and reversals as new compensating entries, never deletions.

Non-Functional Requirements

  • •The sum of all entries in a transfer is always exactly zero — this is invariant, not best-effort.
  • •Transfers are strictly serializable per account; a concurrent double-spend must fail one side.
  • •The journal is immutable: corrections are new entries, never updates.

Back-of-the-Envelope Math

  • 50k transfers/s * 2 entries = 100k journal appends/second.
  • Balance snapshot every 10k entries per account caps replay to 10k rows for any balance query.

Key Architectural Trade-offs

  • Derived balances are always provable from the journal and cost a read-time fold; a cached balance column is fast and can silently drift from truth.
  • Serializable isolation on hot accounts (a merchant's settlement account) serializes throughput — sharding by account with an aggregation step is the usual escape.
  • Sharding the ledger by account breaks cross-shard transfers into a saga, which reintroduces the intermediate states double-entry was meant to eliminate.

Click or drag a component onto the canvas, then connect the handles to draw the data flow.

3 nodes · 2 edges

Components · 35

Client & Edge4
Compute & Gateway7
Storage & Caching11
Messaging & Streaming6
Coordination & Ops5
Intelligence2
Canvas overview