System architecture
How it fits together
Your monitor, phone and dashboard all talk to one backend, which keeps everything safe in a database. Tap any part or path to see what it does.
Air monitor
ESP32-S3 · RustSamples a PMS5003 particle sensor in a short burst every 5 minutes and reads an SHT30 climate sensor every 20 seconds, then shows the result on its little screen.
Mobile app
FlutterSets up a new monitor over Bluetooth, then shows your readings wherever you are.
Web dashboard
ReactManage your devices, browse their history and choose what to share. Public device pages and the map need no sign-in.
Backend
GoOne API for everything. Requests flow from routes to handler, service and repository, and database migrations apply on their own when it starts.
routes → handler → service → repository
Database
PostgreSQLHolds readings, devices and logs. Only the backend talks to it, and public pages only ever see what an owner chose to share.
Phone ↔ monitor
Bluetooth LEShort text commands over the Nordic UART Service, on an encrypted link that only opens after passkey pairing.
Nordic UARTPasskey pairing
Monitor → backend
HTTPSEvery 10 minutes the monitor uploads an averaged reading, sends any log events and asks whether an approved update is waiting. Each request carries its ID, secret key and firmware version.
POST /dataPOST /device/logsGET /device/otaX-Device-IDX-Device-KeyX-Firmware-Version
Mobile app → backend
ClerkThe app signs in with a Clerk session token. Phones have no web origin, so the backend accepts them when native clients are turned on.
CLERK_ALLOW_NATIVE_CLIENTS
Dashboard → backend
ClerkThe dashboard sends a Clerk session token, and the backend checks it came from one of our allowed sites.
CLERK_AUTHORIZED_PARTIES
Before you change a contract
Section titled “Before you change a contract”These are shared between repositories, so a change on one side can break another. Open one to see which repositories to check.
Routes and JSON
REST routes and their payloads.
Check: BackendDashboardMobile appFirmware
Device headers
How a monitor proves who it is.
X-Device-IDX-Device-KeyX-Firmware-Version
Check: FirmwareBackend
BLE commands
UUIDs, commands and reply framing.
Check: FirmwareMobile app
AQI and units
AQI bands, units, sampling intervals and nullable location.
Check: BackendDashboardMobile appFirmware