Architecture Map
Interactive visual architecture and dependency graph of all @cqrs-ddd packages, pipeline behaviors, domain event flow, and the reference API application.
Architectural Overview
Section titled “Architectural Overview”1. CQRS & Pipeline Orchestration
Section titled “1. CQRS & Pipeline Orchestration”@cqrs-ddd/cqrs: Builds lightweightCommandBus,QueryBus, andEventBusviacreateCqrs()without framework DI containers.@cqrs-ddd/pipeline: Encapsulates cross-cutting execution behaviors (LoggingBehavior,CacheBehavior,CaslBehavior, etc.) around domain handlers.- Contract-Based Request Kinds: Request routing uses
Symbol.for('@cqrs-ddd/request-kind')to avoid direct coupling between pipeline and domain layers.
2. Domain Events & Async Background Jobs
Section titled “2. Domain Events & Async Background Jobs”- Buffered Domain Events: Aggregates buffer domain events (
UserCreatedEvent,UserUpdatedEvent,RoleCreatedEvent, etc.) during state mutations. - Automatic Event Dispatch:
CommandBaseHandlerautomatically publishes buffered events throughEventBusafter durable persistence succeeds. - Context-Preserving Queues:
BullMqUserEventDispatcherpackages messages withwithJobContext(), preserving caller tenant, principal, and correlation IDs across Redis queues. - Isolated Processors: Background job workers (
SendWelcomeEmailProcessor,BatchUpdateUsersProcessor) execute decorated with@InJobContext, restoring the full execution context without leaking between jobs.
3. Pure Domain & Persistence
Section titled “3. Pure Domain & Persistence”@cqrs-ddd/core: Framework-neutral DDD primitives (AggregateRoot,Entity,ValueObject,DomainEvent, domain errors) with zero dependencies.@cqrs-ddd/mikro-orm: Implements write-side repository abstractions with version-conditioned optimistic concurrency (optimisticUpdate) and anti-resurrection mutation barriers.- Two-Layer Caching: Repository entity snapshot caching (
@FromCache,@Cache) is kept separate from composed pipeline response caching (CacheBehavior).
4. Application & Reference Implementation
Section titled “4. Application & Reference Implementation”api/: Reference REST application demonstrating dual Express and Fastify adapters, multi-tenant isolation, BullMQ background workers, and session management.