Nguyen Le PhongNguyen Le Phong

Event Sourcing: A Beginner's Guide

A beginner-friendly guide to Event Sourcing: storing facts as an append-only event history, rebuilding current state through projections, and understanding when the pattern is worth its operational cost.

The easiest way to understand Event Sourcing is to think about an office notebook that nobody edits. Every time something important happens, someone writes a new line: meeting started, decision changed, invoice approved, deployment rolled back. The current situation can be understood by reading those lines in order, but the notebook itself is not trying to be the current situation. It is the memory of how the current situation came to be.

Most applications store state as the latest answer. An order has status paid. A profile has an address. A subscription has a plan. When something changes, the row is updated and the old value quietly disappears unless audit logging is added somewhere else. This is simple and often correct. A lot of software should stay this way because the business question is only, what is true now?

Event Sourcing starts from a different question: what happened? Instead of storing only the current state, the system stores a sequence of events such as OrderPlaced, PaymentReceived, AddressChanged, ShipmentCreated, or SubscriptionCancelled. The current state is rebuilt by applying those events in order. The order is paid because a PaymentReceived event appeared after the OrderPlaced event. The address is different because an AddressChanged event happened later.

This can feel strange at first because it asks us to stop treating the database row as the source of truth. In an event-sourced system, the source of truth is the event stream. Projections, read models, dashboards, and search indexes are derived views. They are useful, but they can be rebuilt if needed. The event history is the part the system protects most carefully.

The benefit is not only auditability, although auditability is a big one. Event Sourcing can answer questions that normal state storage often loses: when did this change, who triggered it, what was the sequence before the failure, and what would the state look like if we replayed events through a new projection? This is powerful in domains where history matters: finance, inventory, bookings, claims, workflow approval, compliance, or collaborative systems.

It also changes how teams model the domain. Events should describe facts in business language, not technical commands. UserUpdated is weak because it hides the meaning. EmailChanged, CreditLimitApproved, and RefundRequested carry more context. A good event name helps future readers understand the business story without opening the UI or guessing from column names.

But the pattern has real cost. Event schemas evolve. Badly named events stay in history for a long time. Replaying millions of events can be expensive without snapshots. Projections can lag. A bug in projection logic may require rebuilding read models. Engineers must understand idempotency, ordering, concurrency, versioning, and operational recovery. Event Sourcing is not a decoration for making architecture look advanced. It is a storage model with responsibilities.

A helpful beginner distinction is this: Event Sourcing is not the same as using events. A system can publish events after updating a normal database and still not be event-sourced. Event Sourcing means the events are the primary persisted record. The current state comes from them. That distinction matters because the operational expectations are much higher.

The pattern often pairs with CQRS because write and read needs become different. The write side validates commands and appends events. The read side builds query-friendly projections. A customer support screen does not need to replay the whole stream every time. It reads a projection prepared for that screen. This separation can make complex domains clearer, but it can also make a simple CRUD app needlessly heavy.

My practical rule is to look for the pain first. If the business constantly asks why something changed, if audit history is central, if state transitions are rich, if rebuilding alternate views from history is valuable, Event Sourcing may be worth studying seriously. If the system mostly edits simple records and nobody needs the story behind the latest value, a normal relational model with good audit fields may be kinder to the team.

The calm way to learn Event Sourcing is not to redesign everything. Pick one small domain where history matters. Write the events down in plain language. Build one projection. Break it and replay it. Notice where versioning and idempotency appear. The lesson will become clearer through the small exercise than through any diagram.

Event Sourcing is a promise to remember how the system arrived here. That promise can be valuable, but it should be made with care. If you have worked with an event-sourced system, I would be interested in the moment when the history helped, and the moment when the history became expensive.

Qu'en avez-vous pensé ?