Notification Template Architecture
Summary
Templates are per-channel subject/body pairs, resolvable per tenant and versioned. Resolution prefers a tenant-specific active template over the global default and picks the highest active version. Rendering substitutes {{Variable}} placeholders, leaving unknown placeholders empty.
Resolution precedence
Template model
NotificationTemplate carries a nullable TenantId (null = global/system default), a TemplateKey (usually the source event type), a Channel, a monotonic Version, subject and body templates, an optional Locale, an IsActive flag and a description. A unique index enforces one row per (TenantId, TemplateKey, Channel, Version).
Rendering
TemplateEngine uses a compiled regex ({{ Name }}) to replace placeholders from the supplied variable dictionary. Missing variables render as empty strings so a partial payload never blocks a notification. Render also supports rendering arbitrary subject/body text, used by the template test endpoint.
Default seeding
DefaultTemplateSeeder inserts built-in global (null-tenant) templates — one per event/channel — when they are missing. Seeding is idempotent: a (null, key, channel) row that already exists is skipped. The inventory covers employee, leave, payroll, document, tenant-provisioning, expense, asset, performance, training/LMS and helpdesk keys across in-app and email channels.
Template management surface
The API exposes template list, create-next-version, in-place update and a test-render (optionally live-send) endpoint. Creating a template computes the next Version for its (tenant, key, channel).
Verified constraints
Localeexists on the model but is not used by resolution (invariant rendering only).- There is no separate
TemplateRendererservice or templating engine beyond the regex substitution. - The extracted-service template model differs from the legacy monolith template model (documented under compatibility).
Requires Confirmation
Localization strategy, template approval/versioning governance and the canonical template system across the two implementations require confirmation.
Source References
microservices/src/notification-service/Application/TemplateEngine.csmicroservices/src/notification-service/Domain/NotificationEntities.csmicroservices/src/notification-service/Seed/DefaultTemplateSeeder.csmicroservices/src/notification-service/Api/NotificationEndpoints.cs
Related Articles
See Also
Keywords
Templates, rendering, versioning, placeholders, seeding, precedence.
Revision Information
- Status: Draft
- Last reviewed: 2026-07-21
- Next review: 2026-10-21