Event Sourcing

August 31, 2023    Architecture Development Clean-Code Domain Driven Design

Event Sourcing

I’ve been learning about Event Sourcing for several years and able to work inside of a product that uses this.

In my article in Feburary 18, 2022 F# Introduction from a C# Developer , I said, “I was listening to the Gene Kim and Scott Haven conversations in episode 22 and 23 and then watching Scott Haven at DOES 2019. Forging a Functional Enterprise: How thinking Functionally Transforms Line-of-Business Applications . This “blew my mind”.” and lead me to learn more about F#, functional programming and events.

This summer at Omnitech, we had many interns and many of us took an hour a week to meet with a different intern and share what we are working on. I found myself teaching about Event Sourcing over and over, so I created a presentation to share at Omnitech for a Lunch and Learn.

Here is the Powerpoint Presentation . Be sure to check out the diagram of the flow of information for a good picture and check out the Mr. Invincible cartoon for a fun view of eventual consistency .

“Event sourcing is a software architecture pattern that involves capturing all changes to an application’s state as a sequence of events, rather than simply updating the state itself1. Each event represents a discrete change to the system and is stored in an event log, which can be used to reconstruct the system’s state at any point in time 2 . Instead of storing just the current state of the data in a domain, use an append-only store to record the full series of actions taken on that data. The store acts as the system of record and can be used to materialize the domain objects. This can simplify tasks in complex domains, by avoiding the need to synchronize the data model and the business domain, while improving performance, scalability, and responsiveness. It can also provide consistency for transactional data, and maintain full audit trails and history that can enable compensating actions.” ~ Bing Chat which is a helpful way to define it.

Our Tech Stack

  • Host – Azure PAS
  • Framework – Angular
  • Real Time Communications – SignalR Core
  • Language – Typescript
  • Framework – .Net
  • Language – C# / F#
  • Event Store – Azure CosmosDB -> The Change Feed is a huge enabler
  • Projection Store – Azure CosmosDB

Thinking in Events

It’s really nice to think of the system as a flow of events. This connects well with DDD and enables great communication among the team. It also enables recovery and more visibility when issues arise.

chain of events

Much More

My opinion is that you should learn about this pattern and deeply consider using it for any application that needs history, that is distributed across processes/regions or teams and/or a UI that needs to be really fast. There are different levels of complexity that could be employed.

There is much more to this, but there are also tons of good information out there, search for Greg Young and Event Sourcing on YouTube.

Watch the Story for Good News
I gladly accept BTC Lightning Network tips at [email protected]

Please consider using Brave and adding me to your BAT payment ledger. Then you won't have to see ads! (when I get to $100 in Google Ads for a payout, I pledge to turn off ads)

Use Brave

Also check out my Resources Page for referrals that would help me.

Swan logo
Use Swan Bitcoin to onramp with low fees and automatic daily cost averaging and get $10 in BTC when you sign up.