Expand description
Domain-Driven-Design primitives shared by every pattern.
These traits are the vocabulary: an AggregateRoot is the
transactional consistency boundary, a Command requests a state
change inside one, a DomainEvent records the fact that the change
happened, an Entity is anything with a stable identity, and a
ValueObject is anything whose identity is its value. The
Repository is how callers reach an aggregate.
Traits§
- Aggregate
Root - DDD aggregate root. One per consistency boundary; every command and every event passes through one of these.
- Command
- A command targets exactly one
crate::AggregateRoot(the transactional consistency boundary). The framework needs to know which aggregate before it can route the command, so every command must surface its target id. - Domain
Event - A persisted fact. Supplies optional metadata the read side needs:
- Entity
- A domain object that is identified by its
Id, not by its attribute values. TwoEntityinstances with the sameIdrepresent the same conceptual thing even if their other fields differ. - Repository
- Send commands to an aggregate; receive the events that resulted (or the typed domain error if the command was rejected).
- Value
Object - Marker trait for value objects: domain types that are immutable, compared by value, and have no independent identity. Money, ranges, addresses, codes — anything that, if you mutated it, would no longer be the same value.