Skip to main content

Command Palette

Search for a command to run...

πŸ“œ Event Sourcing Explained Like You're 5

Published
β€’2 min read
S

Building AI systems and writing about how they actually work. Master of AI @ University of Technology Sydney. Previously B.Tech CS with focus on IoT. I believe the best way to learn is to explain. That's why I'm documenting tech concepts with simple analogies (@sreekarreddy.com). AWS Certified β€’ Azure AI Certified β€’ Neo4j Professional β€’ Google Data Analytics When not coding: exploring Sydney, working on side projects, and teaching tech to anyone who'll listen.

Store events, not current state

Day 117 of 149

πŸ‘‰ Full deep-dive with code examples


The Bank Statement Analogy

Your bank doesn't just show your balance:

  • It keeps every transaction ever
  • Deposit $100, withdraw $20, transfer $50...
  • You can see exactly HOW you got to your current balance

Event Sourcing stores all the events that happened!

Not just the final result, but every step along the way.


The Problem It Solves

Traditional databases store current state:

  • "User has $500 in account"
  • But how did they get there?
  • What happened yesterday?

If you only store current state:

  • Can't answer "what changed?"
  • Can't undo mistakes easily
  • Can't understand the journey

How Event Sourcing Works

Instead of storing just the result:

Traditional: { balance: $500 }

Event Sourcing:
1. AccountCreated (initial: $0)
2. Deposited $1000
3. Withdrew $300
4. Transferred $200 to Friend
5. Deposited $0 (fee charged mistake?)

Current balance = replay all events = $500

Every change is an event, stored forever.


Benefits

  • Complete history β†’ See exactly what happened
  • Time travel β†’ Rebuild state at any point in time
  • Audit trail β†’ Perfect for compliance
  • Debug easily β†’ Replay events to find issues
  • Undo/redo β†’ Just remove or replay events

When To Use It

Great for:

  • Financial systems (need full audit trail)
  • Shopping carts (track user journey)
  • Gaming (replay matches)
  • Collaboration tools (track all changes)

Not needed for simple apps where you don't care about history.


The Trade-Off

  • More storage β†’ You're keeping everything
  • More complexity β†’ Rebuilding state takes work
  • Worth it β†’ When history matters!

In One Sentence

Event Sourcing stores every change as an event, so you can trace how things reached their current state.


πŸ”— Enjoying these? Follow for daily ELI5 explanations!

Making complex tech concepts simple, one day at a time.

More from this blog

esreekarreddy

132 posts