A practical introduction
to Event Sourcing
and Command Query
Responsibility
Segregation
Robert Lemke
CEO Flownative

Project Founder Neos



robert@flownative.com

@robertlemke
CRUD
Create, Read, Update, Delete
CQRS
Command Query

Responsibility Segragation
Event Sourcing
Store all changes to the system,
rather than it’s current state.
Event Sourcing
Store all changes to the system,
rather than it’s current state.
Mathias Verraes (http://verraes.net)
Motivation for Event Sourcing
Expressivity
Distributed /

event-driven architecture
Audit log*
Debugging
New representations / analysis
Easy storage
Commands
Do that! (imperative)
Command Handlers
will handle commands.
They don’t return a
result, only accept or
reject commands.
$commandHandler-
>handle($command);
Events
Domain Events:
something interesting
in the domain /
business
(infrastructure)
events: user clicked
button, log has been
rotated, file upload
failed
Events are something
which happened in the
past
You can’t change the
past, so events are
immutable
Event Sourcing does not
need a framework.

But Neos.EventSourcing
helps you implementing
Event Sourcing with Flow.
The sample domain
addBookToAssortment
addBookToCatalog
addBookToListOfProductsPeopleCanBuy ;-)
Live Demo 😱
Some special cases
Deleting a book
Media / assets /
binary data
Flow accounts, …
Versioning events
Should you try it?
robert@flownative.com
www.flownative.com
@robertlemke
your thoughts?

A practical introduction to Event Sourcing and CQRS