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 peak need?
How many PSP calls are in flight at once?
How many status reads while customers approve on their phones?
How much payment data piles up, and how much stays hot?
Build-up · 6 steps
Build the high-level design
One functional requirement at a time, ending with a platform that works in one region at moderate traffic.
Step 1 of 6
Pay for an order
The order service creates the payment server to server, so the amount never comes from the phone. Card numbers go only to the vault; the payment service records attempt att_9 and calls a PSP with it.
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
“A double tap, a 4G retry, a crashed worker, a redelivered webhook. How do you make sure the customer is charged once?”
Your move. Pick an approach:
Deep dive 2 of 6
Interviewer
“The charge for att_9 gets no reply in 8 seconds. What do you do?”
It may never have arrived, been declined, or succeeded with the reply lost. From your side, all three look identical.
Your move. Pick an approach:
Deep dive 3 of 6
Interviewer
“One confirm touches your database, the PSP, the ledger and the order service. How do you record it exactly once?”
Your move. Pick an approach:
Deep dive 4 of 6
Interviewer
“Idempotency, the state machine and the outbox are all in place. How do you prove your records match the money?”
Your move. Pick an approach:
Deep dive 5 of 6
Interviewer
“Your target allows 4.3 minutes of downtime a month; a 99.9% PSP has 43 of its own. How do you keep taking payments?”
Your move. Pick an approach:
Deep dive 6 of 6
Interviewer
“Every system that touches a card number is in PCI scope. How do you keep card numbers out of most of yours?”
Your move. Pick an approach:
Build-up · 8 steps
Follow one ₹1,249.50 payment through it
The hot path is the gateway, payment service, database and PSPs. Outcomes arrive through the resolver and leave through the outbox; the money back office runs off the hot path.
Step 1 of 8
Create
The order service calls create with the key ord_8812:pay:1, derived from the order, so a restarted checkout finds the same payment. The shard number lives in the payment ID.