Layer 3 · Go deeper · 12 min
Go deeper
Size it, build it, then make the calls an interviewer will push you on.
Back of the envelope
Size it up
Tap through each step of the arithmetic.
How many database shards does the festival peak need?
How much ledger data lands every year?
How many top-ups wait at the peak, and how many succeed late?
Can one merchant’s balance row keep up on a sale morning?
Build-up · 5 steps
Build the high-level design
One functional requirement at a time, on one PostgreSQL database, ending with a wallet that works before any scaling.
Step 1 of 5
Add money
A top-up is a payment to the wallet company, so it stays pending until the gateway’s signed webhook arrives. A unique payment ID makes a duplicate harmless; the app’s “success” credits nothing.
6 interview moments
You’re the candidate
The interviewer pushes on the hard parts. Pick an approach and see how it holds up.
Deep dive 1 of 6
Interviewer
“Ravi has ₹1,000. Two ₹800 payments arrive from his phone and tablet in the same millisecond. How do you debit him?”
Your move. Pick an approach:
Deep dive 2 of 6
Interviewer
“Asha is on shard 3, Ravi on shard 11. No transaction spans both rows. How do you move her ₹500?”
15 of every 16 movements cross shards like this.
Your move. Pick an approach:
Deep dive 3 of 6
Interviewer
“On a sale morning one merchant wallet takes about 1,900 credits a second. One row tops out near 500. What do you do?”
Your move. Pick an approach:
Deep dive 4 of 6
Interviewer
““Money left my bank, my wallet shows nothing.” How do you make sure every top-up that took money reaches the wallet?”
Your move. Pick an approach:
Deep dive 5 of 6
Interviewer
“Meena’s small-KYC wallet has loaded ₹8,500 this month against a ₹10,000 cap. Two top-ups start together. How do you enforce the cap exactly?”
Your move. Pick an approach:
Deep dive 6 of 6
Interviewer
“Phished OTPs, SIM swaps, stolen cards moved out to mules. How do you stop fraud without breaking the 500 ms p99?”
Your move. Pick an approach:
Build-up · 8 steps
Follow Asha’s ₹500 and ₹2,000 through it
The hot path is the gateway, wallet API, risk check and one or two shard transactions. Top-ups, payouts, history and reconciliation hang off the event stream and the banks.
Step 1 of 8
Authenticate
The app signs the request with its bound device key, adds PIN proof and an idempotency key. The API gateway checks them and rate-limits, so a phished OTP alone gets nowhere.