Skip to content
RED SAGSkills
hardBackend Developer interview question

How would you design a ledger for a wallet or payments product so balances are always correct?

What the interviewer wants to hear

  • Double-entry bookkeeping: every transfer has balanced debit and credit entries
  • Entries are immutable and append-only; corrections are new entries
  • Integer minor units with currency, never floats
  • Idempotency keys and strong transactions or row locking to avoid double spends
  • Balances derived from entries, cached with checks, and reconciled with providers

Model answer

I would use double-entry bookkeeping. Every movement of money is a journal transaction with two or more entries, debits and credits, that must sum to zero, so money is never created or lost by a bug. Entries are append-only and never updated; a mistake is fixed with a reversing entry, which gives a full audit trail. Amounts are stored as integers in minor units, like cents, together with a currency code. Each request carries an idempotency key with a unique constraint so retries do not double charge. To stop overspending, I write the entries and update a cached balance in one database transaction, locking the account row or using a version check, and enforcing that the balance cannot go below zero. The cached balance can always be rebuilt from entries. Daily reconciliation compares the ledger with bank and provider reports.

Can you answer it under time pressure?

Take a timed hard round and get scored on every answer.

Start mock interview

More hard Backend Developer questions