Notifications & Real-time
The notification system handles both push notifications to mobile devices and real-time updates to connected web clients. It processes events from smart devices and translates them into user-facing alerts.
Architecture Overview
┌─────────────────┐ ┌─────────────────┐ ┌─────────────────┐
│ Smart Device │────▶│ bf_notify │────▶│ User Durable │
│ Webhook │ │ Worker │ │ Object │
└─────────────────┘ └─────────────────┘ └─────────────────┘
│
┌───────────────────────────────┼───────────────────────────────┐
│ │ │
▼ ▼ ▼
┌───────────────┐ ┌───────────────┐ ┌───────────────┐
│ FCM Push │ │ WebSocket │ │ Access Log │
│ (Mobile) │ │ (Web/App) │ │ Recording │
└───────────────┘ └───────────────┘ └───────────────┘
Notification Types
The system supports different notification urgency levels:
| Type | Use Case | iOS | Android |
|---|---|---|---|
| Silent | State sync | Background refresh | Data message |
| Alert | General events | Standard notification | Default channel |
| Critical | Security alerts | Time-sensitive | High priority channel |
Event Processing Flow
- Webhook Received: Smart device platforms send events to
bf_notify - Event Parsing: Webhook payload is validated and parsed into
SmartEvent - Property Resolution: External device ID maps to internal property/device
- DO Processing: Event sent to User Durable Object for the property
- Side Effects: DO triggers notifications, access logs, state updates
- Delivery: Push notifications via FCM, real-time via WebSocket
WebSocket Infrastructure
Connected clients (web dashboard, mobile app) receive real-time updates through WebSocket connections maintained by Durable Objects. This enables:
- Instant device state updates
- Live access log streaming
- Presence awareness
- Synchronized multi-device experience
Documentation in This Section
- notification-system.md - Push notification pipeline and FCM integration
- realtime-events.md - WebSocket infrastructure and event broadcasting