forge-docs

0017. Notification Service Template Storage

Status: Accepted Date: 2026-01-23 Context: Where and how notification templates (email, SMS, push) are stored, versioned, and scaled.

Context

The Notification Service requires template storage for email, SMS, and push notifications. Templates need to:

Template Storage Options:

Note: Template engine selection is covered in ADR-0018.


Decision

Template Storage: AWS DynamoDB + S3 (Hybrid)

Primary Storage: DynamoDB

Large Assets: S3

Why DynamoDB:

Why S3 for Assets:


Rationale

Why DynamoDB (Not PostgreSQL):

  1. Scalability - Better suited for high-throughput read patterns (template lookups)
  2. Serverless - Fully managed, no connection pooling concerns
  3. Existing Infrastructure - Platform already uses DynamoDB
  4. Versioning - Natural fit for versioned templates (PK/SK pattern)
  5. Multi-Region - Easier multi-region deployment

Why Not PostgreSQL:

  1. Read-Heavy - Templates are read-heavy (lookup by templateId), DynamoDB optimized for this
  2. Simple Queries - No complex joins needed, DynamoDB sufficient
  3. Scaling - DynamoDB scales automatically, PostgreSQL requires more management

Consequences

Positive:

Negative / Tradeoffs:

Mitigations:


Implementation

DynamoDB Schema:

Table: notification-templates

GSI: channel-index

Qute Template Rendering:

// Retrieve template from DynamoDB
Template template = templateRepository.getTemplate("welcome-email-v1");

// Render with Qute
String rendered = Qute.fmt(template.getHtmlBody())
    .data("firstName", "John")
    .data("activationLink", "https://example.com/activate?token=abc123")
    .render();

Template Storage Pattern:

  1. Small Templates - Store directly in DynamoDB content.html_body
  2. Large Templates - Store in S3, reference in DynamoDB s3_reference
  3. Versioning - New version = new DynamoDB item (same template_id, different version)
  4. Activation - activation_status field indicates active version


Future Considerations

Template Versioning:

Template Management UI:

Multi-Language Support: