Build an Idempotent Double-Entry Ledger for Multi-Currency Balances
Last updated: November 29, 2026
Quick Overview
Implement an in-memory ledger that posts balanced journals per currency, rejects postings that would overdraw a customer balance, ignores retried requests with the same idempotency key, and supports converting between a customer's currency balances.
Wise
November 29, 20260
0
0 solved
Implement an in-memory ledger that posts balanced journals per currency, rejects postings that would overdraw a customer balance, ignores retried requests with the same idempotency key, and supports converting between a customer's currency balances.
A Wise Account holds balances in dozens of currencies, and every top-up, conversion and payout must leave the books balanced and survive client retries. This screen checks whether a backend engineer understands double-entry invariants, sign conventions for liabilities, and idempotency, which matter far more here than clever algorithms.
What the Interviewer Expects
- Enforces that each journal sums to zero per currency, not just overall
- Models a conversion as legs through an FX position account in both currencies
- Makes posting idempotent on a client key and atomic (validate everything before writing)
- Keeps entries append-only and derives balances from them
- Uses integer minor units and explains the sign convention for customer liabilities
Key Topics to Cover
How to Approach This
- Apply SOLID principles. Single Responsibility makes code testable, Open/Closed makes it extensible.
- Choose data structures based on access patterns, not familiarity.
- Prefer immutable data and message passing over shared mutable state for concurrency.
- Design APIs with RESTful conventions, versioning, meaningful errors, and pagination from day one.
Possible Follow-up Questions
- How would you make this safe under concurrent posts to the same account in a real database?
- How would you correct a wrong posting without editing history?
- How would you prove at end of day that customer balances match money held at safeguarding banks?
- Where would the realised FX gain or loss on a conversion show up?
Sharpen Your Skills on Codemia
Practice similar problems with our interactive workspace, get AI feedback, and track your progress.
Practice System Design ProblemsSample Answer
Requirements
Operations: post(key, lines) where lines are (account, currency, amount) with debits positive and credits negative; customer_balance(account, currency); convert(...). Invariants: every journal b...
High-Level Design
Store immutable entries and a derived balance map. Customer money is a liability to Wise, so it is credit-normal: a top-up debits the safeguarding bank asset account and credits the customer. A GBP to...