Define Domain Elements
DDD CQRS ES
This section covers how to model your business concepts as domain elements in Protean -- aggregates, entities, value objects, events, and the relationships between them.
For the conceptual foundations behind these patterns, see Building Blocks.
What's in This Section
Aggregates
Define your root entities -- the coarse-grained building blocks that encapsulate business logic, enforce invariants, and define transaction boundaries. Start here when modeling a new domain concept.
Entities
Add child objects with unique identity inside an aggregate. Entities are always accessed through their parent aggregate and share its lifecycle.
Value Objects
Model immutable descriptive concepts like Money, Email, or Address. Value objects are defined by their attributes, not identity, and are embedded within aggregates or entities.
Relationships
Connect domain elements with HasOne, HasMany, and Reference fields.
Express one-to-one, one-to-many, and cross-aggregate references.
Events
Define domain events -- immutable records of state changes that enable decoupled communication between different parts of your system. Events can be processed synchronously or asynchronously.
Related
- Identity -- Configure identity strategies, types, and custom generators.
- Fields Reference -- All field types, arguments, and definition styles.
- Choosing Element Types -- Guidance on when to use an aggregate vs. entity vs. value object.