Historical charts depend on rows stored in Postgres, not on the browser remembering prior values. The Worker writes them: push devices post readings to the ingest API, and server code polls pull feeds on a schedule. Each row is tied to a household and a sensor.
Insert model
- Household, sensor, and timestamp identify each sample.
- Store numeric, on/off, or text values in typed columns for fast chart queries.
- Skip insert if upstream fetch failed to avoid flatlines at zero.
Auth boundary
Every history query runs on the server and is scoped in SQL to the signed-in user's household: sign-in flow. Only server code in the Worker writes rows, such as the ingest route and scheduled jobs; the browser never inserts history directly.
Consumption
Dashboard reads via history browsing; export via CSV export. Live path: home page fetch.