Aggregate Root

Learn about the main aggregate in a domain layer, called an aggregate root, and how to implement it

Let us imagine that there are many aggregates in the domain. They have different functionalities, for several use cases. When it is necessary to carry out a particular use case, it will be difficult to choose the access and decide which aggregate should be executed first. Therefore, DDD extends the concept of aggregate and creates a new artifact called an aggregate root.

What is an aggregate root?

Like a normal aggregate, an aggregate root is a cluster of objects with entities, values, or even other aggregates. The main difference between them is that an aggregate root is the main aggregate, while a simple aggregate is not the main aggregate. This means that everything outside of the domain layer boundary must use business logic, through interaction with the aggregate root. The aggregate root should, in turn, orchestrate logic in other aggregates, value objects, and entities.

Get hands-on with 1400+ tech skills courses.