What problem does it solve?
Clean Architecture, DDD, and Hexagonal Architecture solve the problem of tightly-coupled NestJS backends that become hard to test, refactor, and evolve as business complexity grows.
Core Features & Use Cases
- Layered architecture with a strict dependency rule: Keep the Domain core independent of NestJS, TypeORM, and HTTP concerns so changes don’t ripple across the system.
- DDD modeling with entities, value objects, aggregates, and domain events: Encapsulate business rules in rich domain models and emit events when important state transitions occur.
- Ports & adapters with application use cases: Define repository/service contracts in the domain (ports) and implement infrastructure details in adapters, wiring everything via NestJS dependency injection.
- Practical NestJS/TypeScript structure: Organize src folders into domain, application, infrastructure, and adapters to make implementation consistent and discoverable.
- Testability and refactoring support: Enable fast pure unit tests for domain logic and reduce “anemic domain model” regressions during incremental refactors.
A practical example is refactoring an existing NestJS CRUD module into a layered design by moving business rules into aggregates and replacing direct ORM dependencies with repository ports and persistence adapters.
Quick Start
Use the clean-architecture skill to restructure your NestJS feature into domain entities/value objects, application use cases, and ports/adapters with dependency inversion.