Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
Event Sourcing - History in the making
Search
Benjamin Dulau
February 19, 2015
Programming
240
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Event Sourcing - History in the making
Benjamin Dulau
February 19, 2015
Other Decks in Programming
See All in Programming
Domain-Driven Transformation
hschwentner
2
2.3k
The Rails Doctrine Decade
koic
2
590
GemmaをJevのように使ってみる / Use Gemma like Jev
kishida
5
790
Optunaを作ったときにやりたかったこと、その後 (2026/10/16, Optuna Meetup #3)
iwiwi
1
440
Apple Intelligence を用いた個人情報誤送信防止、及びユーザーリクエスト体験の改善について
yukiny
0
350
APNsからLive Activityを開始する話
yumnumm
0
170
RAG の “R” を Swift で覗いてみる 〜「意味から探す」検索の仕組み〜
nao_randd
0
160
當我們開始不讀 Code - AI Agent 時代,Code Review 與 Clean Code 還剩下什麼?
jame2408
1
250
Atomic Design, Enforced: Scaling Mobile Design Systems (next.app devCon / droidCon Berlin 2026)
steliosf
PRO
0
170
IBM Bob でAI駆動開発『QC-Playbook』
ichirokano2
0
110
すこし踏み込む CancellationToken
htkym
2
1.7k
phperだってパンチカードでコーディングしたい
o0h
PRO
0
340
Featured
See All Featured
From Legacy to Launchpad: Building Startup-Ready Communities
dugsong
0
360
The Illustrated Guide to Node.js - THAT Conference 2024
reverentgeek
1
570
How to train your dragon (web standard)
notwaldorf
96
6.9k
Visualizing Your Data: Incorporating Mongo into Loggly Infrastructure
mongodb
50
10k
Building the Perfect Custom Keyboard
takai
2
910
Reflections from 52 weeks, 52 projects
jeffersonlam
356
22k
My Coaching Mixtape
mlcsv
0
360
Abbi's Birthday
coloredviolet
4
10k
Navigating the moral maze — ethical principles for Al-driven product design
skipperchong
2
630
Building Flexible Design Systems
yeseniaperezcruz
330
41k
Navigating Team Friction
lara
192
16k
4 Signs Your Business is Dying
shpigford
187
23k
Transcript
Event Sourcing History in the making
Benjamin Dulau Entrepreneur anonymation.com Co-founder thebigbrainscompany.com Web architect @benjamindulau
Event Sourcing
❝ I want a list of all members that signed
in at least four times between 1st January and 15th January 2014… and … I want to compare this to the same period range but in 2013. ❞ Business guy
ID username last_login 1 ehamill 2007-01-22 03:04:39 2 lherman 2012-04-27
10:38:28 3 darien13 2010-06-16 21:43:06 4 olind 2012-01-02 04:31:21 … … … Current data
Event Sourcing resolves this issue.
RDBMS as the center of the architecture
State A Something important happened (delta) State B Time
State A Something important happened (delta) State B Dropped Stored
Dropped Working with current state Time
Lost data could have a massive value for the business.
ID CartId SKU Qty 1 1 ABC 5 2 1
DEF 1 3 1 IJK 10 Cart Cart lines ID CustomerId 1 1 2 1 3 1 1 0..*
In life, the only way to understand the present is
to look at the past.
If we know the events of the past, we can
reconstitute the present.
Event Sourcing
State A Something important happened (delta) State B Stored Reconstituted
Reconstituted Time Working with Event Sourcing
We express what happened in the past as a series
of Domain Events
happened in the past.
CustomerWithdrewCash
A Domain Event is a Message emitted by the Domain
Model to inform the system that something relevant happened.
class CustomerWithdrewCash implements DomainEvent { public $customerId; public $accountId; public
$amount; public $date; public function __construct($customerId, $accountId, $amount, $date) { $this->customerId = $customerId; $this->accountId = $accountId; $this->amount = $amount; $this->date = $date; } }
A message has no behavior and it is easy to
serialize.
Event Store
An append-only database storing a series of events organized in
event streams.
Bob’s account stream (Domain Model) CustomerWithdrewCash CustomerDepositedMoney CustomerWithdrewCash CustomerPaidWithHisCreditCard
JSON JSON JSON JSON Bob’s account stream (Database - Event
Store)
{ payload: { customerId: "123", accountId: "456", amount: 150, date:
"2005-08-15T15:52:01+00:00" }, eventType: "CustomerWithdrewCash" }
CustomerWithdrewCash CustomerDepositedMoney CustomerWithdrewCash CustomerPaidWithHisCreditCard Replay history Bob’s account current state
balance.
Reconstituting JSON JSON JSON JSON Fetch & unserialize Domain Event
Domain Event Domain Event Domain Event Domain Model Aggregate apply one-by-one Event stream Domain events object collection
No need for an ORM
Modelling freedom
No delete What’s done is done.
A delete is explicitly expressed as a domain event. It
is part of history.
Immutability = Infinite caching
Transactional by nature
Business Intelligence
Allows to ask almost any question to the data.
Projections
Derivative of the facts
Code that goes over a stream of events and produces
a transient state of it.
Domain Events UI View Models Statistics Models Search index Models
API Read models
class LatestMemberViewGenerator implements EventHandler { private $memberDAO; public function __construct(MemberDAO
$memberDAO) { $this->memberDAO = $memberDAO; } public function whenMemberHasSignedUp(MemberHasSignedUp $event) { $this->memberDAO->addToLatestMemberList(new LatestMemberItem( $event->memberId, $event->name, $event->username, $event->email, $event->date )); } }
Any structural representation of the data.
CQRS
Command Query Responsibility Segregation
None
Summary
Working with current state always involves valuable data loss.
Events in the domain should be explicitly expressed in the
domain model and in the ubiquitous language.
Being able to replay history is a major benefit both
technically and for the business.
Immutability is a bless.
A single model doing everything can’t be right and it
won’t scale.
Questions?