Skip to main content

Domain: notifications

Curated entry point for the notifications bounded context.

Owner

Founder + agents (Phase 1).

Mission

Owns delivering messages to traders and admins: transactional email rendering and delivery via Resend, in-app notifications, breach alerts, and webhook fanout to Centrifugo channels for real-time push (per Q-E11). Boundary: notifications delivers messages; the content templates and trigger rules are owned here, but the signals that drive notifications (breaches, payouts, fills, etc.) come from other domains via Kafka events.

Code paths

  • Application code: apps/api/src/modules/notifications/
  • Domain logic (pure): packages/domain/notifications/ (template rendering, trigger evaluation)
  • Contracts: packages/contracts/events/notifications.ts
  • External clients: packages/clients/resend/
  • Database schemas owned: notifications (NotificationTemplate, NotificationDelivery, NotificationPreference, WebhookFanout)
  • Email templates: React Email components per Q-E4 frontend baseline

PRD chapters that touch this domain

TDD chapters

(Empty - will populate.)

ADRs that affected this domain

Service interfaces this domain exposes

export interface NotificationsService {
// sendTransactional(template, to, data): Promise<DeliveryId>
// publishRealtime(channel: string, payload: object): Promise<void>
// updatePreferences(userId, preferences): Promise<NotificationPreference>
// listInAppForUser(userId): Promise<InAppNotification[]>
// markRead(notificationId, userId): Promise<void>
// (full surface defined during notifications TDD)
}

Events this domain produces / consumes

DirectionTopicTriggered by
producesnotifications.email.sentResend confirmed delivery
producesnotifications.email.bouncedBounce / complaint
producesnotifications.realtime.publishedConfirmation that a Centrifugo publish occurred
consumesrisk.evaluation.breach_detectedTriggers breach alert email + Centrifugo push
consumesaccounts.account.state_changedState-transition emails (e.g., "you passed evaluation")
consumespayouts.transfer.completedPayout confirmation email
consumesbilling.payment.completedReceipt email
consumesidentity.user.signed_inSuspicious-signin email if flagged

External integrations

  • Resend - transactional email rendering + delivery
  • Centrifugo - WebSocket channel publishes (per Q-E11)
  • Discord (V1+) - community webhook fanout
  • Intercom (V1+) - in-app messaging

Runbooks for this domain

(Empty - will populate. Expected high-priority: email delivery rate drop, Centrifugo publish failure burst.)

On-call

To be filled in Section 17.6.

Cross-domain dependencies

  • This domain consumes events from: every other domain (it is a leaf consumer).
  • This domain emits events consumed by: audit (every notification is logged), admin (notification delivery dashboards).
  • No synchronous outbound dependencies.