# Intent.Modelers.Domain.Events

A **Domain Event** is a record of something that happened in the domain that other parts of the system care about — an order was placed, a payment was captured, a customer changed address. Raising one lets the entity that owns the change stay unaware of everything that has to react to it.

The `Intent.Modelers.Domain.Events` module adds Domain Events to **Intent Architect**'s Domain designer, and Domain Event Handlers to the Services designer. It is designer metadata only; the code is generated by the modules that consume these elements (for example Intent.Domain.Events and the eventing modules).

## Modeling a Domain Event

In the **Domain Designer**, right-click a Package or Folder and select **`New Domain Event`**. A Domain Event holds `Property` elements describing what happened — right-click it and select **`Add Property`**.

Domain Events support a few relationships:

| Option | What it does |
| --- | --- |
| **`New Inheritance`** | Derives the event from another Domain Event, so shared properties are declared once. |
| **`Publish Domain Event`** | On an entity, declares that it raises this event. |
| **`Map to Entity`** / **`Map Domain Event`** | Maps the event's properties to the entity the event originates from, so the generated code can populate it. |

An origin association that has not been mapped is drawn in grey on the diagram, so an unfinished mapping is visible without opening it.

## Handling a Domain Event

Handlers are modelled in the **Services Designer**, on a Domain Interactions diagram.

1. Right-click a Package or Folder and select **`New Domain Event Handler`**.
2. Right-click the handler and select **`Handle Domain Event`** to point it at the Domain Event it reacts to.

A handler can handle more than one event. Each handled event is listed on the handler's card.

## Diagram styling

Domain Events and Domain Event Handlers are drawn as cards matching the rest of the Domain designer — Domain Events in rose, handlers in sea green — and the association lines between them share the designer's colour and dash vocabulary. The styling system itself is documented in `Intent.Modelers.Domain`'s `CONTEXT.md`.
