Scalable Software and Systems · Schema
Domain Event
Schema for a domain event in an event-sourced or event-driven system following CloudEvents conventions.
API FirstArchitecture PatternsCQRSDistributed SystemsEnterpriseEvent DrivenMicroservicesScalable ArchitectureSoftware EngineeringSystems Design
Properties
| Name | Type | Description |
|---|---|---|
| specversion | string | CloudEvents specification version. |
| type | string | Event type in reverse DNS notation. |
| source | string | Identifies the event producer (bounded context or service). |
| id | string | Unique identifier for this event occurrence (UUID recommended). |
| time | string | Timestamp when the event occurred (RFC 3339). |
| subject | string | Subject/entity identifier this event relates to (e.g., order ID). |
| datacontenttype | string | Content type of the data field. |
| dataschema | string | URI of the schema the data attribute conforms to. |
| data | object | Event payload. Schema depends on event type. |
| correlationId | string | Correlation ID for tracing requests across service boundaries. |
| causationId | string | ID of the command or event that caused this event. |
| aggregateId | string | Identifier of the domain aggregate this event belongs to. |
| aggregateType | string | Type of the domain aggregate (e.g., Order, Customer, Payment). |
| aggregateVersion | integer | Optimistic concurrency version of the aggregate after this event. |
| metadata | object | Additional metadata (user ID, tenant ID, trace context, etc.). |
JSON Schema
{
"$schema": "http://json-schema.org/draft-07/schema#",
"$id": "https://api-evangelist.com/schemas/scalable-software-and-systems/domain-event",
"title": "Domain Event",
"description": "Schema for a domain event in an event-sourced or event-driven system following CloudEvents conventions.",
"type": "object",
"required": ["specversion", "type", "source", "id", "time"],
"properties": {
"specversion": {
"type": "string",
"description": "CloudEvents specification version.",
"enum": ["1.0"],
"example": "1.0"
},
"type": {
"type": "string",
"description": "Event type in reverse DNS notation.",
"example": "com.example.order.placed"
},
"source": {
"type": "string",
"format": "uri-reference",
"description": "Identifies the event producer (bounded context or service).",
"example": "/orders-service"
},
"id": {
"type": "string",
"description": "Unique identifier for this event occurrence (UUID recommended).",
"example": "b2c3d4e5-f6a7-8901-bcde-f01234567890"
},
"time": {
"type": "string",
"format": "date-time",
"description": "Timestamp when the event occurred (RFC 3339)."
},
"subject": {
"type": "string",
"description": "Subject/entity identifier this event relates to (e.g., order ID).",
"example": "order-12345"
},
"datacontenttype": {
"type": "string",
"description": "Content type of the data field.",
"default": "application/json",
"example": "application/json"
},
"dataschema": {
"type": "string",
"format": "uri",
"description": "URI of the schema the data attribute conforms to."
},
"data": {
"type": "object",
"description": "Event payload. Schema depends on event type.",
"additionalProperties": true
},
"correlationId": {
"type": "string",
"description": "Correlation ID for tracing requests across service boundaries."
},
"causationId": {
"type": "string",
"description": "ID of the command or event that caused this event."
},
"aggregateId": {
"type": "string",
"description": "Identifier of the domain aggregate this event belongs to."
},
"aggregateType": {
"type": "string",
"description": "Type of the domain aggregate (e.g., Order, Customer, Payment)."
},
"aggregateVersion": {
"type": "integer",
"minimum": 0,
"description": "Optimistic concurrency version of the aggregate after this event."
},
"metadata": {
"type": "object",
"description": "Additional metadata (user ID, tenant ID, trace context, etc.).",
"properties": {
"userId": { "type": "string" },
"tenantId": { "type": "string" },
"traceId": { "type": "string" },
"spanId": { "type": "string" }
},
"additionalProperties": true
}
}
}