| license | Apache-2.0 |
| name | cqrs-event-sourcing-architect |
| description | CQRS pattern, event stores, projections, eventual consistency. Activate on: CQRS, event sourcing, event store, read model, projection, aggregate, domain event, command handler. NOT for: message broker setup (use event-driven-architecture-expert), database optimization (use data-warehouse-optimizer). |
| allowed-tools | Read,Write,Edit,Bash(npm:*,npx:*,docker:*) |
| category | Backend & Infrastructure |
| tags | ["cqrs","event-sourcing","ddd","projections","eventual-consistency"] |
| pairs-with | [{"skill":"event-driven-architecture-expert","reason":"Event sourcing depends on reliable event infrastructure"},{"skill":"distributed-transaction-manager","reason":"Saga patterns complement CQRS for cross-aggregate consistency"},{"skill":"schema-evolution-manager","reason":"Event schema evolution is critical for long-lived event stores"}] |
CQRS & Event Sourcing Architect
Design systems that separate read/write models and derive state from immutable event logs using EventStoreDB, Marten, or custom stores.
Activation Triggers
Activate on: "CQRS", "event sourcing", "event store", "read model", "projection", "aggregate", "domain event", "command handler", "EventStoreDB", "Marten"
NOT for: Message broker infrastructure → event-driven-architecture-expert | Database query optimization → data-warehouse-optimizer | API design → api-architect
Quick Start
- Model aggregates — identify consistency boundaries in your domain
- Define domain events — past-tense facts:
OrderPlaced, ItemShipped
- Implement command handlers — validate, then emit events
- Build event store — append-only log (EventStoreDB, PostgreSQL, DynamoDB)
- Create projections — materialize read models from event streams
Core Capabilities
| Domain | Technologies |
|---|
| Event Stores | EventStoreDB 24.x, Marten 7.x, custom PostgreSQL |
| Frameworks | NestJS CQRS, Axon (JVM), Eventuous, Commanded (Elixir) |
| Projections | In-memory, PostgreSQL views, Elasticsearch, Redis |
| Serialization | JSON with versioned schemas, Protobuf |
| Testing | Given-When-Then event test pattern |
Architecture Patterns
CQRS Separation
Command Side Query Side
───────────── ──────────
POST /orders GET /orders/:id
↓ ↑
Command Handler Read Model (Postgres/ES)
↓ ↑
Aggregate.apply(event) Projection Handler
↓ ↑
Event Store (append) ──────→ Event Subscription
Aggregate with Event Replay
class OrderAggregate {
private : | | = ;
: [] = [];
: [] = [];
(: ): {
(. !== ) ();
.( ({ : command., : command. }));
}
(: ): {
.(event);
..(event);
}
(: ): {
(event ) {
. = ;
. = event.;
}
}
(: []): {
agg = ();
events.( agg.(e));
agg;
}
}