Skip to content

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 · Rust

Samples 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

Flutter

Sets up a new monitor over Bluetooth, then shows your readings wherever you are.

Web dashboard

React

Manage your devices, browse their history and choose what to share. Public device pages and the map need no sign-in.

Backend

Go

One 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

PostgreSQL

Holds 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 LE

Short text commands over the Nordic UART Service, on an encrypted link that only opens after passkey pairing.

  • Nordic UART
  • Passkey pairing

Monitor → backend

HTTPS

Every 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 /data
  • POST /device/logs
  • GET /device/ota
  • X-Device-ID
  • X-Device-Key
  • X-Firmware-Version

Mobile app → backend

Clerk

The 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

Clerk

The dashboard sends a Clerk session token, and the backend checks it came from one of our allowed sites.

  • CLERK_AUTHORIZED_PARTIES

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