Skip to main content

Event Sourcing From The Ground Up

Track:
Software Engineering & Architecture
Type:
Tutorial
Level:
intermediate
Room:
Club H
Start:
09:30 on 08 July 2024
Duration:
180 minutes

Abstract

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 an in-browser game from the ground up. 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
  • Optimistic concurrency
  • 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
  • A container runtime (preferably Docker)
  • Git
  • Your favorite editor

The speakers

Ravi Selker

Ravi Selker

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

Sebastiaan Zeeff

Sebastiaan Zeeff

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.