</> MAANG.io

Expert

Design landmark systems in depth, from Dynamo, GFS, Bigtable and Kafka to payments and ads pipelines.

0 of 232 solved 0%

Section 1: Where Every Cent Has an Owner - Problem Understanding & Requirements

Executive Summary: This section covers the first ten minutes of the interview. We decompose the prompt into three inside parties (buyer, seller, platform) and two outside ones (the PSP, and the banks and card networks behind it), and trace money moving forward (charge, split, payout) and backward (refund, chargeback). Six clarifying questions each create or kill a subsystem. The answers become functional requirements, a ranked list of non-functional requirements, five invariants that define "correct" for money, and an out-of-scope list with reasons. We also meet Maya's $120 cart, which follows us through all twelve sections.

The interviewer reads the prompt:

"Design the payment system for a large online marketplace. Buyers pay at checkout, often for items from several sellers in one cart. We pay the sellers, keep a commission, and have to be able to prove where every cent went. It has to be correct, auditable, and survive Black Friday."

Most candidates hear "payments" and draw a box labeled Stripe. That's the trap. Charging a card is the part you buy. The part you build is everything after it: deciding whose money each cent is, holding it until it's safe to release, paying it out exactly once, and clawing it back when a buyer's bank reverses the sale.

Key Insight: The prompt's hardest phrase is "prove where every cent went." A system that moves money correctly but can't explain a balance three years later fails an audit just as surely as one that double-pays. Provability is a requirement, not a reporting feature.

Decomposing the Prompt

Map the territory before asking anything:

  • Inside parties: the buyer who pays, the seller who is owed, and the platform (us), which keeps a commission and carries the risk when money flows backwards.
  • Outside parties: the PSP (payment service provider), which talks to card networks and holds funds; and the banks and card networks, which authorize charges, settle them days later and can reverse them months later through chargebacks.
  • Forward flow: buyer's card is charged, the charge is split among sellers and the platform, and sellers get a bank payout.
  • Backward flow: a refund (we choose to return money) and a chargeback (the buyer's bank takes it back, whether or not we agree).

Here is the whole shape of the money, both directions:

Money flow in a marketplace: buyer's card charge goes through the card network to the PSP, which holds funds, while the platform ledger splits each capture into seller balance, platform commission and PSP fees, with refunds and chargebacks flowing back

The ledger box says records ownership, not holds money: the funds sit at the PSP, and our job is to know which cents belong to whom.

Quick check before moving on:


Sign in to continue reading

The rest of this lesson is available with a free account. Signing in with Google or Microsoft is free.

Sign in to read the full lesson

Sign in to MAANG.io

Use your Google or Microsoft account — no password to remember.

Continue with Google Continue with Microsoft

Please accept the terms above to continue.