Service Design Specification

Notification Service Documentation Version: 1.0.3


Scope

This document provides a comprehensive architectural overview of the Notification Service, which is responsible for sending multi-channel notifications via Email, SMS, and Push. The service supports both REST and gRPC interfaces and utilizes an event-driven architecture through Kafka.

This document is intended for:

For detailed REST interface, refer to the [REST API Guide]. For Kafka-based publishing and consumption flows, refer to the [Event API Guide].


Service Settings


Interfaces Overview

REST API

Exposes endpoints to:

For full list and parameters, refer to the REST API Guide.

gRPC API

Defined via notification.sender.proto:

Kafka Events

For event structure and consumption logic, refer to the Event API Guide.


Provider Architecture

Each channel (SMS, Email, Push) is pluggable using a provider pattern. Providers can be toggled via env vars.

Email Providers

Push Providers

SMS Providers

Each provider implements a common send(payload) method and logs delivery result.


Storage Mode

Notifications can be optionally stored in the PostgreSQL database if STORED_NOTICE=true and notificationBody.isStored=true.

Stored data includes:


Aggregation & Templating

Notification body and title can be:

Template rendering supports interpolation with metadata. Separate template files exist for:


Middleware

Error Handling

Validation

Utilities


Lifecycle & Boot Process

  1. Loads configuration from .env using dotenv

  2. Initializes:

    • Express HTTP Server
    • gRPC Server (if GRPC_ACTIVE=true)
    • Kafka listeners
    • Redis connection
    • PostgreSQL connection
  3. Injects OpenAPI/Swagger via api-face

  4. Registers REST routes and middleware

  5. Launches any scheduled cron jobs

  6. Handles graceful shutdown via SIGINT


Environment Variables

Variable Description
HTTP_PORT Express HTTP port (default: 3000)
GRPC_PORT gRPC server port (default: 50051)
SERVICE_URL Used to build auth redirect paths
SERVICE_SHORT_NAME Used for auth hostname substitution
PG_USER, PG_PASS PostgreSQL credentials
REDIS_HOST Redis connection string
STORED_NOTICE Whether to persist notifications
SENDGRID_API_KEY SendGrid API token
SMTP_USER/PASS/PORT SMTP credentials
TWILIO_*, NETGSM_* SMS provider credentials
ONESIGNAL_API_KEY OneSignal Push key

Testing Strategy

Unit Tests

Integration Tests

End-to-End (Optional)


Observability & Logging