domainsevents
Domain events are facts that something meaningful has occurred within a domain model. In domain-driven design and event-driven architectures, a domain event records a state change of an aggregate or entity and is used to communicate that change to other parts of the system. A domain event is immutable once created. It carries identifying information and relevant attributes needed by consumers to react or reconstruct state, such as entity IDs, timestamps, and necessary payload.
Domain events are typically produced by aggregates after a successful operation, and may be persisted in an
Distinguish between domain events and integration events or commands. Domain events model facts within the domain;
Best practices: keep events small and purpose-focused, version payloads, avoid leaking internals, provide stable names, include
Example: An Order aggregate publishes an OrderPlaced domain event when an order is created, containing orderId,