QA
Intermediate LevelSystem Design & Architecture

What is Event Sourcing and how does it pair with CQRS?

❓ Interview Prompt: Explain Event Sourcing, append-only event logs, CQRS (Command Query Responsibility Segregation), projections, and temporal state replay.

Event Sourcing and CQRS are architectural patterns that decouple write and read data operations:

β€’
Event Sourcing: Stores state mutations as an append-only sequence of immutable events ('OrderCreated', 'PaymentReceived', 'OrderShipped'). Current state is derived by replaying events.
β€’
CQRS: Separates the write model (Commands) from read models (Queries). Event projections update optimized read stores (Elasticsearch/Redis) asynchronously.

Code Implementation Example

markdown
CQRS + Event Sourcing Architecture:

[Write Command] ──> [Command Service] ──> (Event Store: Append Event)
                                                β”‚
                                      (Async Event Projection)
                                                β”‚
                                                β–Ό
[Read Query]    <── [Query Service]   <── [Read DB (Redis / Elastic)]
πŸ’‘CQRS and Event Sourcing architecture pipeline.
🎯 Interview Key Takeaway

Pair Event Sourcing with CQRS to maintain complete auditability and optimize read and write models independently.

#System Design#Event Sourcing#CQRS#Architecture#Intermediate
Back to all System Design & Architecture Questions→

More System Design & Architecture Interview Questions

Beginner LevelSystem Design & Architecture

Explain the CAP Theorem and PACELC Theorem with real-world database examples.

Beginner LevelSystem Design & Architecture

What is Vertical Scaling (Scale Up) vs Horizontal Scaling (Scale Out)?

Beginner LevelSystem Design & Architecture

How do Load Balancers distribute traffic (Round Robin, Least Connections, IP Hash)?