Skip to main content

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:

TypeUse CaseiOSAndroid
SilentState syncBackground refreshData message
AlertGeneral eventsStandard notificationDefault channel
CriticalSecurity alertsTime-sensitiveHigh priority channel

Event Processing Flow

  1. Webhook Received: Smart device platforms send events to bf_notify
  2. Event Parsing: Webhook payload is validated and parsed into SmartEvent
  3. Property Resolution: External device ID maps to internal property/device
  4. DO Processing: Event sent to User Durable Object for the property
  5. Side Effects: DO triggers notifications, access logs, state updates
  6. 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