Event sourcing
Most ledgers keep the latest balance and a log they hope agrees with it. LedgerTM keeps the events, and works the balance out from them.
Nothing is ever overwritten.
Every movement, correction and decision is recorded as an event, with a trading date, a value date and the person who made it. The state of an account is worked out from its events, which means the audit trail isn't something kept alongside the system of record. It is the system of record.
If you've ever been asked what an account looked like at month-end three months ago and reached for a backup, you'll see why we went this way. We spent years fighting dated values and back-dated corrections on a conventional design before we switched, and we'd been wary of event sourcing for a long time. It's easy to understand and surprisingly hard to do well, which is why we built on Marten and Wolverine rather than writing our own.
| Situation | A conventional ledger | LedgerTM |
|---|---|---|
| A rate change effective last month | Adjust balances by hand, note it somewhere | Post the change with its value date; the engine re-accrues and posts the difference as new events |
| "What did this account look like on 31 March?" | Restore a backup, or trust a report | Replay to 31 March: both what was true then and what was known then |
| A new report nobody planned for | Wait for the next release | Build a new projection over the whole history, retroactively |
| The auditor asks who changed this | Search the log, hope it matches | Read the event: who, when, on whose authority, what it changed |
| A future-dated payment instruction | A batch job with its own rules | An event that applies when the business clock reaches its value date |
Every write is a command and every read is a query, and nothing is ever both.
A command is handled by a single aggregate, which decides what happens and records the events. A query reads a read model built from those events. Every message has to declare which kind it is, the build checks that it has, and a read never touches an aggregate. The name for this is CQRS, and the engine uses it all the way through rather than for one corner of it.
Aggregates decide
There's one for each thing with a history, such as an account, a counterparty, a structure or a payment. Aggregates hold the rules and record the events, and they never serve reads.
Read models serve
Lists, details, statements and dashboards, each shaped for its own screen and rebuilt from the events whenever the shape changes. There are about eighty of them.
Why it matters
Writes stay small and easy to audit, reads stay fast and can be thrown away and rebuilt, and a new screen means a new projection rather than a change to the model.
A long history doesn't mean a slow account.
Every account keeps a snapshot that's updated in the same transaction as each write, so loading one never replays years of events. Lists, statements and dashboards read tables built from the events as they happen, rather than working anything out on the fly. And a question about a past date reads the dated values directly instead of rewinding the account. Proper benchmarks at scale come before the production release, and we'll publish them.
The forecaster runs the same code as tonight's day-end.
Project an account to maturity and you see exactly what the day-end will post, day by day, and a test proves that the two never drift apart.
Events answer "when did we know?" and dated properties answer "when was it true?", and the model needs both.
A correction is a new event rather than a data fix, so the number you showed a regulator can be reproduced from the stream months later, to the cent.