Skip to content
Code by Pawpu

System Design Simulator

Payment System

Design a charge and ledger path that survives retries and provider lag.

Loading simulator…

How the challenge works

  • Store the intent first. The provider call is a side effect of a recorded command.
  • Webhooks are not a source of truth until you reconcile them to that command.

Key concepts

Idempotency

The same key must return the same charge, even when the client, the worker, and the webhook all retry.

Ledger before cache

Balances derived from an append-only log survive a Redis flush. The reverse does not.

Common mistakes

  • Mutating a single balance column under contention.
  • Trusting a CDN or search cluster for money state.

Recommended architecture

  • API with idempotency keys, durable database/ledger, queue and workers for provider I/O and webhooks, rate limits on charge endpoints.

Interview tips

  • Walk a double-submit and a delayed webhook as two sequence diagrams.

Related challenges

Built by Al Beltran