Atomic Innovation

Introducing event.store
Atomic’s open source solution for event-driven software

 • Joe Gambino, Jonas Svalin, and Toby Clemson


Here at Atomic, we began working with event-based systems in earnest about eight years ago, when we were helping Kroo, a nascent fintech client, effectively build a new bank from scratch. Since then, we have continued to hone our approach, working mainly in highly regulated industries, such as banking and healthcare.

These clients shared many common traits. They needed to accurately understand the history of their system, they needed reliable audit trails, and they needed to communicate across domains asynchronously. And so each project proved excellent for further perfecting solutions to the many (sometimes unexpected) complications that arise when implementing event-driven systems.

Today we are taking our best practices and making them public. event.store is our event-sourcing toolkit, a Python library to empower back-ends with foundational to advanced event-sourcing capabilities. We have been developing it internally for nearly a decade, and today it is officially open source.

Even, or especially, as we are in the midst of radical changes to how we write code with AI, we think it’s more important than ever to focus on the foundational architecture of the systems we build.

The many problems that event-sourcing solves always arise once a system is of sufficient complexity, so it’s best to think in that frame of mind from day one.

Event-sourcing made easy

Traditional relational systems eventually fall short once a system reaches a certain complexity or has simply been around for long enough. Even in unregulated industries with no explicit requirement for auditability, a system that only maintains the current state of affairs eventually leaves you wanting. A former customer has just re-subscribed. How many times have they done that? A perennial attendee has stopped buying tickets to our music festival. Have they moved? How has their mailing address changed since we first met them?

With an event-based system, answering those questions is trivial. With a relational system, you'd have to have known ahead of time that those were changes you'd care about.

The flexibility to replay history

A few years back we were helping a mental health foundation develop an educational platform. Many parts of the experience hinged on which courses the users had already explored or completed, but the curriculum was naturally in a continuous state of development. And so the way we conceptualized and even discussed users internally was also constantly evolving.

event.store intentionally separates the writing and reading of events, and reading is done through projections that can be recomputed at any time. You don’t read the raw log of events but a view of it, and views are cheap. Say the app unveils a journaling feature, and now each new course wants to know if students have written in their journal. No matter. Different services can have different views, and they can change any time.

It’s not just that plans inevitably go wrong, but that you can't and even shouldn’t try to plan for everything. event.store sets you up from the beginning to be flexible for the long term. But being able to replay history is just level one of event-sourcing. The boss level is something called bi-temporality.

Bi-temporality

There are two times associated with any event: when it happened and when found out that it happened. Those are meaningfully different, and in any commercial application with enough users, it’s likely that something else could happen in between those two times.

event.store guarantees proper sequencing

As with logging history, in a relational system you must deliberately measure this lag. But when these sorts of delays are unavoidable in the real world, why not set yourself up to record them natively?

Well, because setting yourself up from the start is complex and time consuming. Bi-temporality applies to logging events as well. The moment we reserve an ID in the database is not the same moment we write an event to that ID, and quite often another event arrives in between.

Reconciling these differences and ensuring proper sequencing can be surprisingly complex and confounding. This is often what leads teams to forgo event-sourcing until absolutely necessary, especially as we find that many engineering teams choose to roll their own event handling. But retrofitting eventing onto a non-evented system can be a nightmare. event.store guarantees proper sequencing, making it easier to be event-driven from day one.

An event-based mindset

Choosing an event-driven architecture can help ensure your platforms are flexible and scalable. But our primary argument for event.store is not about the software but about us, the developers: it gets the team thinking in an evented mindset from the start.

Fifteen years ago, create user and update user endpoints were probably sufficient. But contemporary software is so complex that a reliance on events is inevitable.

We can all recognise the signs of a codebase transitioning towards event-sourcing. A boolean deleted column becomes a timestamped deleted_at. Teams begin to rely on analytics data for more than just analytics because that’s the only place recording history. Recording data twice: once in the original users table and once in a new user_history table. This leads to clunky workflows where your systems don’t think in events but the communication between them does.

The many problems that event-sourcing solves always arise once a system is of sufficient complexity, so it’s best to think in that frame of mind from day one.

An event stream for cart-42: three items added, the mug removed, then checked out
An example of an event stream for an online shopping cart, from our interactive Introduction to Event Sourcing.

Getting started

While the benefits of event-driven architecture are obvious, the implementation often is not. Maintaining concurrency, ensuring proper sequencing, or simply deriving the current state from the log of events: this work can so frustrate teams, eating up time they’d rather spend on their own product, that they often move away from events and back to a traditional CRUD setup.

We’ve addressed those issues. Baked into event.store are our years of learning, years of testing in critical environments. This has led to a complete package. event.store can guarantee sequencing either overall or, for a performance improvement, just by category—a need that has come up quite often. We make no underlying assumptions as to your choice of storage. In fact, event.store is the only event-sourcing library we know of that doesn’t mandate a particular database, letting you build adapters for any that you like.

Please join us and contribute, especially if you work on independently maintained microservices. event.store is still in use at every one of our past clients, but we’re eager to grow the community even more. See our getting started guide, or, if you’re new to event-based architecture, our introduction to event-sourcing.