When business rules are scattered across services, controllers, and persistence callbacks, they are difficult to protect from infrastructure changes. The domain layer gathers the rules and invariants that must survive independently of frameworks and deployment choices. section 2.4.1 section 3.1
Keep framework annotations, persistence mechanisms, controllers, messaging, and security infrastructure outside the domain. The inner layer contains pure Java business objects and imports no framework. section 3.1 section 3.10
Place business behavior and concepts in the domain, not merely data:
- Entities maintain identity and enforce rules on valid state changes; value objects express concepts through their attributes. section 3.1
- Aggregates and domain services also belong in the core; services handle business logic spanning multiple entities. section 3.1 section 3.10
- Create domain objects through factories that validate invariants, so invalid objects cannot be instantiated. section 2.4.1 section 3.10
Extracting Article rules
If deleting Spring Boot would break a class, it does not belong in the domain. Article rules that survived that test became the seed of a framework-free domain layer. section 2.4.1
Figure 3.2 The domain layer inside the hexagon. Shows entities, value objects, aggregates, and domain services inside the innermost ring. Ports sit at the ring boundary. Adapters and frameworks are outside. Arrows emphasize that nothing from outside points inward into the domain.
The hexagon diagram locates the domain inside the boundary, with ports at its edge and adapters and frameworks outside. section 3.1




