Video in progress
A team proposes building the new accounting module with event sourcing. How do you evaluate this decision?
With event sourcing you get full history and audit for free, and you can rebuild the state at any point in time and build new projections. But event schema evolution, rebuilding projections, eventual consistency and the team's experience are a serious cost. It pays off only if the domain truly rests on events.
📖 Answer
In event sourcing the state isn't stored, only the sequence of things that happened: AccountOpened, MoneyDeposited, MoneyWithdrawn. The current balance is the result of replaying them. For reading, separate projections are built (CQRS).
Accounting is one of the best-fitting domains, because by nature it is already a journal: there is no deletion, only reversals. What you get:
- A complete, immutable audit: a precise answer to "what was the balance on March 1 and why?"
- If a new report is needed, you can build a new projection from the old events.
- Error analysis: replaying exactly which sequence of events led to the bug.
The costs, which I discuss openly:
- Events are forever. The event format from 3 years ago has to be readable by today's code: upcasting, versioning. You can't delete a wrong event, only add a correcting one.
- Projections are updated asynchronously, so in the UI you get "I saved it, but it isn't in the list" cases. Rebuilding a projection from scratch can take hours with millions of events, so you need snapshots.
- Concurrency: optimistic locking by aggregate version (
expected_versionin the event store). - Personal data and the "right to be forgotten" collide with immutable events (you need solutions like crypto-shredding).
- Team experience: this is a completely different way of thinking from ordinary CRUD, and mistakes on the first project are expensive.
- Tools: Axon Framework, EventStoreDB, or your own table on PostgreSQL, each with its own dependencies.
The alternative is a lighter solution: traditional tables + an immutable journal table (ledger_entry, INSERT only) + domain events through an outbox. It gives you 80% of the accounting requirements (audit, reversals, history) without the complexity of event sourcing.
The decision: I ask the team for a concrete list of requirements: which of them can only be solved with event sourcing? If the answer is "audit and history", a ledger table is enough. If replay over time, many projections and complex aggregates are really needed, I would choose event sourcing only for that module, in a limited scope and led by someone experienced.
Sign up to mark studied questions and save your progress.