0%
System Design Interview Framework: A Repeatable Plan From Requirements to Wrap Up
The Interview Itself
The Framework Step by Step
Walkthrough: A Payments Ledger
The final walkthrough is a payments ledger: the system at the heart of a wallet, a marketplace or a payments company that records every movement of money between accounts. It is a common senior and staff level prompt because the scale is moderate but the correctness bar is extreme. Losing a tweet is unfortunate; losing or duplicating a payment is a regulatory and financial incident. The problem tests whether a candidate can design for correctness first and performance second, and whether they know the standard techniques that make money systems safe: double entry, idempotency, transactional outboxes and reconciliation.
As with the other walkthroughs, the dialogue shows one good path through the problem. Your session will differ, but the order of decisions and the way each is justified should look similar.
The prompt
The interviewer says: design the ledger for a payments platform. Users and merchants have accounts. Money moves between them when people pay, get refunds or withdraw. We need to know every account's balance and the history of how it got there. The prompt is about a ledger, not a whole payments company, and the candidate's first job is to keep it that way.
Scoping the functional requirements
Interview Dialogue
In about a minute the candidate has drawn a clear boundary: the ledger is the system of record for money movements, and everything else is a client of it. The question about negative balances produced a rule, no overdrafts for users, that will shape the write path, because the ledger must check a balance and move money atomically.
Non functional requirements
Interview Dialogue
The candidate made the ordering explicit and stated the conflict resolution rule, correctness over availability, out loud. That one sentence settles a whole class of later questions, such as whether to accept writes during a network partition, before they are asked.
The estimate
Interview Dialogue
The estimate shows that raw throughput is modest, a few thousand transfers a second, and points at the real difficulties: correctness and hot accounts. That framing prevents the common mistake of reaching for an exotic high throughput store and then struggling to make it transactional.
What has been established
About seven minutes in, the board shows the scope (transfers, balances, history, reconciliation), the requirements in order with correctness first, and the key numbers: five thousand transfers a second at peak, ten thousand entry writes, under a hundred terabytes over five years, and hot merchant accounts. The candidate has also named the two hard parts, which tells the interviewer where the deep dive will go.
Why correctness is broken into parts
Notice that the candidate did not just say the system must be correct. They split correctness into three testable properties: money is conserved, no transfer is applied twice and user balances never go negative. Each property maps to a mechanism later: double entry for conservation, idempotency keys for no duplicates and a conditional balance check for no overdrafts. Breaking a vague requirement into concrete properties is one of the most useful habits in any interview, because it turns a slogan into a checklist the design can be measured against.
A weaker opening for comparison
A weaker opening would treat the ledger as a balances table with an update balance endpoint, estimate only throughput and choose a store for its speed. The interviewer would then have to ask how retries are handled, how history is kept and how balances are audited, and each answer would be a patch on a design that started from the wrong place. Starting from correctness avoids all of that.
Questions that were not needed
The candidate did not ask how many countries the platform operates in, what the user interface looks like or which card networks are supported. None of those affects how a ledger records a transfer. Each opening question either narrowed the scope or produced a rule the design must follow, such as one currency and no user overdrafts.
Confirming the numbers
Before moving on, the candidate could check the scale with one question: does a hundred million transfers a day with peaks around five thousand a second match what you have in mind? If the interviewer says it is ten times larger, the conclusion barely changes. Fifty thousand transfers a second still fits a well partitioned distributed SQL database, and the hard parts are still correctness and hot accounts. Saying that the conclusion is robust to the exact number is itself a useful signal, because it shows the candidate knows which numbers drive the design and which do not.
The ledger as a platform
It also helps to say early that the ledger is a platform for other teams. Checkout, refunds, payouts and billing all call it, and none of them should be able to break its rules. That framing explains why the API is narrow and why the rules live inside the ledger rather than in its callers.
Saying the ledger must be correct is a slogan. Saying money is conserved, no transfer applies twice and user balances never go negative is a checklist. Each property then maps to a mechanism, which makes the design easy to explain and easy for the interviewer to evaluate.
For a ledger, the data model is the design. Most of the important decisions, how money is represented, how history is kept and how duplicates are prevented, are made here. The candidate keeps the API short and spends most of this step on the tables.
The API
Interview Dialogue
That small statement, no endpoint to set a balance, says a great deal about the candidate's understanding. It turns auditability from a requirement into a property of the API.
Amounts and money types
Interview Dialogue
Integer minor units and an explicit currency are details that interviewers often look for in payments problems, and the candidate mentioned them in two sentences without being asked.
Double entry
Interview Dialogue
Double entry is the centuries old answer to exactly this problem, and the candidate justified it with the property that matters most in a software system: a cheap, global invariant that detects bugs. Mentioning that fees are just more entries shows how the model extends without special cases.
Balances
Interview Dialogue
The candidate kept the materialised balance for performance but made it clearly derived, with a check that it matches the entries. That pattern, a fast derived view verified against an immutable log, appears throughout good financial systems.
Idempotency
Interview Dialogue
Partitioning
Interview Dialogue
The candidate chose the partition key from the main read pattern and immediately named the problem it creates, cross partition transfers, deferring the answer to the next step. Naming a weakness before the interviewer does is a strong signal.
The state of the board
About fourteen minutes in, the board has a short API with no balance setter, integer amounts with currency, the entries, transfers, balances, accounts and idempotency tables, and a partition plan with one open question. The model already enforces conservation and auditability by construction.
Account types and their rules
The accounts table carries a type and a flag for whether the account may go negative. User accounts may not. Merchant accounts usually may not, although some platforms allow a small negative balance after a refund, recovered from future sales. Internal accounts, such as the platform's clearing account, its fee account and a correction account for adjustments, can go negative because they represent the platform's own position. Putting the rule on the account, rather than hard coding it per transfer type, keeps the write path simple: the transaction looks up the source account's flag and applies the non negative condition only when it is set.
Transfer types and references
Every transfer carries a type, such as payment, refund, payout, fee or adjustment, and a reference to the business object that caused it, such as an order or a refund request. The type makes reporting easy, since finance teams want totals by type. The reference makes support easy, since an agent looking at an order can find every transfer linked to it. Neither field affects correctness, but both make the ledger far more useful, and naming them takes a sentence.
Refunds as transfers
A refund is not an edit to the original payment. It is a new transfer in the opposite direction, from the merchant to the user, with a reference to the original payment. The original entries stay as they were. This keeps the history complete: anyone reading the user's account sees the payment and then the refund, with times and reasons, rather than a payment that silently disappeared. The same rule applies to every correction, which is why the candidate said there is no balance setter.
Indexes
Entries are read by account and time for history, so the primary index is account id plus timestamp or sequence. Transfers are read by id and by reference, so the reference needs a secondary index. Idempotency keys need a unique index scoped to the client. Stating these briefly confirms that every read in the API is efficient.
Keeping the step focused
Even though the data model took longer than in the other walkthroughs, each decision here is used later: the balances table in the overdraft check, the idempotency table in the retry deep dive, the account flag in the hot account discussion and immutable entries in reconciliation.
Reading the model back
A quick read back confirms the model covers the requirements: conservation by double entry, no duplicates by the idempotency key, no overdrafts by the account flag and conditional balance update, and auditability by immutable entries and visible corrections.
No endpoint sets a balance, entries are append only and every transfer's entries sum to zero. When rules like these are built into the API and the tables, the system cannot violate them by accident, and auditing becomes a query rather than an investigation.
With the model in place, the candidate draws the system. The design is intentionally conservative: a small number of well understood components, arranged so that every transfer is one database transaction and every side effect is reliable. Most of the interesting decisions are about how to keep it that way.
The core path
Interview Dialogue
The candidate faced the cross partition question directly, compared the two approaches on the deciding concern, correctness risk, and chose the one that keeps the hardest property in the database rather than in application code. That is a mature judgment: use the boring, proven mechanism for the part that must never be wrong.
Publishing events reliably
Interview Dialogue
The outbox is the standard answer to the dual write problem, and the candidate explained both failure cases that make the naive approach wrong. Noting that consumers must still deduplicate shows an understanding that at least once delivery is what the outbox provides.
Reads
Interview Dialogue
Separating reads that will be acted on from those that are only displayed is a small but important distinction in money systems, and the candidate made it in a sentence.
Walking one transfer
Interview Dialogue
Asynchronous work around the ledger
The ledger itself stays small and synchronous. Everything that does not need to be in the transaction, sending receipts, updating analytics, notifying merchants, moving money to banks, happens downstream of the event stream. This keeps the transaction short, which matters for latency and for contention on busy accounts.
Checking in
Interview Dialogue
The candidate is about twenty two minutes in, with a clear plan for the deep dive.
What the design avoids
The design avoids several common traps. It does not update balances without entries, which would destroy auditability. It does not publish events outside the transaction, which would lose or invent events. It does not build its own distributed transaction protocol. And it does not put slow work, such as calling a bank, inside the ledger transaction. Each of these traps is easy to fall into under time pressure, and avoiding all four is a strong signal.
Why not a key value store
An interviewer might ask why not use a high throughput key value store for balances. It would be fast, but most such stores lack multi row transactions, so debiting one account and crediting another atomically would need custom coordination. Any bug in that coordination creates or destroys money. At five thousand transfers a second, the throughput of a key value store is not needed, so its speed does not buy anything worth that risk. The candidate can say this in two sentences, and it reinforces the theme of the session: choose infrastructure by the correctness property it provides, not by raw speed.
Isolation level
Inside the transaction, the conditional balance update does the critical work. Writing it as update balances set amount equals amount minus forty where account is A and amount is at least forty means the check and the change are a single atomic statement, so two concurrent debits cannot both pass the check, whatever the isolation level. If the update affects zero rows, the transfer is rejected for insufficient funds. Mentioning that the condition lives in the update itself, rather than in a read followed by a write, shows the candidate understands where races come from.
Lock ordering
A transfer updates two balance rows. If two transfers move money in opposite directions between the same pair of accounts at the same time, each might lock one row and wait for the other, a deadlock. Updating balance rows in a fixed order, such as by account id, prevents this. The database would detect and break a deadlock anyway, but avoiding it keeps latency predictable.
Where calls to banks happen
Payouts to merchants' banks are slow and can fail for reasons outside the platform's control. They never happen inside the ledger transaction. Instead, a payout is recorded as a transfer from the merchant's account to a pending payouts account; the payouts service, reading events, calls the bank with the transfer id as its idempotency key and, on confirmation, records a second transfer from pending payouts to a settled account. If the bank rejects the payout, a reversing transfer returns the money to the merchant. Every step is visible in the ledger.
The shape of the design
The result is deliberately unexciting: a stateless API, one relational transaction per transfer and an event stream. For a ledger, boring is the goal, because every component is well understood and its failure modes are known.
Interviewers at payments companies tend to reward exactly that restraint.
Writing to a database and then publishing to a queue, or the reverse, will eventually lose or invent an event when a process crashes between the two. Put the event in an outbox table in the same transaction and let a relay publish it. Consumers then deduplicate by id.
The interviewer asked for both deep dive topics briefly, starting with retries. The candidate spends about seven minutes on each, keeping both at the level of mechanisms rather than slogans.
The retry problem
Interview Dialogue
The candidate described the normal retry and then the concurrent retry, at the level of what the database does with the unique index. That second case is where many answers become vague, and handling it precisely is a strong signal.
How long keys live
Interview Dialogue
Idempotency beyond the API
Interview Dialogue
Extending idempotency across the event stream and to the external bank shows the candidate sees retries as a property of the whole system, not one endpoint.
Hot accounts
Interview Dialogue
Sub accounts are a well known technique, and the candidate explained why it is safe here: credits need no overdraft check, so they can go to any sub account. That reasoning, rather than the technique alone, is what the interviewer is evaluating.
Another option
Interview Dialogue
The candidate compared two options and gave the rule for when each is safe. The follow up answer, that asynchronous balances are only safe where no write depends on them, is a precise statement of the trade off.
What the deep dive showed
In about fourteen minutes, the candidate showed exactly how duplicates are prevented, including the concurrent retry case, extended idempotency across the system, and handled hot accounts with two techniques and a clear rule for when each is safe. Every answer was tied back to the requirements: no duplicates, no overdrafts, conservation.
A deeper follow up
Interview Dialogue
The candidate recognised that the design already had the essence of the suggestion and explained precisely what would be lost by going further, which is how to handle a challenge that is partly right.
Measuring contention
How would the team know a merchant account has become hot? The ledger can track lock wait time and transaction latency per account. When an account's lock waits rise above a threshold, it is a candidate for splitting. Splitting can be done online: create the sub accounts, start routing new credits to them and leave the existing balance in the main account, which still counts in the sum. Mentioning this operational path shows that the technique is not just a whiteboard idea.
What the interviewer is listening for
In this deep dive, the interviewer is listening for whether the candidate understands why each technique is safe, not just what it is. Sub accounts are safe because credits need no check. Asynchronous balances are safe only where no write needs the exact balance. The concurrent retry is safe because the unique index serialises it. Each of those reasons is a short sentence, and together they are the evidence of depth that a strong rating requires.
Testing the invariants
The candidate could add how the invariants are tested. Property based tests run random sequences of concurrent transfers, retries and failures against a test ledger and check after each run that all entries sum to zero, no key produced two transfers and no user balance went negative. Running these continuously catches bugs that ordinary tests miss.
Summarising the deep dive
Before moving on, the candidate summarised in one sentence: retries are safe because a unique key serialises them and every hop carries a key, and hot merchants are handled by sub accounts because credits need no balance check, with asynchronous aggregation reserved for receive only extremes. A clear summary marks the end of the deep dive and gives the interviewer a sentence to write down.
A mid level answer reaches double entry, a balances table and idempotency keys with guidance. A senior answer adds the transactional outbox, handles the concurrent retry precisely and splits hot accounts with a reason it is safe. A staff answer also chooses where atomicity lives across partitions, extends idempotency to the bank, designs reconciliation and explains which accounts may use asynchronous balances and why.
The final stretch covers what happens when parts of the system fail, how the ledger stays consistent with the outside world and how the candidate closes the session.
Database failures
Interview Dialogue
The candidate applied the conflict rule from the first section directly, which shows that the early requirement was not decoration but a decision tool.
Service and relay failures
Interview Dialogue
Every failure is described in terms of what is delayed and what is preserved. For a ledger, the important message is that no failure loses or duplicates money; at worst, it delays it.
Reconciliation
Interview Dialogue
Reconciliation is the part of payments design that many candidates forget, and it is often the one interviewers at payments companies care about most. The candidate explained what is compared, what kinds of mismatches occur and how they are fixed in a way that preserves auditability.
The trade offs
Interview Dialogue
Extensions
Interview Dialogue
Each extension is described as a reuse of the existing model, which shows that the design was built on the right abstraction.
The close
Interview Dialogue
Looking back at the session
The time split was roughly seven minutes on requirements and numbers, seven on the API and data model, eight on the high level design, fourteen on the deep dive and eight on failures, reconciliation and the close. The data model took a little longer than in the other walkthroughs because, for a ledger, it carries most of the design.
What made it strong
The candidate broke correctness into checkable properties and mapped each to a mechanism. The data model made auditability and conservation properties of the system rather than promises. The high level design kept atomicity in proven infrastructure and avoided dual writes. The deep dive handled the concurrent retry and hot accounts with reasons for safety. The failure discussion applied the correctness rule consistently, and reconciliation closed the loop with the outside world.
Common mistakes on this problem
Common mistakes include storing only balances with no entries, using floating point amounts, updating a balance and publishing an event as two separate writes, retrying transfers without idempotency keys, ignoring hot accounts, building a custom two phase commit and forgetting reconciliation altogether. Each one is a real source of incidents in production payment systems, which is why interviewers probe for them.
Closing the course
This walkthrough ends the course. Across the three walkthroughs, the problems were very different, a flash sale, a live editor and a ledger, but the shape of each session was the same: scope tightly, let the numbers name the hard part, define the interface and data, draw a design with reasons, go deep where the difficulty lives, cover failures in terms of what users experience and close with the trade offs. That shape is the framework, and with practice it becomes the natural way to run any system design interview.
Monitoring
A few signals tell the team the ledger is healthy: transfer success and error rates by reason, transaction latency, lock waits on the hottest accounts, outbox lag between commit and publish, the age of the oldest unsent outbox row and, most important, the results of the internal invariant checks and reconciliation. A non zero ledger sum or a balance mismatch is a top priority alert, because it means money has been created or destroyed somewhere.
Questions the interviewer might still ask
How would you support a hold, as when a hotel reserves money before charging? Record a transfer from the user to a holds account; capture is a transfer from holds to the merchant, and release is a transfer back. How would you produce monthly statements? Read entries by account and month, which the index already supports, and store the generated statement. How would you handle a merchant disputing a payment? A dispute is a transfer from the merchant to a disputes account, reversed if the merchant wins. Each answer reuses the transfer as the single primitive, which is the clearest evidence that the model is right.
Practising this walkthrough
Try the problem yourself without the dialogue, then compare. Check whether you split correctness into properties, whether you avoided a dual write and whether you remembered reconciliation. Then try a variation, such as multiple currencies or holds before capture, and see how much of the model carries over unchanged. If the answer is almost all of it, the model is right.
One last habit
Notice that in every walkthrough the candidate checked in after the high level design, summarised the deep dive and closed with the trade offs. Those small habits make a session easy to follow and easy to score, whatever the problem.
A ledger can be internally consistent and still wrong about the world. Daily reconciliation against bank and processor settlement files, plus internal checks that entries sum to zero and balances match entries, is how real payment systems catch the errors no design fully prevents.