SYSTEM DESIGN SKETCHBOOK / PRACTICE SHEET / NO. 47
Design a wire transfer API with a ledger
Business customers of a banking platform hold balances, move money instantly between accounts on the platform, and send outgoing wires to other banks. Treasury and auditors need to account for every cent, and customers want to know exactly where a wire is.
Requirements
- Create a transfer (internal account to account, or an outgoing wire to an external bank) with an idempotency key; a retried request never moves money twice.
- Record every money movement as balanced double-entry postings and expose both the ledger balance and the available balance.
- Place a hold on funds when an outgoing wire is created; settle it when the rail confirms, release it if the wire is rejected.
- Expose transfer status (pending, submitted, completed, returned, failed) and a statement of postings per account.
- Reconcile daily against the partner bank's statements.
Constraints and assumptions
- 5 million accounts; 300 transfer requests per second at peak, mostly internal.
- 50,000 outgoing wires per day, submitted to a partner bank in batches before fixed cutoff times; confirmation takes minutes to hours, and a wire can be returned days later.
- An account's available balance must never go below zero unless it has an approved overdraft limit.
- One large corporate account can make 50 transfers per second.
- History is immutable and kept for 7 years.
Out of scope for the first sketch
Sanctions and fraud screening internals (assume a screening call that answers approve, deny or review) · Foreign exchange · Customer onboarding and identity checks · Interest and fees
Draw your design
Rough math and notes
SYSTEM DESIGN SKETCHBOOK / FOLLOW-UPS
Design a wire transfer API with a ledger
Finish your first sketch before answering these. Cross out freely.
- A client sends the same transfer twice because its first request timed out. Walk through what each request does.
- Two transfers from the same account race for its last $1,000. What stops the balance going negative?
- Your service crashes after the partner bank accepted a wire batch but before you recorded that it was sent. How do you find out and fix the state?
- A corporate treasury account makes 50 transfers per second. Where does contention show up, and how would you relieve it if it grew to 500?
- A wire is returned by the beneficiary bank three days after you marked it completed. What postings and state changes happen?
Compare afterwards: worked approaches and reading at sketchbook /questions/wire-transfer-api/review