Cognitive Scaffold

Preparing your thinking workspace

arrow_back_ios_new
MENTAL MODEL · M4789

Event Sourcing

Event Sourcing
CultureHigh supportHistory
Included
account_tree

Updated 2026-08-10

Loading revision record…

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.

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/1

Practice this model in one real situation:

Check to track your progress (stored locally)
Learning progress0%

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

  • link
    martinfowler.comhttps://martinfowler.com/eaaDev/EventSourcing.htmlZH · Explicit
    verified
account_treeGenealogyexpand_more

RELATED MODELS