System Architecture

Two ingestion paths — the preferred backend-first flow and a spreadsheet-based fallback for early POC use.

Preferred flow

Sensors report via a hub or automation layer, normalized events are pushed to the backend, and the dashboard subscribes for live updates.

Aqara FP2
Presence sensor
Hub / Gateway
Automation layer
API / Webhook
POST /api/sensor-event
Lovable Cloud
Postgres + RLS
Dashboard
Live UI
Staff Action
Verify & resolve
Fallback (POC) flow

Useful when no gateway integration exists yet. Acceptable for prototyping; should not be the long-term architecture.

Sensor / Manual
Aqara or operator entry
Spreadsheet
Sheets / Excel / CSV
Sync job
Periodic import
Lovable Cloud
Postgres
Dashboard
Periodic refresh
Why two paths?

The preferred flow is real-time and reliable, but requires gateway integration. The fallback unblocks the POC by treating spreadsheets as a temporary event source.

Both paths converge on the same database schema, so swapping the source later requires no UI changes.

Event normalization

Hardware-specific payloads are mapped to a generic event format before persisting. This keeps the backend extensible to other sensor brands.

Required fields: sensor_id, zone, event_type, timestamp.