# Event Sourcing

> Save each change as an event. Build the present state from them.

**Field:** Software Development  
**Category:** Architecture  
**Also known as:** Event Store, Event Log

## Think of it like

Think of it like a bank statement. It lists each deposit and each spend. The balance is the sum.

## Definition

Event sourcing stores every change to data as an event, not just the latest value. A shopping cart is saved as item added, item added, item removed, not as its final list. The current state is worked out by replaying the events in order. Nothing is ever written over. So you have the full history. The cost is more storage and more complex code.

## Example

Jack's bank app stores each deposit and payment as an event. To show a balance, it adds them up. When a customer asks about a charge from March, it is all there.

## Why it matters

You can see exactly how data got to where it is, which helps with audits and bug hunts.

## Common mistake

Using it for simple data that nobody needs the history of. It adds a lot of work for little gain.

## Three principles

- **Store the changes.** Not just the result.
- **Replay to rebuild.** State comes from events.
- **Full history.** Nothing overwritten.

## Related terms

- [Command Query Responsibility Segregation (CQRS)](https://learn.benibix.com/term/development/cqrs)
- [Event-Driven Architecture](https://learn.benibix.com/term/development/event-driven-architecture)
- [Database](https://learn.benibix.com/term/development/database)
- [Git](https://learn.benibix.com/term/development/git)

## Told apart from

- [Event Sourcing vs CQRS](https://learn.benibix.com/compare/event-sourcing-vs-cqrs): Event sourcing and CQRS are often used together, so people mix them up, but they solve two different problems. Event sourcing is about how data is stored. Every change is kept as an event. CQRS is about how code is split. One side changes data, and another side reads it. Either one works fine without the other.

---

Source: https://learn.benibix.com/term/development/event-sourcing
Author: Behnia Zarei (a developer in Vienna, Austria, who builds and teaches data, AI and business intelligence at BENIBIX)
Publisher: BENIBIX Learn (https://learn.benibix.com/)
Last updated: 2026-11-17
Licence: CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Quote freely with attribution.
