spring-boot-ddd

Installation
SKILL.md

Domain Driven Design In Spring Boot

Choose aggregate boundaries, enforce invariants inside them, and make identity and value equality explicit instead of leaving them to a JPA schema. Spring Data and Hibernate make the row the default model, which is the single most common cause of an anemic domain; the countermeasure is a deliberate decision about what the aggregate guarantees, not an extra layer of annotations.

When to use

  • Deciding what belongs in one aggregate, where a transaction boundary must stop, or whether the aggregate is too large to load in one query.
  • A @Entity is mutated from a service with no rule protecting valid state, or valid state is protected only by a database constraint nobody can unit test.
  • Value equality is wrong, so two identical concepts compare unequal in a test.
  • A class has only getters and setters, with the logic in a service, or valid state is protected by scattered if statements.
  • Deciding whether logic needs a domain service, a factory, or a specification.
  • Choosing between a domain event, a Spring application event, and a broker message.
  • Two models of one concept exist because two bounded contexts each need their own.

When not to use

Installs
1
First Seen
Oct 25, 2026
Security Audits