Event Sourcing in Python — ELI5

Think about your bank account. The bank does not just store your current balance. It stores every single transaction: deposits, withdrawals, transfers, fees. If you want to know your balance, the bank can add up all those transactions from the beginning.

That list of transactions is your history. And because the bank keeps it, you can answer questions like “What was my balance on March 1st?” or “Show me all the deposits from last month.”

Event Sourcing works the same way for software. Instead of saving just the current state of something (like “the order is shipped”), you save every event that ever happened to it:

  1. Order was created
  2. Item was added
  3. Payment was received
  4. Order was shipped

To know the current state, you replay those events from the beginning. To know the state at any point in the past, you replay events up to that moment.

Why not just save the current state? Because you lose history. If all you know is “the order is shipped,” you cannot answer “when was the payment received?” or “was an item removed and re-added?”

Event sourcing is like keeping a diary instead of just a snapshot. The diary tells the full story. The snapshot only tells you where things stand right now.

Most apps do not need this. But for banking, auditing, logistics, and anything where knowing the full history matters, event sourcing is incredibly powerful.

The one thing to remember: Event Sourcing saves every change as an event so you always have a complete, replayable history — not just a snapshot of where things are now.

pythonarchitectureevent-sourcing

See Also