Notification Runtime Composition
Summary
The service is a Microsoft.NET.Sdk.Web project targeting net8.0 with nullable and implicit usings enabled. Program.cs builds a WebApplication, registers observability, messaging, options, the DbContext, application services, channel senders and the event consumer, then applies migrations, seeds default templates and maps the endpoints.
Startup sequence
Dependency-injection registrations
Verified registrations in Program.cs:
RetryPolicy— singleton.IEventNotificationResolver→EventNotificationResolver— singleton.ITemplateEngine→TemplateEngine— scoped.IPreferenceEvaluator→PreferenceEvaluator— scoped.INotificationDispatcher→NotificationDispatcher— scoped.IChannelSender→InAppSender,SmsSender,WhatsAppSender— singletons; the email sender is chosen at startup by theNotification:Email:Providervalue (smtp→SmtpEmailSender,noop→NoOpEmailSender, otherwiseConsoleEmailSender).IChannelSenderRegistry→ChannelSenderRegistry— singleton.NotificationEventConsumer— hostedBackgroundService.NotificationDbContext— Npgsql, using theNotificationDbconnection string.- Swagger generation and ASP.NET Core health checks.
Configuration binding
NotificationOptions binds the Notification section: RabbitMQ queue/dead-letter names and prefetch, Retry (max attempts, base delay, backoff factor), StaleAfterHours, an optional per-event EventChannels override map, Email/Sms/WhatsApp provider settings and SeedDefaultTemplates. Observability and RabbitMq sections are bound by shared-kernel helpers.
Hosting endpoints
The application maps /health (health checks), a root service-info endpoint via MapHrSuitServiceInfo, Swagger UI, and the notification endpoints via MapNotificationEndpoints. The http launch profile listens on port 5074.
Startup side effects
Unless the SKIP_MIGRATIONS environment variable equals true, the service applies EF Core migrations on startup and, when SeedDefaultTemplates is enabled, seeds the built-in global templates idempotently.
Requires Confirmation
Production hosting, container image, replica count and the environment values for provider selection and broker connectivity require confirmation.
Source References
microservices/src/notification-service/Program.csmicroservices/src/notification-service/Application/NotificationOptions.csmicroservices/src/notification-service/Properties/launchSettings.jsonmicroservices/src/notification-service/notification-service.csproj
Related Articles
See Also
Keywords
Runtime composition, dependency injection, hosted service, startup, configuration.
Revision Information
- Status: Draft
- Last reviewed: 2026-07-21
- Next review: 2026-10-21