The aggregates the service owns are declared
The service names its aggregates, so it is clear what changes together in one transaction and what does not.
MediumChecked automatically
- Applies to:
- Services that own a data store
- Rule id:
- data.aggregates-declared
Why it matters
An aggregate is the unit that is loaded, changed and saved as a whole: an order with its lines. Naming them answers the questions a data model alone doesn't: what one transaction may touch, what an event is about, what can be split out later. Without them, transactions grow until they span half the schema.
How to apply it
- List the aggregates the service owns, each with its root entity.
- Keep them small: only what has to be consistent at the moment of the change.
- Refer to other aggregates by id, not by object reference or foreign-key join in the write path.
- Change one aggregate per transaction; reach the others through events.
- Name events after the aggregate they are about:
OrderPlaced,OrderLineRemoved.
Example
The orders service owns Order (root Order, with OrderLine and the value object Money) and Cart. Order refers to the customer by customerId; the customer is an aggregate of another service.
References
Checklists with this rule
Related agent skill: designing-service-boundaries