State Reconstitution (Replay)
To determine the current state of an entity, the system does not read a single mutated row. Instead:- It loads the entire stream of past committed events belonging to that specific Aggregate ID from an append-only store.
- It initializes an empty instance of the aggregate in memory.
- It replays each event in-order through the aggregate’s deterministic
applymethod.
The Command Execution Lifecycle
The following sequence diagram illustrates the complete, end-to-end lifecycle of a client dispatching a command to execute a transaction, persisting the resulting event facts, and asynchronously updating the query models:Why Event Sourcing?
By building your core around event streams, you receive several powerful architectural benefits:- Auditability: You have an indisputable, complete history of everything that has ever occurred in your domain. Excellent for compliance, business intelligence, and security audits.
- Deterministic Bug Reproduction: If a production error occurs, you can fetch that aggregate’s event stream, load it into a local unit test, and replay it. You will replicate the exact in-memory state of the aggregate at that moment, letting you debug and resolve issues rapidly.
- Temporal Querying: You can reconstituted state to any point in time. If you want to know what a customer’s account looked like exactly on January 1st, 2026, you simply replay only the events committed prior to that date.