Event Sourcing From The Ground Up

  • 07-08, 09:30–11:00, Club H
  • 07-08, 11:15–12:45, Club H

All times in Europe/Prague

We often think about data in terms of storing the current state of our models. If a chess player moves a piece, we update the state of the board and persist it. This makes it easy to query the current state of the game, but also poses some challenges: How do we know which moves led up to the current state? And how do we ensure that the state remains consistent, even in a distributed system?

Event Sourcing takes a different approach to storing state. Instead of storing the current state as-is, we store the sequence of events that led to the current state. If we need to know the current state, we can replay this immutable record of events to reconstruct it. Not only does this give us an immutable audit log, this also promotes loose coupling and enables optimistic concurrency.

In this tutorial, we are going to build an “Event Sourcing”-based backend for a simple Connect 4 game. Rather than using a framework that abstracts away some of the core principles, we are going to implement the mechanisms ourselves to help us understand the core principles.

Outline

  • Introduction to Event Sourcing and Domain-Driven Design
  • Modeling the events in our game
  • Implementing our first events and our aggregate
  • Reconstructing state from events
  • Persisting the events
  • Beyond this tutorial + Q&A

Audience & Preparation

This tutorial is for you if you’re interested in Event Sourcing but don’t have any real experience with it yet. We do expect you to have at least an intermediate level in Python.

Do make sure to bring your laptop, with the following tools installed:
- Python 3.12
- Docker (free-to-use for educational purposes)
- Git
- Your favorite editor

After you've installed everything on your laptop, clone the repository and follow the instructions in the README.md to set up the project.


Expected audience expertise

Intermediate

Sebastiaan is a Python enthusiast who likes to think about good software design and engineering. He is a fellow of the EuroPython Society and the Python Software Foundation, works for the Pythoneers at Sopra Steria Netherlands, and frequently speaks at conferences around the world. Sebastiaan is also a board member of the EuroPython Society.

Ravi works as a (python) software developer at Ordina/Sopra Steria, an IT service provider. He also co-founded jamovi, an easy-to-use statistical spreadsheet.