Notifications
Your project includes a multi-channel notification system that delivers messages via in-app notifications, email, and push notifications (web and mobile). Notifications are role-based and processed asynchronously via a background job queue.
Notification types
The following types are included as a starter. You can add more types to match your application's needs by extending the schemas and notification worker.
| Type | Trigger |
|---|---|
memberAdded | New member joins organization |
memberRemoved | Member is removed |
subscriptionCreated | New subscription is created |
custom | Manually sent by admin |
How it works
- An event occurs (e.g., new member added).
sendNotification()is called with the organization ID, target roles, and payload.- Notification records are created immediately in the database for matching members.
- A background job is queued to deliver email and push notifications.
- The notification worker sends emails and push notifications to all recipients (except the sender).
Delivery channels
In-app notifications
- Stored in the
Notificationtable with read/unread status. - Displayed via the bell icon in the app header with unread count.
- Users can view all notifications at
/notificationand mark them as read/unread.
Email notifications
- Queued via the email service (SendGrid or SMTP).
- Sent to all members matching the target roles (except the sender).
- Content is formatted per notification type with localized templates.
Push notifications
- Web push: Via VAPID/Web Push API (requires
PUSH_NOTIFICATIONS_ENABLED=true). - Mobile push: Via Expo Push Notifications API.
- Sent to all registered push tokens for each recipient.
- Members can enable/disable notifications via
isNotificationsEnabledon their member record.
Sending custom notifications
Admins can send custom notifications from the /notification/send page:
- Title: Short title (max 200 characters)
- Message: Notification body (max 1000 characters)
- Roles: Select which roles receive the notification
Custom notifications are delivered through all three channels (in-app, email, and push).
API endpoints
| Method | Path | Description |
|---|---|---|
GET | /api/notification | List notifications (filtered) |
GET | /api/notification/unread-count | Get unread count |
POST | /api/notification/mark-as-read | Mark notifications as read |
POST | /api/notification/mark-as-unread | Mark notifications as unread |
POST | /api/notification/send | Send custom notification |
Permissions
Notification features require the notification permission resource. The send action is typically restricted to admins.
Key files
| File | Description |
|---|---|
backend/src/features/notification/notificationService.ts | Main send function |
backend/src/features/notification/notificationWorker.ts | Background job worker |
backend/src/features/notification/notificationQueue.ts | Job queue integration |
backend/src/features/notification/notificationSchemas.ts | Zod schemas and types |
backend/src/features/notification/notificationFormat.ts | Content formatting |
backend/src/features/notification/notificationApiRoutes.ts | API routes |
frontend/src/features/notification/components/NotificationButton.tsx | Bell icon with unread count |
frontend/src/features/notification/pages/NotificationListPage.tsx | Notification list page |
frontend/src/features/notification/pages/NotificationSendPage.tsx | Send custom notification page |