About this module
Design a peer-to-peer wallet where users send each other money in seconds: a double-entry ledger in one transaction per transfer, idempotency keys, row locks in ID order, pending top-ups and withdrawals, an in-flight account across shards, a hot merchant account, and a nightly match against the bank.
Lessons
- Lesson 26
Clarifying a P2P Wallet
Money in, between users and out, one currency, no overdraft, and one very popular coffee chain
3:10 - Lesson 27
Estimating a Wallet
Sixty transfers a second, a payday peak, and the limit hiding in one account
1:50 - Lesson 28
Money Invariants for a Wallet
No money created, exactly once, never below zero, append-only entries, and books that match the bank
1:46 - Lesson 29
The Wallet API
Five calls, a key on every money move, and three transfer states
2:25 - Lesson 30
A Ledger That Works
Four boxes, three tables, one transaction per transfer, and the outbox
2:16 - Lesson 31
Money In and Out of the Wallet
Pending top-ups, withdrawals and returns, and reading history from a replica
2:25 - Lesson 32
Two Spends at Once, and a Deadlock
Never below zero under pressure, and locking accounts in a fixed order
2:04 - Lesson 33
Sharding the Ledger and the Hot Account
Transfers across shards, the in-flight account, and the coffee chain at lunchtime
2:59 - Lesson 34
Failures and Reconciliation for a Wallet
Failover, timeouts, duplicate webhooks, a shard down, and the nightly checks
2:32 - Lesson 35
Wallet Follow-ups and the Invariant Replay
A dropped network, a fast balance, reversals, limits, and five ticks
2:04