Notification System Architecture
This document describes the real-time notification system implemented using RabbitMQ and WebSockets (Socket.IO) to keep administrators and partners informed of critical actions.
Architecture
- Event Origin: A service (e.g.,
PartnerService) performs an action and publishes a message to RabbitMQ exchange partner.events.
- Event Consumption: The
NotificationService (specifically ContractEventConsumerService) subscribes to these RabbitMQ messages.
- WebSocket Broadcast: The
NotificationService emits a WebSocket event to the appropriate channel (admin or partner:{partnerId}).
- UI Feedback: The frontend consoles (Admin and Partner) listen for these WebSocket events and display
sonner toasts and/or browser Web Notifications.
Implemented Notifications
Admin -> Partner Notifications
| Event |
Trigger |
UI Feedback (Partner Console) |
contract.created |
Admin creates a new contract draft. |
Toast & Web Notification |
contract.status_changed (SENT) |
Admin sends a contract for review/signature. |
Toast & Web Notification |
contract.status_changed (ACTIVE) |
Admin activates a signed contract. |
Toast & Web Notification |
task:created |
Admin creates a task for the partner. |
Toast & Web Notification |
service.proposal.approved |
Admin approves a service update proposal. |
Toast & Web Notification |
service.proposal.rejected |
Admin rejects a service update proposal. |
Toast & Web Notification |
Partner -> Admin Notifications
| Event |
Trigger |
UI Feedback (Admin Console) |
contract.created |
Partner creates a contract (if allowed). |
Toast |
contract.signed |
Partner signs a contract. |
Toast |
contract.updated |
Partner uploads a document to a draft. |
Toast |
task:created |
Partner action triggers an admin task (e.g. submit draft). |
Toast |
service.proposal.created |
Partner requests a service update. |
Toast |
Identified Missing or Potential Notifications
Admin -> Partner (Future)
- Document Status: Notify partner when an admin marks an onboarding document as VERIFIED or REJECTED.
- Account Status: Notify partner when their global account status changes (ACTIVE, SUSPENDED).
- Service Text Review: Instant notification when an admin requests a partner to review AI-generated content.
Partner -> Admin (Future)
- Onboarding Complete: Notify admin when a partner has filled all required fields and uploaded all required documents.
- Critical Info Change: Notify admin if a partner changes their tax ID, legal name, or emergency contacts.
- Messaging: Instant notifications for any future direct messaging feature between admin and partner.
Technical Details
- RabbitMQ Exchange:
partner.events
- WebSocket Namespace:
/notifications
- Rooms:
admin: All administrators.
partner:{partnerId}: Individual partners (identified by UUID).