Event sourcing
Event sourcing is a persistence pattern that stores every state change as an immutable event in an append-only log. The current state of an entity is derived by replaying its events. Reading is fast because read models (projections) are pre-built from the event stream; writing is auditable because the event log is the system of record.
Event sourcing pairs naturally with CQRS — events drive both the audit log and the read-model projectors. The biggest benefits are time-travel debugging (replay events up to any past moment to see what state was), audit compliance (the event log IS the audit trail), and integration (downstream systems consume the same events). The biggest costs are schema migration (events are immutable; renaming a field requires upcasters), eventual consistency (projections lag the event log), and operational complexity (event-store backups, replay performance). It's a powerful pattern for the right domain — financial ledgers, multi-stakeholder workflows — and overkill for CRUD admin tools.
Related terms
- CQRS
Command Query Responsibility Segregation is an architectural pattern that splits a system's write path (commands that change state) from its read path (queries that return state) — typically with separate models, sometimes separate databases.
- Saga pattern
A saga is a sequence of local transactions across multiple services that together accomplish a distributed business transaction.
- Domain-driven design
Domain-driven design (DDD) is a software-design approach, formalised by Eric Evans in 2003, that places the business domain at the centre of model design.