Real-time Notifications System
Relevant source files
The following files were used as context for generating this wiki page:
The Real-time Notifications System is a core infrastructure component designed to facilitate instantaneous communication between the property management platform and its various users, including Administrators, Vendors, and Tenants. The system ensures that critical project updates, bid status changes, and compliance alerts are delivered immediately to the relevant parties, enhancing operational efficiency and transparency.
The system is integrated deeply into the RFQ Management System and Vendor Management modules. It utilizes a combination of database-level triggers, specialized service utilities, and frontend real-time listeners to maintain a synchronized state across the application.
System Architecture
The notification system follows a multi-tier architecture involving the database, edge functions, and the frontend user interface.
Core Components and Logic
The system is built upon several key pillars:
- Notification Templates: Standardized message formats for various events such as project assignments, milestone approvals, and document expirations.
- Broadcasting Logic: Mechanism to filter and notify specific groups, such as "Qualified Vendors," based on specialties and availability.
- Delivery Channels: Dual-channel delivery via in-app notifications and automated email templates.
Sources: src/components/NotificationSystemVerification.tsx:1-150, supabase/migrations/20251228080428_f95dcabc-4c93-43af-a1d9-2553a871c206.sql:1-100
Notification Data Flow
The following sequence diagram illustrates the flow of a notification from a system event (like a new RFQ) to the final user alert.
Functional Modules
1. Vendor Broadcasting
Administrators can broadcast project availability to verified vendors. This module filters vendors by:
- Specialties: Matching project categories (e.g., HVAC, Plumbing).
- Availability Status: Targeting only "available" vendors.
- Verification Status: Restricting to "is_verified" profiles.
Sources: src/components/AdminRFQSystem.tsx:212-220
2. Milestone & Bid Tracking
Specific notifications are triggered by state changes in project lifecycles:
- Bid Status Updates: Notifies vendors when their bids are accepted or rejected.
- Milestone Approvals: Alerts vendors when a project milestone is approved, often linked to payment processing.
Sources: src/components/NotificationSystemVerification.tsx:52-70, src/components/AdminRFQSystem.tsx:340-360
3. Compliance & Expiration Alerts
The system monitors document validity and issues automated warnings:
- Insurance Certificates: Alerts sent 7 days before expiration.
- Verified Status: Warnings to maintain verification by updating expired credentials.
Sources: src/components/NotificationSystemVerification.tsx:72-90, supabase/migrations/20251228080428_f95dcabc-4c93-43af-a1d9-2553a871c206.sql:102-120
Email Integration
The system includes a robust email templating engine managed via the database. These templates support variable injection for personalization.
| Template Name | Subject | Usage Context |
|---|---|---|
rfq_invitation | New RFQ Opportunity | Sent when an Admin invites a vendor to an RFQ. |
bid_confirmation | Bid Submitted Successfully | Sent to a vendor after successful bid submission. |
contract_award | Congratulations! Contract Awarded | Sent when a vendor's bid is accepted. |
rfq_reminder | RFQ Deadline Approaching | Automated reminder for pending submissions. |
compliance_expiry | Document Expiring Soon | Warning for expiring insurance or certifications. |
Sources: supabase/migrations/20251228080428_f95dcabc-4c93-43af-a1d9-2553a871c206.sql:1-150
Implementation Details
Notification Structure
Notifications are stored in the database with the following critical fields:
{
"user_id": "UUID",
"title": "String",
"message": "Text",
"type": "info | success | warning | error",
"action_url": "String",
"read": "Boolean"
}
Sources: src/components/AdminRFQSystem.tsx:222-228, src/components/NotificationSystemVerification.tsx:20-40
Real-time Synchronization
The frontend maintains a real-time connection using Supabase's realtime capabilities. This is reflected in the global UI:
- Bell Icon: Displays an unread count badge.
- Toast Alerts: Instant pop-up notifications using the
sonnerlibrary. - Notification Center: A dedicated view for history and management.
Sources: src/App.tsx:20-50, src/components/NotificationSystemVerification.tsx:160-180
Verification and Testing
A dedicated verification utility allows developers to simulate and validate notification flows:
- Basic Creation Test: Validates manual insertion.
- Broadcast Test: Simulates vendor filtering and mass notification.
- Template Test: Verifies variable injection in milestone and document alerts.
Sources: src/components/NotificationSystemVerification.tsx:18-140
The Real-time Notifications System is critical for maintaining the responsive nature of the property management platform, ensuring that no stakeholder misses time-sensitive actions or status updates.