Domain Layer
The Heart of Your Application
What Belongs in the Domain Layer?
The domain layer contains pure business logic with no external dependencies.
domain/
├── entities/ # Core business objects
│ └── Task.js # Task with business methods
├── services/ # Domain operations
│ └── TaskDomainService.js
├── interfaces/ # Contracts (ports)
│ └── ITaskRepository.js
└── errors/ # Business exceptions
└── DomainErrors.js
Rule: If you can explain it to a non-technical stakeholder, it belongs in the domain.
- “A high priority task needs immediate attention” ✓
- “We use MongoDB with Mongoose” ✗