Build a Global Remittance Platform: FX, Compliance, Payouts
System DesignModel answerLast updated
Design a service that lets users send money abroad with live FX quotes, fees, limits, multiple funding and payout options, status tracking, refunds and notifications.
Problem
You are asked to design a platform that lets people in one country send money to recipients in another country, in the style of a consumer remittance app.
Required capabilities
- Provide near-real-time exchange-rate quotes and compute the fee and the amount the recipient will receive.
- Enforce country-specific transfer restrictions and per-user limits.
- Accept funding from bank accounts, cards, or an in-app wallet balance.
- Deliver payouts to local bank accounts, mobile wallets, or cash pickup partners.
- Let users track the status of each transfer.
- Handle failures, cancellations and refunds correctly.
- Notify users when important state changes occur.
What to cover
Walk through the following areas and justify your choices:
- Requirements and a rough capacity estimate
- Public and internal APIs
- Core services and how they interact
- Data model, including how money is recorded
- The end-to-end transfer workflow and its states
- Exchange-rate sourcing and quote handling
- Compliance and limit checks
- Consistency and idempotency guarantees
- Scalability and reliability
- Observability and reconciliation
State any assumptions you make, such as traffic volumes and the length of time a quote stays valid.
Hints
Hint 1
Treat this as a money-movement problem rather than a CRUD one: begin with an append-only double-entry ledger and an explicit transfer state machine, then think about scale.
Hint 2
Every external call (card processor, bank, payout partner) can time out or answer late. Ask what makes each step safe to retry, and how a duplicate request or duplicate worker is prevented from moving money twice.
Hint 3
Lock the exchange rate into a stored quote with an expiry, and decide who bears FX risk after that. Also decide what happens to the rate, fee and limits when a transfer fails and must be refunded.
Hint 4
Compliance is part of the workflow, not a pre-check: consider where sanctions screening, KYC-tiered limits and manual review fit among the states.
Model answer
Medium Try it yourself first — then compare your approach, complexity and edge cases.
Framing
This is about moving money safely across unreliable parties, not about raw throughput. The priorities are:
- Correctness: never lose or duplicate money.
- Explicit state: each transfer is a long-running, multi-party workflow.
- Uncertainty: banks, card networks and payout partners time out, respond late or contradict each other.
- Regulation: compliance and limits are first-class steps.
I would lead with the ledger and the state machine, and treat scale as secondary.
Requirements and sizing
Functional: quote (rate, fee, receive amount); create a transfer against a locked quote; fund; pay out; per-corridor rules and per-user limits tiered by KYC level; status tracking; failures, cancellations, refunds; notifications.
Non-functional: strong consistency and auditability for money; idempotent operations; 99.95%+ availability for quoting and creation; quote p99 under 200 ms; 5-7 year record retention.
Estimates (assumed): 2M transfers/day is about 25 TPS average and about 250 TPS peak. If quotes run about 20x transfers, that is roughly 500 QPS average and 5k QPS peak. At around 10 KB of ledger rows, events and partner logs per transfer, storage is about 20 GB/day, or about 7 TB/year. Rates for about 150 currencies refresh every 1-5 seconds. Write volume is modest, so correctness is the hard part.
APIs
POST /v1/quoteswith source currency, amount (send or receive side), destination country and currency, funding type and payout type. It returns quote_id, rate, fee, send and receive amounts, and expires_at.POST /v1/transferswith anIdempotency-Keyheader, carrying quote_id, recipient_id, funding instrument and purpose. It returns transfer_id and status.GET /v1/transfers/{id}returns status, timeline and estimated delivery.POST /v1/transfers/{id}/cancelis allowed only before payout submission.POST /v1/recipientsstores bank, wallet or pickup details, encrypted.- Signed partner webhooks at an internal callback endpoint.
The client generates the idempotency key once per user intent and reuses it on every retry.
Data model
Use a relational store (sharded Postgres or a Spanner-like system) for money data.
- quotes: mid rate, customer rate, margin, fee, amounts, expiry, used_by_transfer_id.
- transfers: status, version, quote, funding and payout references, with a unique constraint on (user_id, idempotency_key).
- transfer_events: append-only transition history for audit.
- ledger_entries: immutable double-entry rows (txn, account, debit/credit, amount, currency). Each transaction nets to zero per currency. Accounts include user wallet, funding clearing, FX position per currency, fee revenue, partner payable and refund payable.
- limits_usage: consumed amount per user and window, updated in the same transaction as the reservation.
- corridor_config: allowed methods, min/max, required fields, partner priority.
- outbox: events written in the same transaction as the state change.
Architecture
Gateway (auth, rate limiting) in front of a Quote Service (backed by an FX Rate Service), a Transfer Orchestrator, and the services it calls: Compliance, Limits, Funding, Ledger and Payout (with per-partner adapters). An outbox feeds Kafka, which drives Notifications, Analytics, Reconciliation and Treasury. A Reconciliation Service ingests partner and bank settlement files.
Workflow (saga)
States: CREATED -> SCREENING -> (ON_HOLD) -> FUNDING -> FUNDED -> PAYOUT_SUBMITTED -> PAID_OUT. Failure paths: REJECTED, FUNDING_FAILED, PAYOUT_FAILED -> REFUNDING -> REFUNDED, CANCELLED.
- Create in one DB transaction: check the quote is unexpired and unused and mark it used, reserve limits, insert the transfer, write the outbox row.
- Screening: sanctions/PEP checks on both parties, corridor rules, AML and fraud scoring. A fuzzy sanctions match goes to ON_HOLD for an analyst rather than auto-rejecting.
- Funding: cards are authorized then captured; ACH is slow and reversible, so either wait for settlement or front funds based on risk; wallet funding is a ledger debit. On success post ledger entries.
- Payout: pick a partner by corridor config, health and cost, and submit using our transfer_id as the partner's idempotency reference. Confirmation arrives by webhook or polling; then post entries moving value to partner payable.
- Failure: a rejected payout (for example a bad account) leads to a corrected retry or a refund. A refund is a new compensating ledger transaction, never a deletion. A common policy refunds the original source amount and lets the business absorb the FX difference.
Drive steps with a durable workflow engine (Temporal/Cadence-style) or a DB-backed state machine with workers. Use optimistic concurrency, such as UPDATE ... WHERE status='FUNDED' AND version=n, so duplicate workers cannot advance a transfer twice.
Exchange rates and quotes
- Ingest from two or more providers, discard outliers against the median, flag stale feeds, and publish versioned mid-rates to a cache such as Redis.
- Customer rate = mid x (1 - margin), with margin varying by corridor, amount tier and promotion. Fees come from a rules table (flat plus percentage, by funding method, since cards cost more than ACH).
- A quote freezes the exact rate for 30-60 seconds. The business carries the FX risk in that window, and Treasury hedges the aggregate FX position.
- A circuit breaker halts quoting for a pair when the market moves beyond a threshold.
Consistency and idempotency
- The ledger is the source of truth; balances are derived or checked against it.
- Idempotency keys at the API, a unique constraint to dedupe, and stable references on every outbound call (processor, partner).
- Outbox pattern for reliable event publishing, with consumers that tolerate duplicates.
- For unknown outcomes (timeouts), never assume failure: query the partner by reference, and let reconciliation resolve what remains.
Scalability and reliability
- Shard transfers and ledger by user or transfer ID; quotes are stateless and cache-friendly.
- Isolate partner adapters with timeouts, circuit breakers and per-partner queues, and fail over to alternates where the corridor allows.
- Multi-AZ database with synchronous replication for money data; replay from events for derived stores.
- Daily (or more frequent) reconciliation against bank and partner files, with automatic breaks raised to operations.
Observability
Track funnel conversion by state, time in each state, partner success and latency, ON_HOLD queue age, FX quote staleness, ledger imbalance (which must be zero), and reconciliation breaks. Alert on stuck transfers and trace each by transfer_id. Retain immutable audit trails for the regulatory period.
Common mistakes
- Updating balances in place instead of using an append-only double-entry ledger.
- Treating a timeout as a failure and retrying without a stable reference, causing double payouts.
- Locking the rate without an expiry or without a plan for FX risk.
- Placing compliance only at the front instead of as a state with a manual-review path.
- Deleting or editing records during refunds instead of compensating entries.