Bird
Raised Fist0
HLDsystem_design~12 mins

Event sourcing in HLD - Architecture Diagram

Choose your learning style9 modes available
System Overview - Event sourcing

Event sourcing is a system design pattern where all changes to application state are stored as a sequence of events. Instead of saving only the current state, the system records every change as an event, allowing full history and easy state reconstruction.

Key requirements include reliable event storage, event replay for rebuilding state, and handling commands that generate events.

Architecture Diagram
User
  |
  v
Command Handler
  |
  v
Event Store <--> Read Model Database
  |
  v
Event Processor
  |
  v
Notification Service

Legend:
- Arrows show data flow
- Double arrow between Event Store and Read Model Database indicates event replay and state projection
Components
User
actor
Initiates commands that change system state
Command Handler
service
Validates commands and generates events
Event Store
database
Stores all events in order as the source of truth
Read Model Database
database
Stores current state projections built from events for fast queries
Event Processor
service
Processes events from the store to update read models and trigger side effects
Notification Service
service
Sends notifications or triggers external actions based on events
Request Flow - 6 Hops
UserCommand Handler
Command HandlerEvent Store
Event StoreEvent Processor
Event ProcessorRead Model Database
Event ProcessorNotification Service
UserRead Model Database
Failure Scenario
Component Fails:Event Store
Impact:New events cannot be stored, so state changes are lost and system cannot rebuild state from events
Mitigation:Use replication and backups for event store; degrade to read-only mode using existing read models until event store recovers
Architecture Quiz - 3 Questions
Test your understanding
Which component stores the complete history of all changes in the system?
AEvent Store
BRead Model Database
CCommand Handler
DNotification Service
Design Principle
Event sourcing separates the write model (event store) from the read model (projections), enabling full history tracking, easy state reconstruction, and scalable read performance by building specialized views.