Skip to main content

SPEC 021 — Notifications


1. Feature Purpose

The Notifications module handles all outbound transactional email for the Equa platform. It implements a Notifier interface (from common) that accepts a user ID and a notification object, renders HTML from Handlebars templates, and delivers via a configurable transport layer. Every critical user journey — sign-up verification, magic link login, team invitations, password resets, and support contacts — depends on this module.

2. Current State (Verified)

2.1 Transport Configuration

Transport Selection Logic (services.ts:96-113)

2.2 Template Engine

2.3 Email Templates (10)

2.4 Layout Partials (3)

2.5 Environment Variables


3. Data Model

The Notifications module does not maintain its own persistent entities. Sent emails are fire-and-forget. Related entities that trigger notifications:

EmailVerifications (from SPEC 001)

TempPasswords (from SPEC 001)

Invitations (from SPEC 012)


4. Module Interface

The module exposes a Notifier factory, not direct API endpoints: Consumer modules receive a Notifier function via dependency injection and call it with a user ID and notification object containing the template name, subject, and template arguments.

5. Frontend Components

None. All email content is rendered server-side using Handlebars templates. Users interact with notifications only through their email client.

6. Business Rules

  1. Transport selectionEMAIL_TRANSPORTER env var selects transport; unset defaults to SES; none disables sending entirely.
  2. Global BCC — When GLOBAL_BCC is set, every outbound email is BCC’d to those addresses for compliance.
  3. Template caching — Templates compiled once at startup; changes require server restart.
  4. No retry on failuresendMail() is called with no retry or dead letter queue.
  5. SES sandbox — In sandbox mode, emails can only reach verified addresses; production requires SES production access.
  6. Rate limiting — Deferred to transport providers (SES/SMTP enforce their own limits).
  7. noEscape renderinghandlebars.compile(template, { noEscape: true }) renders all variables as raw HTML. Intentional for HTML emails; template variables must be sanitized upstream.
  8. From address — All emails use the same sender; per-organization customization is not supported.
  9. No delivery tracking — The module does not track delivery status, opens, or clicks.

7. Acceptance Criteria

  • AC-1: All source files documented with exact line references
  • AC-2: Notifier interface and flow documented
  • AC-3: All 3 transport types documented (SES, SMTP, Buffer)
  • AC-4: Template system documented (loading, rendering, partials)
  • AC-5: All 10 email templates catalogued with purpose and consumers
  • AC-6: All 3 layout partials documented
  • AC-7: AWS SES configuration documented with environment variables
  • AC-8: All consumer modules identified
  • AC-9: Deployment mapping covers desktop, staging, and production

8. Risks