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
Ordercan be the aggregate root: aPendingOrderreferencesLineItems, which areProductreferences + their quantities + bulk discounts. ThePendingOrdergroups, or: “aggregates”, all these info. -
In terms of the Bounded Context of “listing all previous orders”, the
Customerobject is the Aggregate Root with all its associatedOrders and maybe evenPendingOrders that await payment or represent a shopping basket.
So: