DD

Domain-Driven Design

Used in 293 javascript projects (avg ★54)

Details

Language / Topic
javascriptJavaScript
Category
Architecture

Rules

balanced
- Organize code by bounded contexts based on business domains, not technical layers.
- Use rich domain models with behavior (methods) — not anemic data bags with external service logic.
- Model Aggregates as classes or factory functions — validate invariants in constructor/factory, emit domain events for side effects.
- Define aggregates with invariant enforcement. Only the aggregate root should be accessible externally.
- Use value objects for concepts defined by their attributes (Money, Email, DateRange), not identity.
- Use domain events to communicate between bounded contexts without tight coupling.
- Keep the domain layer pure: no framework imports, no I/O, no side effects.