Spaces:
Running
Running
save
#5
by
alexshkor
- opened
😃: wazzup
🤖: ## Building a NestJS + CQRS Application – A Step‑by‑Step Guide
TL;DR – Install NestJS, add
@nestjs/cqrs, define Commands (writes), Handlers, Queries (reads), Providers, and Events. Wire everything together with theCommandBus,QueryBusandEventBus.
The example below shows a tiny “Todo” service that you can grow into a full‑blown micro‑service or a domain‑driven‑design (DDD) project.
1️⃣ What Is CQRS and Why Use It with NestJS?
| Concept | Purpose |
|---|---|
| Command | A request to change the state (write side). |
| Command Handler | Executes the business logic for a command, usually inside a transaction. |
| Query | A request to read the state (read side). |
| Query Handler / Provider | Retrieves data (often from a different model or DB). |
| Event | Something that has happened... |