Skip to main content

What is an aggregate in DDD?

An Aggregate is a group of related entities and value objects that form a logical whole and are managed as a single unit.

The key parts of an aggregate:

  1. Aggregate Root: the main entity through which everything inside is accessed.
  2. Invariants: business rules that must remain true for the whole group.
  3. Boundaries: everything inside the aggregate changes only through its root.

Example: The Order aggregate includes OrderItems, but an item can only be changed through Order.add_item().

The point: an aggregate protects data integrity and simplifies managing complex business logic.

Short Answer

Interview ready
Premium

A concise answer to help you respond confidently on this topic during an interview.