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.

TypeTrigger
memberAddedNew member joins organization
memberRemovedMember is removed
subscriptionCreatedNew subscription is created
customManually sent by admin

How it works

  1. An event occurs (e.g., new member added).
  2. sendNotification() is called with the organization ID, target roles, and payload.
  3. Notification records are created immediately in the database for matching members.
  4. A background job is queued to deliver email and push notifications.
  5. The notification worker sends emails and push notifications to all recipients (except the sender).

Delivery channels

In-app notifications

  • Stored in the Notification table with read/unread status.
  • Displayed via the bell icon in the app header with unread count.
  • Users can view all notifications at /notification and 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 isNotificationsEnabled on 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

MethodPathDescription
GET/api/notificationList notifications (filtered)
GET/api/notification/unread-countGet unread count
POST/api/notification/mark-as-readMark notifications as read
POST/api/notification/mark-as-unreadMark notifications as unread
POST/api/notification/sendSend custom notification

Permissions

Notification features require the notification permission resource. The send action is typically restricted to admins.

Key files

FileDescription
backend/src/features/notification/notificationService.tsMain send function
backend/src/features/notification/notificationWorker.tsBackground job worker
backend/src/features/notification/notificationQueue.tsJob queue integration
backend/src/features/notification/notificationSchemas.tsZod schemas and types
backend/src/features/notification/notificationFormat.tsContent formatting
backend/src/features/notification/notificationApiRoutes.tsAPI routes
frontend/src/features/notification/components/NotificationButton.tsxBell icon with unread count
frontend/src/features/notification/pages/NotificationListPage.tsxNotification list page
frontend/src/features/notification/pages/NotificationSendPage.tsxSend custom notification page