System design walkthroughs 5: money systems
Problem. Full interview answers for the bank’s money questions — where correctness outranks everything. Part 5 of 6. (1: foundations · 2: feeds · 3: geo & marketplaces · 4: media & storage · 6: AI era)
24. Stripe-style payments [Stripe, PayPal, Square]
Requirements. Functional: charge cards, refund, webhooks for async outcomes. Non-functional: never double-charge, PCI scope minimal (never touch PANs — tokenize at the edge).
Estimation. 10k charges/s peak; ledger append-only, so storage is bounded by transaction count × ~1 KB, trivially shardable by merchant.
API. POST /charges {amount, token, idempotency_key}, POST
/refunds {charge_id}, webhooks charge.succeeded with retry + signing.
Core design. Idempotency keys on every mutating call (same key, same result, safe retries); ledger as the source of truth; settlement as nightly reconciliation jobs, not inline logic.
Deep dives. Double-charge prevention as the correctness core (say the mechanism, not the slogan), currency conversion timing, dispute flows, and cite Stripe’s engineering blog once.
25. Visa-style card processing [Databricks, reported Sep 2026]
Requirements. Scope first: card network between banks, or merchant-side service? Then functional: authorize, clear, settle. Non-functional: authorization in milliseconds, five-nines on the auth path.
Estimation. 5k auths/s sustained, 50k/s peaks; auth payloads tiny (~2 KB) — bandwidth is noise, latency budget is everything.
API. POST /authorize {pan_token, amount, merchant} (sync, millisecond
budget), batch POST /clearing, POST /settlement end of day.
Core design. Split the paths: authorization decides from memory (precomputed risk scores, standby replicas, no disk on the hot path); clearing/settlement runs as a separate batch pipeline hours later. In-memory decisions with async persistence is the shape; say why the disk can’t be in the loop.
26. Stock trading system [Robinhood, Jane Street, Citadel]
Requirements. Functional: place/cancel orders, match by price-time priority, report fills. Non-functional: deterministic matching, no double-fills across failover, microsecond-measured latency.
Estimation. 100k orders/s per symbol universe; market-data multicast dwarfs order flow — size ingest and matching separately.
API. POST /orders, DELETE /orders/{id}, drop-copy GET /fills
stream, GET /book/{symbol} snapshot + deltas.
Core design. Single-threaded matcher per symbol (determinism beats raw throughput — say this sentence); sequence-numbered everything; pre-trade risk checks inline; failover with replay from the journal so a standby never double-fills; back-office reads drop copies, never the live book.