Notification Module
The Notification module provides system-wide announcements and user notification preference management. It enables administrators to broadcast messages to users with different priorities and targeting options, while allowing users to control what types of notifications they wish to receive.
Core Features
Announcements
Announcements are system-wide messages that can be displayed to users. Key characteristics:
- Priority Levels: Four priority levels (Journal, Info, Warning, Urgent) to indicate message importance
- User Targeting: Announcements can be targeted to specific user groups and extra groups
- Pinning: Important announcements can be pinned to stay at the top
- Persistence: All announcements are stored in the database for historical reference
Notification Settings
Each user has personalized notification preferences that control:
- Login Notifications: Whether to receive email notifications on login
- Marketing Communications: Opt-in/out for promotional emails
- Service Alerts: Notifications for package expiration and other service events
These settings are stored per-user and can be modified through the user-facing API.
Architecture
Services
The module exposes two gRPC services:
- NotificationService: User-facing API for viewing announcements and managing personal notification settings
- NotificationManageService: Admin-facing API for CRUD operations on announcements
Events & Hooks
The module uses an internal event system for announcement lifecycle management:
- AnnouncementCreatedEvent: Published when a new announcement is created, consumed internally for potential side effects (e.g., cache invalidation, push notifications)
- Event routing uses RabbitMQ with the
notificationexchange
Database Schema
The module uses its own notification PostgreSQL schema with two main tables:
announcement: Stores announcement data with GIN indexes on user group arrays for efficient targetingsettings: Stores per-user notification preferences, linked to user profiles via foreign key
Integration Points
With Auth Module
- Notification settings are tied to user profiles through foreign key relationships
- User group information is used for announcement targeting
With Mailer Module
While not directly coupled, the notification settings (especially send_login_email and receive_marketing_email) are designed to be consumed by the mailer module when sending emails.
Development Notes
- All APIs follow the Processor pattern (not OOP)
- The module uses RabbitMQ for internal event handling
- Announcement targeting uses PostgreSQL array types with GIN indexes for performance
- User groups are stored as integer arrays for flexible targeting