@spurtcommerce/broadcast-notification) adds scheduled and real-time broadcast notifications to SpurtCommerce Community and Enterprise editions.
It allows vendors and administrators to create and manage broadcast notifications, schedule publication, and deliver notification updates to buyers. Buyers can retrieve their notifications and manage their read, clicked, and deleted states.
The package integrates with the SpurtCommerce application through its TypeORM, Express, and plugin loaders. It uses BullMQ for background processing and Socket.IO for real-time delivery.
Key Features
- Broadcast management: Create, list, view, update, and delete broadcast notifications for vendors and administrators.
- Scheduled publishing: Queue notifications for publication at a configured future date and time, with delayed job support.
- Background processing: Use a BullMQ queue and worker to process scheduled broadcasts outside the request-response cycle.
- Multi-tenant processing: Process notification jobs in a multi-tenant application while retaining tenant context.
- Real-time buyer alerts: Send Socket.IO updates to buyer-specific rooms when a broadcast is published.
- Buyer notification centre: List notifications, retrieve the unclicked notification count, mark notifications as read or clicked, and delete notifications.
- Delivery tracking: Maintain per-buyer notification state, including read status, click status, and soft deletion.
- Automatic integration: The host application’s loaders register the add-on’s entities, migrations, controllers, worker, and plugin module.
- Safe package removal: The host application is designed to continue running when the add-on is uninstalled.
Requirements
- A compatible SpurtCommerce Community or Enterprise application.
- A SpurtCommerce host application with the add-on loader integration expected by this package.
- A reachable Redis-compatible datastore for the BullMQ queue backend used by the integration.
- A configured Socket.IO server/instance in the host application’s runtime for real-time delivery.
Queue infrastructure: BullMQ needs a configured datastore connection for queues and workers. The package’s Redis connection settings must point to a reachable queue datastore. Use the connection configuration expected by the installed package; this guide does not assume environment-variable names that are not part of the package reference.
Installation
Run the following command from the root directory of your SpurtCommerce project:How the Add-on Works
The broadcast notification module combines persistent notification records, background job processing, and real-time buyer delivery. A typical broadcast lifecycle is:- Create a broadcast: A vendor or administrator creates a notification with its content and optional image, announcement link, status, and scheduled publish date.
- Schedule processing: When publication is scheduled for a later time, the notification is queued with a delay.
- Process the job: The
NotificationWorkerconsumes queued jobs and processes the broadcast. The worker supports multi-tenant processing and error resilience. - Deliver to buyers: When the broadcast is published, the module sends real-time Socket.IO alerts to the relevant buyer rooms.
- Track buyer activity: Per-buyer records track whether a notification has been read, clicked, or soft-deleted.
- Expose buyer notifications: Buyers use the notification-list APIs to retrieve notifications and update their notification state.
API Overview
The add-on exposes two API groups.Broadcast Notification API
Base route:/api/broadcast-notification/*
This API group is used by vendors and administrators to manage broadcast notifications.
Supported operations include:
- Create a broadcast notification
- List broadcast notifications
- Retrieve notification details
- Update a broadcast notification
- Delete a broadcast notification
Buyer Notification List API
Base route:/api/buyer-notification-list/*
This API group provides buyer-facing notification management.
Supported operations include:
- Retrieve the buyer’s notification list
- Retrieve the count of unclicked notifications
- Mark a notification as read
- Mark a notification as clicked
- Delete a buyer notification
API reference note: The paths above are route namespaces. The package reference supplied for this guide does not include every individual HTTP method, endpoint path, request DTO, response schema, or authentication decorator. Use the controllers and the running API documentation for the exact endpoint contracts.
Data Models
The add-on uses two primary TypeORM entities.
The main broadcast record represents the notification being published. The buyer record tracks each recipient’s interaction with that broadcast.
This separation allows one broadcast to be delivered to multiple buyers while maintaining an individual notification state for each buyer.
Background Processing with BullMQ
The add-on uses BullMQ to process broadcast jobs asynchronously.Queue responsibilities
- Accept broadcast jobs for processing.
- Support delayed jobs for scheduled notification publication.
- Make jobs available to the worker when they are ready to run.
Worker responsibilities
TheNotificationWorker is initialized by the Express loader and processes queued broadcast jobs.
The package description identifies the worker as supporting:
- Multi-tenant job processing
- Scheduled/delayed broadcast handling
- Error resilience during job processing
Real-Time Updates with Socket.IO
When a broadcast is published, the add-on sends real-time alerts to buyer rooms through Socket.IO. The package exposes the following Socket.IO utilities:SpurtCommerce Loader Integration
The add-on is integrated into the host application through its loader lifecycle.1. TypeORM loader
typeormLoader.ts registers the broadcast notification database components:
BroadcastNotificationandBroadcastNotificationBuyerentities- The add-on’s database migrations
DataSource.
2. Express loader
expressLoader.ts registers the API controllers and initializes the background worker:
The worker is initialized as part of the Express loader integration described by the package.
3. Plugin loader
pluginLoader.ts registers BroadcastNotification in pluginModule.
This makes the broadcast notification module available through the host application’s plugin registration mechanism.
Integration flow
Buyer Notification States
TheBroadcastNotificationBuyer entity tracks the state of a broadcast for an individual buyer.
These per-buyer states support the buyer notification list, unclicked notification count, and read/click/delete actions.
Uninstallation
To remove the add-on, run the following command from the SpurtCommerce project root:Database note: Uninstalling the npm package does not, by itself, mean that existing notification tables or records are automatically removed. Handle database cleanup separately and only after reviewing the add-on migrations and your data-retention requirements.
Operational Notes
- Keep the BullMQ datastore reachable by the application and worker.
- Ensure the host application’s Socket.IO server is initialized and available to the add-on.
- Confirm the worker is initialized during application startup.
- Verify scheduled publication using a test broadcast with a future publish time before enabling the feature in production.
- Test tenant isolation to ensure a broadcast is processed for the intended tenant and its buyers.
- Confirm buyer notification state changes independently for different recipients.
Summary
@spurtcommerce/broadcast-notification provides broadcast creation and management, scheduled publication, background processing, and real-time buyer notifications for SpurtCommerce. It uses TypeORM entities for broadcast and per-buyer tracking, BullMQ for queue processing, Socket.IO for buyer-room alerts, and the SpurtCommerce loader lifecycle for application integration.