Notifications
Genie has a store-and-forward notification system: callers queue a notification, background worker services pick it up and deliver it over the appropriate channel, and in-app messages arrive in real time over SignalR (with a browser push fallback for offline users).
The pipeline
Section titled “The pipeline”┌─────────────┐ ┌───────────────────┐ ┌─────────────────┐ ┌────────────────────┐│ queue │ │ NotificationStore │ │ worker service │ │ channel delivery ││ API/service │ ─▶ │ persisted in DB │ ─▶ │ polls + retries │ ─▶ │ App·Email·SMS·push │└─────────────┘ └───────────────────┘ └─────────────────┘ └────────────────────┘Every notification is persisted first, then delivered by a worker on its next cycle. Delivery is retried (up to a max attempt count) and marked delivered on success, so nothing is lost if a channel is briefly unavailable.
Channels & workers
Section titled “Channels & workers”Under Features/Notifications/Workers/, each channel has a MonitoredBackgroundService that drains the
store in batches:
| Worker | Channel | Status |
|---|---|---|
AppNotificationWorkerService |
In-app (SignalR) + browser push | Implemented |
EmailNotificationWorkerService |
Implemented — SMTP delivery (MailKit), configured via SmtpSettings |
|
SmsNotificationWorkerService |
SMS | Batching/retry wired; the provider send is a stub (Twilio/Vonage integration pending) |
The app worker delivers each in-app notification by pushing a ReceiveNotification event to the
recipient over SignalR and sending a Web Push message to every registered browser subscription;
delivery counts as successful if either path works. Push uses VAPID keys from configuration
(Genie:Notifications:Vapid:PublicKey / PrivateKey / Subject); when a subscription returns 410 Gone or
404, it is marked inactive automatically.
No double sends
Section titled “No double sends”Each worker claims its batch in one atomic update (ClaimedBy / ClaimedUntil on
NotificationStore) and sends only the rows it won. A new active worker taking over during failover, or
several workers running in parallel, therefore never sends the same notification twice. A worker that
loses the worker lease mid-batch stops and hands the rest back. A worker that crashes leaves its claim,
and the rows are retried once Genie:Notifications:ClaimSeconds (default 300) passes. See
configuration.
Retries, giving up, and retention
Section titled “Retries, giving up, and retention”A row is pending while it is neither delivered nor given up. When an attempt fails, the worker
pushes the row’s ScheduledAt back by Genie:Notifications:RetryDelaySeconds (default 30), doubling on
each further failure up to MaxRetryDelaySeconds (default 3600). A failing destination therefore
doesn’t hold up new notifications. When the channel’s last allowed attempt fails, the row gets a
GivenUpAt time and is never picked up again.
A background NotificationRetentionWorkerService runs hourly and deletes finished rows older than
Genie:Notifications:RetentionDays (default 90; 0 keeps everything). Finished means:
- delivered (an in-app notification only once it has been read, so an unread inbox item is never removed), or
- given up.
Rows an incoming mail points at are kept. It runs on whichever process runs the delivery workers.
Indexes
Section titled “Indexes”NotificationStore carries only the primary key and two filtered indexes, one per real query:
| Index | Columns | Filter | Serves |
|---|---|---|---|
IX_NotificationStore_Pending |
Type, ScheduledAt, ClaimedUntil, DeliveryAttempts |
not delivered, not given up, not deleted | the workers’ claim |
IX_NotificationStore_Inbox |
To, Read, DeliveredTime |
Type = 'App', delivered, not deleted |
the user’s unread/read lists, mark-all-read |
The pending index holds only rows still waiting to go out, so a worker’s poll stays a seek into a near-empty index however much history the table holds. Filters are authored in SQL Server syntax and rewritten automatically on PostgreSQL.
Real-time delivery (SignalR)
Section titled “Real-time delivery (SignalR)”The GenieNotificationHub (mapped via MapGenieHubs()) delivers per-user pushes. It requires
authentication so the hub can resolve UserIdentifier — Clients.User(userId) only reaches a
connection whose identity matches, so an anonymous connection silently drops per-user messages. The UI’s
SignalR hook subscribes to ReceiveNotification: it updates the notification bell live and pops a toast
with the subject. The UI never polls; it re-reads the lists on load, on each push, after a reconnect,
and after mark-read.
Users who allow it also get browser (OS) notifications through Web Push, even with no Genie tab open. This needs VAPID keys on the API and the package’s service worker served by the host. See frontend configuration.
With several processes, the worker that sends the push is usually not the process the browser is
connected to. The Redis backplane (Genie:SignalR:Backplane, on by default when ConnectionStrings:Redis
is set) relays it. Without the backplane the push is lost, but the notification still shows when the
bell next loads. See configuration.
The current user’s own notifications — /api/v1/notification
Section titled “The current user’s own notifications — /api/v1/notification”| Method | Route | Purpose |
|---|---|---|
GET |
/unread?limit= |
list unread notifications |
GET |
/read?limit= |
list read notifications |
POST |
/{id}/read |
mark one as read (recipient only) |
POST |
/mark-all-read |
mark all unread as read |
Sending notifications (external integration) — /api/v1/notifications
Section titled “Sending notifications (external integration) — /api/v1/notifications”A JWT-bearer, role-gated surface (Authorize(Roles = "NotifUser")) for external callers to queue a
notification. Each returns a NotificationResponse with the new notification id.
| Method | Route | Body |
|---|---|---|
POST |
/app |
{ UserName, Subject, Body, ScheduledAt? } |
POST |
/email |
{ Email, Subject, Body, CC?, BCC?, ScheduledAt? } |
POST |
/sms |
{ PhoneNumber, Subject, Body, ScheduledAt? } |
POST |
/whatsapp |
{ PhoneNumber, Subject, Body, ScheduledAt? } |
ScheduledAt lets a caller defer delivery; the worker only picks up notifications whose scheduled time
has passed.
Browser push subscriptions — /api/v1/push-subscription
Section titled “Browser push subscriptions — /api/v1/push-subscription”| Method | Route | Purpose |
|---|---|---|
GET |
/vapid-public-key |
the VAPID public key the browser needs to subscribe |
POST |
/register |
register a PushSubscription (endpoint + keys.p256dh/auth) |
POST |
/unregister |
remove a subscription by endpoint |
GET |
/my-subscriptions |
list the current user’s active subscriptions |
Monitoring
Section titled “Monitoring”The notification workers are MonitoredBackgroundServices, so they appear in the hosted-services
dashboard with live metrics and pause/resume controls — see
Background jobs & hosted services.
Copyright © 2026 Orbyn Technologies. All rights reserved.