Domain Layer
The Domain Layer contains the core business logic. It is completely independent of infrastructure concerns.
In This Section
- Entities - Objects with identity and lifecycle
- Value Objects - Immutable, self-validating primitives
- Identifiers - Typed unique identifiers for entities
- Enums - Finite value sets with domain behavior
- Specifications - Composable business rules for querying
- Domain Events - Facts that happened in the domain
- Domain Exceptions - Business rule violation errors
- Repository Interfaces - Persistence abstractions (ports)
- Collections - Typed collections for domain objects
- DateTime Formats - Standard date/time format constants
Key Principles
Independence: The Domain Layer has no dependencies on other layers. It defines interfaces (ports) that infrastructure implements.
Immutability: Entities and Value Objects are readonly classes. State changes return new instances.
Self-Validation: Value Objects validate their data in constructors. Invalid data cannot exist.
Ubiquitous Language: Class and method names reflect business terminology.