Aggregate Root

An “Aggregate Root” is a concept of Domain Driven Design that describes the main entity (“root”) of a graph of nested objects.

Classic example: a Customer entity might be associated with multiple Orders in a shop system, and an Order references many LineItems or Products.

  • In terms of the Bounded Context of “making an order”, the Order can be the aggregate root: a PendingOrder references LineItems, which are Product references + their quantities + bulk discounts. The PendingOrder groups, or: “aggregates”, all these info.

  • In terms of the Bounded Context of “listing all previous orders”, the Customer object is the Aggregate Root with all its associated Orders and maybe even PendingOrders that await payment or represent a shopping basket.

So:

  • It’s aggregating, aka grouping or bundling, different objects/ entities;
  • It’s the root of the hierarchy (in the current context).