This system uses Clean Architecture principles, ensuring business logic independence from frameworks and external services.
Dependencies point inward:
Domain ← Application ← Infrastructure ← Presentation
Core has zero framework dependencies. You can:
- Switch from NestJS to Express
- Change from TypeORM to Prisma
- Replace Redis with Memcached
Every layer tested independently:
- Domain: Pure unit tests
- Application: Mock repositories
- Infrastructure: Integration tests
- Presentation: E2E tests
Location: packages/core/src/domain/
Contains:
- Entities (User, Session)
- Value Objects (Email, Password)
- Repository Interfaces
Rules:
- No framework dependencies
- Pure TypeScript
- All business rules here
Location: packages/core/src/application/
Contains:
- Use Cases (RegisterUser, LoginUser)
- Port Interfaces
Rules:
- Orchestrates domain objects
- Depends only on domain
- Defines interfaces for infrastructure
Location: packages/nestjs-adapter/src/infrastructure/
Contains:
- TypeORM Repositories
- Security implementations
- Cache providers
Location: packages/nestjs-adapter/src/presentation/
Contains:
- HTTP Controllers
- Guards & Strategies
- DTOs
- Repository Pattern
- Dependency Injection
- Result Pattern
- Value Objects
- Domain Events
- Use Case Pattern
- Adapter Pattern