Skip to content

Data contracts, read models and integration events

The Interfaces group: data contracts (payloads), read models (projections with mappings) and integration events (what a context publishes for others).

These three kinds make up the Interfaces group of the sidebar. The group was called Contracts before; its URLs and the files in Git did not change.

Data contracts

A data contract is a named payload with fields, each with a name, a description and a type: the request of a public API, the body of a message. It belongs to a bounded context or to the project.

Read models

A read model is a projection built for reading. Each of its fields has a type, a mapping (where the value comes from) and whether it is part of the key.

Integration events

An integration event is what a context publishes for others, such as OrderPlaced, with a summary and its fields. Other contexts react with event handlers; use cases, handlers and scheduled jobs that publish it tag it in their steps.

A new integration event needs a bounded context: create it in the context that publishes it. Older events without a context stay editable and show a warning (no-context) until someone sets one; the Integration events list filters them with No context. An import of an existing spec folder may still create one without a context, with the same warning.

When to use which

You needUse
Something another system sends or receivesA data contract
A view optimised for a screen or a reportA read model
A fact another context must learn aboutAn integration event

Next steps