Domain Events Overview¶
Why This Exists¶
This document explains how domain events support communication across the Algosure Domain Model.
Owner¶
The owner is the Chief Product Officer and Enterprise Architect.
Business Value¶
Domain events allow Algosure domains to collaborate without sharing ownership. They support workflow automation, notifications, analytics, AI reasoning, auditability, and modular implementation.
Event-Driven Principle¶
A domain event records that something meaningful happened inside an owning domain.
Examples:
- OrganizationRegistered.
- ComplianceDocumentExpiring.
- OpportunityMatched.
- BidWorkspaceCreated.
- ContractMilestoneCompleted.
- LearningRecommendationCreated.
- NotificationDelivered.
- MetricSnapshotCreated.
- SubscriptionPastDue.
- AuthorizationDecisionRecorded.
- FeatureFlagUpdated.
Event Communication Model¶
sequenceDiagram
participant Source as Owning Domain
participant EventBus as Event Mesh
participant Notification
participant Analytics
participant Intelligence
participant Consumer as Other Domain
Source->>EventBus: Publish domain event
EventBus-->>Notification: Communication trigger
EventBus-->>Analytics: Reporting input
EventBus-->>Intelligence: Reasoning input
EventBus-->>Consumer: Workflow trigger
Consumer->>Consumer: Apply own rules before state change
Event Metadata Standard¶
Every cross-domain event should include:
- EventId.
- EventType.
- SourceDomain.
- AggregateId.
- AggregateType.
- OccurredAt.
- OrganizationId where applicable.
- ActorId where applicable.
- CorrelationId.
- CausationId.
- SchemaVersion.
Event Ownership Rules¶
- The source domain owns event meaning.
- Consumers own their reaction.
- Events must not expose internal implementation details.
- Events must not require consumers to mutate source state.
- Events should carry enough context to route and evaluate, not enough to duplicate entire aggregates.
Common Event Consumers¶
| Consumer | Typical use |
|---|---|
| Notification | Creates notification requests, reminders, and escalations. |
| Analytics | Creates snapshots, reporting models, trends, and insights. |
| Intelligence | Interprets events, explains changes, and supports recommendations. |
| Learning | Creates learning recommendations from gaps or operational patterns. |
| Administration | Opens support, review, or governance workflows. |
| Identity | Responds to access-related configuration and membership changes where appropriate. |
Event And Command Distinction¶
Events say what happened. Commands request something to happen.
Example:
- Event:
PaymentFailed. - Command:
RequestBillingNotification.
This distinction protects ownership because consumers do not treat every event as permission to mutate another domain's facts.
Spring Boot Modulith Alignment¶
Spring Boot Modulith supports application events and module boundary verification. Algosure should use domain events to express module collaboration and use tests to ensure modules communicate through approved APIs and events.