SPEC 021 — Notifications
1. Feature Purpose
The Notifications module handles all outbound transactional email for the Equa platform. It implements aNotifier 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 aNotifier 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
- Transport selection —
EMAIL_TRANSPORTERenv var selects transport; unset defaults to SES;nonedisables sending entirely. - Global BCC — When
GLOBAL_BCCis set, every outbound email is BCC’d to those addresses for compliance. - Template caching — Templates compiled once at startup; changes require server restart.
- No retry on failure —
sendMail()is called with no retry or dead letter queue. - SES sandbox — In sandbox mode, emails can only reach verified addresses; production requires SES production access.
- Rate limiting — Deferred to transport providers (SES/SMTP enforce their own limits).
- noEscape rendering —
handlebars.compile(template, { noEscape: true })renders all variables as raw HTML. Intentional for HTML emails; template variables must be sanitized upstream. - From address — All emails use the same sender; per-organization customization is not supported.
- 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