Skip to main content

Notification Service — Service Overview

Status: populated Owner: Platform Engineering Last updated: 2026-04-18 Companion: DOMAIN_MODEL · API_CONTRACTS · EVENT_SCHEMAS

1. Purpose

notification-service delivers transactional email and SMS notifications to users and administrators in response to platform lifecycle events. It:

  • Consumes events from multiple NATS subjects: auth.events, billing.events, operator.health, system.alerts.
  • Resolves notification preferences per account/user to respect opt-outs by category.
  • Renders templates using Handlebars + Mjml (email HTML) or plain text (fallback and SMS).
  • Delivers via SendGrid (email) and Ghasi platform (SMS, via sms-orchestrator — low-priority queue).
  • Maintains a full notification audit log for every delivery attempt.

This service has no public REST API — it is purely event-driven. A single internal endpoint allows admin-dashboard to manage notification templates; health/metrics endpoints are also exposed internally.

2. Bounded Context

User & Admin Notifications — Generic / infrastructure concern. Does not own user preferences (auth-service owns the user record); it owns per-account notification preferences.

3. Responsibilities

AreaWhat notification-service owns
Event consumptionNATS consumer on auth.events, billing.events, operator.health, system.alerts
Preference resolutionnotification_preferences table; per-account opt-out by category
Template managementnotification_templates table (id, type, channel, subject, body_html, body_text, variables_schema)
Template renderingHandlebars variable substitution; Mjml → HTML compilation; plain-text fallback
Email deliverySendGrid HTTP API
SMS deliveryGhasi platform (POST to sms-orchestrator) with low-priority metadata
Notification audit lognotification_log — every attempt, channel, status, error
Template adminInternal endpoint (no Kong route): admin-dashboard can CRUD templates

4. Non-Responsibilities

AreaOwner
User identity / email address managementauth-service
SMS routing and operator selectionsms-orchestrator + routing-engine
Billing event productiondlr-processor / billing-service
Customer-facing notification preferences UIcustomer-portal (calls auth-service + this service's internal endpoint)
Alert escalation to PagerDutySRE alerting stack (Grafana OnCall)
Marketing / bulk emailsExternal marketing tool

5. Dependencies

DependencyKindPurpose
NATS JetStreamEvent bus (consumer)auth.events, billing.events, operator.health, system.alerts
PostgreSQL (schema notif)Data storenotification_log, notification_preferences, notification_templates
SendGrid APIExternal HTTPEmail delivery
sms-orchestratorInternal HTTPSMS delivery (low-priority channel)
auth-serviceInternal HTTPResolve email address from accountId/userId
Mjml libraryIn-processEmail HTML compilation

6. High-Level Flow

7. Key Design Decisions

DecisionRationaleTrade-off
Pure event-driven; no public REST APINotifications are side-effects of platform events; no synchronous callerAdmin must trigger test notifications via admin-dashboard
Templates stored in DB, not filesystemAdmin-dashboard can update templates without a deploymentTemplate errors can affect production; mitigated by variables_schema validation and staging preview
Mjml for email HTMLIndustry-standard responsive email DSL; avoids manual table-based HTMLAdds Mjml compile step; acceptable overhead
SMS via sms-orchestrator, not direct SMPPReuses existing rate-limiting, operator routing, and audit trailExtra HTTP hop; acceptable for low-priority notifications
Per-account opt-out (not global)Platform sends transactional notifications that some roles must not suppress (e.g. security alerts)Some categories (SYSTEM_SECURITY) ignore opt-out
Handlebars variables_schema in DBValidate template at admin-save time; catch missing variables before production deliverySchema must be kept in sync with event-to-notification mappers

8. Status

Greenfield service. Gated on: NATS stream provisioning for all consumed subjects, SendGrid API key provisioned via Vault, sms-orchestrator deployment live (SMS channel). See SERVICE_READINESS.