SD-47 · Back to the write-up
Design a Wire Transfer API
Commit the transfer, its idempotency key, a hold and an outbox row together; send from the outbox; settle with double-entry entries; reconcile daily.
Follow a request
Create a transfer
Retry after a timeout
Send to the network
Settle or return
Network goes silent
Reconcile the day
Clients
Edge
Services
Delivery and network
ClientAPI or app
API gatewayAuth + limits
Transfer serviceStateless, many
Risk + sanctionsScreening
Ledger DB16 shards by account
Outbox queueCommitted sends
Network senderOutbox workers
Payment networkExternal rail
ReconcilerDaily + hourly
Idempotency-Key: 7f3c….1 / 7The numbers, at a glance
1 transfer ≈ 58/s20 reads ≈ 1,160/s
3.3 TBY1
9.9 TBY3
16.5 TBY5
23 TBY7
1 of 6 writes hits clearing5 spread over accounts
Creating a transfer, in order
The network is not called here; the 202 only promises the money is held and the send is queued.
Client
Gateway
Transfer service
Risk
Ledger shard
Outbox queue
1 POST + Idempotency-Key
2 authed request
3 screen
4 clear
5 txn: key, hold, transfer, outbox
6 committed
7 202 held
8 202 { id }
9 relay outbox row
RequestResponseAsync, does not block
Making retries safe
The decision this question is really about.
POSTtimeout
POST again
2 wires sent
+ Nothing to build.− Each retry is a second wire.
hash(acct, bene, amt)
seen in 10 min?
rent blocked
+ No client change.− Blocks real repeat payments.
POST + key
INSERT keyhold + outbox
retry → saved 202
+ Client names the retry; atomic.− Keys kept 30 days.
How it grows
Add a box only when a number forces you to. Highlighted boxes are new at each stage.
Client
Transfer server
Database
Client
API gateway
Transfer × NRisk + sanctions
Ledger DB
Client
API gateway
Transfer × NRisk + sanctions
Ledger DBOutbox queue
Network senderPayment network
Client
API gateway
Transfer × NRisk + sanctions
Ledger · 16 shardsOutbox queue
Network senderPayment networkReconciler
Was this walkthrough useful?Your vote tells us what to improve next.