TorbatYar/docs/ai-framework/event-template.md
Mortezakoohjani e41ecfad4c Sync platform docs, infra, and module services with Accounting integration.
Include Loyalty/Communication/Sports Center backends and registry updates alongside production nginx and compose wiring.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-07-25 22:35:23 +03:30

2.2 KiB
Raw Blame History

Event Template

Standards for domain and integration events.

Domain Events

  • Emitted when an aggregate state change may matter inside or outside the service.
  • Written via outbox in the same DB transaction as the write (ADR-006).
  • Consumers treat events as facts; producers do not assume synchronous handling.

Integration Events

  • Cross-service contracts for interoperability (same envelope).
  • Stable payload fields; evolve additively when possible.
  • Consumers must be idempotent (inbox / event_id).

Naming

Preferred forms (follow the owning services established style):

Style Example When
{aggregate}.{past_tense} tenant.created Core / generic
{service}.{aggregate}.{past_tense} crm.lead.created, loyalty.member.enrolled Namespaced business services

Use past tense. Do not use generic names like update without the aggregate.

Versioning

  1. Envelope fields remain stable (event-driven-architecture.md).
  2. Payload additive changes preferred.
  3. Breaking payload changes: new event type or explicit payload_version documented in catalog and handover.
  4. Never reuse an event_type string for a different meaning.

Payload Rules

Envelope (canonical):

{
  "event_id": "uuid",
  "event_type": "service.aggregate.past_tense",
  "aggregate_type": "aggregate",
  "aggregate_id": "uuid",
  "tenant_id": "uuid|null",
  "source_service": "service-name",
  "payload": {},
  "occurred_at": "ISO-8601"
}

Payload must:

  • Include enough IDs for consumers to fetch details via API if needed
  • Avoid embedding secrets or large binaries
  • Prefer refs over duplicated foreign aggregates
  • Remain JSON-serializable

Catalog & Registration

  1. List new events in the phase doc and event-catalog.md.
  2. Update module-registry.md Events fields.
  3. Update service-manifest.yaml event list.