Event Sourcing
Updated 2026-08-10
Summary
An architecture that stores the full sequence of events rather than current state, rebuilding state by replaying them.
Definition
Event sourcing stores every state change as an immutable event in an append-only log, treating the current state as a derived projection produced by replaying those events. The pattern, described by Martin Fowler and widely used with command-query responsibility segregation, provides a complete audit trail and allows a system to reconstruct its state at any past moment. Key qualification: event schemas must be designed for long-term evolution, replay performance requires periodic snapshots, and commands must be distinguished from events, since only the latter are facts about the past.
Introduction
How to use
- Record the changes: store what happened rather than only the resulting state. - Replay to inspect: rebuild any past state to understand how the current situation arose. - Separate intent from fact: distinguish a requested command from an event that actually occurred.
Mechanism
If the log of changes is complete and immutable, the current state is only a projection, so it can be recomputed or reinterpreted at any time. This makes auditing and correction possible, because the sequence that produced an error remains visible. The costs are storage growth, replay time, and the discipline required to keep event definitions stable over years.
Practice
In progress 0/1Practice this model in one real situation:
Cases
- Financial ledgers record transactions rather than balances, which allows any historical position to be recomputed.
- Version control systems store commits and reconstruct file states by replaying history.
- Audit-heavy domains such as insurance and healthcare use event logs to reconstruct past decisions.
Common pitfalls
- Designing poor event schemas that become impossible to replay after requirements change.
- Ignoring snapshot strategy, so replay times grow until the system becomes unusable.
- Confusing commands with events and storing intentions as if they were facts about the past.
Sources
Source support: Explicit
- martinfowler.comhttps://martinfowler.com/eaaDev/EventSourcing.htmlverified
account_treeGenealogyexpand_more
PRIVATE NOTES · Only visible to you
SAVED Q&A
ENTRY Q&A · Private saving available
Ask with a clear boundary
thinkingmodels answers from published entry context only.
Your question is sent to thinkingmodels. The answer uses public entry context only.
RELATED MODELS