Technical Glossary

Event Sourcing

Definition: Storage pattern that persists entity state as an immutable sequence of events rather than storing only the current state.

— Source: NERVICO, Product Development Consultancy

What is Event Sourcing

Event sourcing is an architectural pattern where entity state is not stored as a mutable record but as an ordered, immutable sequence of events representing every change that occurred. To obtain the current state, all events are replayed from the beginning. Each event describes a fact that already happened and cannot be modified or deleted.

How it works

Instead of updating a database record with new state, each action generates an event stored in an event store. For example, in a bank account, rather than updating the balance directly, events like “500 euro deposit,” “200 euro withdrawal,” and “100 euro transfer received” are stored. The current balance is calculated by replaying the complete event sequence. To improve performance, periodic snapshots store the accumulated state up to a certain point.

Why it matters

Event sourcing provides a complete audit trail of all changes, which is critical in financial, legal, or regulated domains. It allows reconstructing state at any point in time, facilitates error debugging, and enables new retroactive features without losing historical data. Combined with CQRS, it allows optimizing reads and writes independently.

Practical example

An order management system stores each order as a sequence of events: “order created,” “item added,” “payment processed,” “order shipped.” Months later, the team needs a report on how many orders were modified before payment. With a traditional database that only stores the final state, that information does not exist. With event sourcing, querying the event sequence of each order provides the exact answer.

Need help with product development?

We help you accelerate your development with cutting-edge technology and best practices.