The Domain Layer is the absolute center of your application. It contains the enterprise-wide business rules that would exist even if you didn't have a computer system.
This is the most important rule of the Domain project: **It must not reference ANY other project or library** (except perhaps some very basic utility libraries or common abstractions). No EF Core, no ASP.NET, no JSON serializing libraries. It should be "Pure C#". This ensures your business logic is immortal and decoupled from the fast-changing world of tech frameworks.
- **Entities:** Objects with identity and business state.
- **Value Objects:** Immutable objects defined by their values.
- **Domain Exceptions:** Specialized errors specific to your business rules.
- **Domain Services:** Stateless logic that coordinates multiple entities.
- **Repository Interfaces:** Definitions (NOT implementations) of how the domain needs to persist data.
Q: "How do I validate data in the Domain layer?"
Architect Answer: "Always favor 'Always-Valid' entities. Use your constructors and Value Objects to ensure an entity can never exist in an invalid state. For example, if an Order must have at least one item, the constructor should take an initial item. Never allow a 'public set' on your properties; use methods like ChangeName() that can enforce business rules before the change occurs."