A wallet balance is an answer to a question: how much can this account use now? The ledger must also explain why that answer is correct. Designing the posting model around business events gives engineering and operations a shared language for deposits, reservations, spending and corrections. Begin with a small set of explicit event types rather than allowing every feature to edit a balance field directly.
Name the accounts before naming the tables
Write down what each account represents and who owns the obligation behind it. A customer balance, a provider clearing account and an operational adjustment account serve different purposes. Define which currencies each can hold and whether balances represent available value, reserved value or another documented position. Similar-looking numbers should not become interchangeable simply because they share a database type.
Walk through one complete example on paper. Show the original deposit, a reservation, its completion and a later correction. Each movement should connect to a specific business event and have an understandable counterpart. Have product, finance and engineering review the example together before turning it into a schema. Disagreement at this stage is cheaper than unexplained production balances.
Make the posting boundary indivisible
A posting should either record all required entries or none of them. Keep the event identifier, validation and ledger entries within an appropriate consistency boundary. Concurrent requests must not both spend the same available amount. Database transactions help, but the chosen isolation and application checks still need to match the actual concurrency problem.
Keep external provider calls outside a long-running database lock. Record the intended operation, send it through a recoverable workflow and apply the resulting event when its outcome is established. A network call cannot be made atomic merely by placing it between local database statements. Explicit intermediate states make that limitation manageable.
Correct with a new explanation
Preserve the original posting when an error is discovered. Use a linked reversal or adjustment that records the reason, authority and relevant references. Editing historical entries in place can make yesterday's report impossible to reproduce and obscure which downstream processes already relied on the earlier record.
Separate a technical reversal from a commercial goodwill credit. They may both increase a displayed balance, but they have different meanings and approval routes. Require a specific event type and a human-readable explanation rather than treating a free-text note as the only distinction.
Prove the balances from the entries
Build a repeatable check that derives account positions from their entries and compares them with any cached balance used by the product. Investigate discrepancies through event references rather than manually forcing the cache to an expected number. Include closed and inactive accounts in periodic integrity checks.
Test simultaneous spending, repeated provider events, incomplete operations and correction sequences. The acceptance result should include both the customer-visible outcome and the resulting ledger explanation. A wallet is easier to operate when an unfamiliar reviewer can reconstruct an event without relying on the memory of the engineer who built it.
The key decisions.
- Give each account and posting type an explicit business meaning.
- Keep ledger changes atomic while external calls use recoverable workflows.
- Preserve historical entries and explain corrections with linked records.
Sources & further reading
Primary references for the concepts discussed. Check the applicable documentation when planning implementation.







