PRACTICAL SOFTWARE ARCHITECTURE
DDD, CQRS, EVENT SOURCING
@gboissinot
Grégory BOISSINOT

2021-03-04
Beyond buzzwords ?
2
GRÉGORY BOISSINOT
STARTING
3
4
OBJECTIVE : BUILDING A USEFUL DOMAIN MODEL #1
@gboissinot
5
OBJECTIVE : BUILDING A USEFUL DOMAIN MODEL #2
@gboissinot
6
OBJECTIVE : BUILDING A USEFUL DOMAIN MODEL #3
@gboissinot
7
OBJECTIVE : BUILDING A USEFUL DOMAIN MODEL #4
@gboissinot
8
OBJECTIVE : BUILDING A USEFUL DOMAIN MODEL #5
@gboissinot
9
OBJECTIVE : BUILDING A USEFUL DOMAIN MODEL #6
@gboissinot
USE CASES
10
Business intents
11
LISTING USE CASES
@gboissinot
Storytelling
12
LISTING USE CASES
@gboissinot
13
APPLYING DDD TACTICAL DESIGN PATTERNS
@gboissinot
Objects with rich behavior
14
IDENTIFY AGGREGATES
@gboissinot
Driven by use cases

Respect for invariants
Aggregate as a 

consistent unit
15
AGGREGATES COMMUNICATION
@gboissinot
Driven by use cases
Aggregate as a 

consistent unit
16
APPLYING CLEAN ARCHITECTURE
@gboissinot
Get rid of Transaction Script
17
USE CASE
@gboissinot
CQS
Command Query Separation
18
19
COMMAND VS QUERY
@gboissinot
20
COMMAND VS QUERY
@gboissinot
Commands & queries are simple POJOs
MARKED INTERFACE
MARKED INTERFACE
21
COMMAND VS QUERY
@gboissinot
22
COMMAND VS QUERY
@gboissinot
23
COMMAND VS QUERY
@gboissinot
THE ASSOCIATED COMMAND
THE AGGREGATE ROOT
THE REPOSITORY
24
COMMAND VS QUERY
@gboissinot
THE ASSOCIATED QUERY
THE REPOSITORY
QUERY HANDLER METHOD
25
USING A SHARED REPOSITORY
@gboissinot
26
SHARED REPOSITORY
@gboissinot
27
COMMAND BUS & QUERY BUS
@gboissinot
28
COMMAND BUS & QUERY BUS
@gboissinot
29
COMMAND BUS & REST CONTROLER
@gboissinot
CQRS
30
Command Query Responsibility Segregation
31
CQRS
@gboissinot
Reduce complexity with different models
32
CQRS
@gboissinot
Single source 

of truth
Replication
EVENT-DRIVEN 

SYSTEMS
Event as the building block
33
34
MODELLING WITH EVENTS
@gboissinot
35
EVENT IDENTIFICATION PROCESS
@gboissinot
36
DOMAIN EVENT
@gboissinot
37
EVENT
@gboissinot
A SMIPLE DTO
ALL INFORMATION
38
EVENT
@gboissinot
39
EVENT DISPATCHER / EVENT HANDLER
@gboissinot
40
COMMUNICATION WITH APPLICATION EVENTS
@gboissinot
41
EVENT SOURCING
Events as the source of truth
42
EVENT STORE
@gboissinot
Events as the source of truth
History of events.

The state by a replay of events.
43
EVENT STREAMING
@gboissinot
44
EVENT SOURCING
@gboissinot
Replaying all events to get the final state
45
MODEL EVENT-DRIVEN
@gboissinot
Aggregates apply events
46
EVENT STORE - EVENT SOURCING
@gboissinot
Single source 

of truth
47
CQRS & EVENT SOURCING
@gboissinot
Single source 

of truth
48
CQRS
@gboissinot
49
MANAGING SYSTEMS
Choreography & Orchestration
50
CHOREOGRAPHY
@gboissinot
No central coordinator. Simply know how to respond to events.

The participants are loosely coupled and don't have direct knowledge of each other.
51
CHOREOGRAPHY
@gboissinot
52
ORCHESTRATION
@gboissinot
53
ORCHESTRATION - PROCESS MANAGER
@gboissinot
Knows the entire composition

Coordinates all parties
1
54
ORCHESTRATION - PROCESS MANAGER
@gboissinot
2

Practical Software Architecture DDD