Resources
Developer guide
- Written for
- Developers working on the firmware, backend, or dashboard.
- You need
- Node.js 18 or newer, npm, and access to the mantai-sensor-unit repository. Firmware builds also need arduino-cli.
Everything that makes up MantAI lives in the mantai-sensor-unit repository. The firmware, cloud backend, and dashboard all sit side by side and talk to each other through one documented protocol. Think of this page as the working README: where things live, how to run them, and how to check that a change holds up. Once you ship something, walk through the documentation release checklist on Audiences & maintaining documentation.
Repository layout#
| Path | What it is |
|---|---|
firmware/MantaiSensor/ | The ESP32-S3 sketch (Arduino core 3.x, FreeRTOS tasks). It handles sensor sampling, event detection, audio capture, the SD archive, and the uplink. |
backend/ | The Cloudflare Worker (Hono, TypeScript). This is the /v1 API, D1 SQL migrations, R2 clip storage, live ride Durable Objects, and the AI analysis. |
dashboard/ | A React 18 + Vite SPA. The built assets are served by the same Worker deployment that runs the API. |
docs/ | protocol.md covers packet layouts, the transfer protocol, and test vectors, and it is the source of truth. hardware.md covers the pin map, wiring, IDE setup, and the bring-up checklist. |
app/ | The Expo / React Native companion app from the BLE MVP days. We keep it around for reference and bench testing, but the LTE product doesn't need it. |
scripts/ | CI helpers, including the firmware compile check. |
Run it locally#
Backend + dashboard
# API worker (local D1/R2 emulation via wrangler)
cd backend
npm install
npx wrangler dev
# Dashboard
cd dashboard
npm install
npm run devIf you run the backend with DEV_MODE=1, the magic-link endpoint hands the sign-in token back to you right in the response, so you don’t need an email provider wired up to develop locally.
Firmware
# Compile check (arduino-cli, ESP32-S3 target, installs required libraries)
./scripts/check-firmware.shFlashing, wiring, and the full bring-up checklist (I2C scan, SD init, microphone test) are walked through step by step in docs/hardware.md.
Verify a change#
- Backend
- Run the type-check and tests in
backend/, then hit the endpoints againstwrangler dev. - Dashboard
- Make sure the Vite build passes, and check the pages you touched against a dev backend.
- Firmware
./scripts/check-firmware.shshould compile cleanly for the ESP32-S3 target.- Protocol changes
- Update
docs/protocol.mdin the same change. It’s the source of truth both sides are built against, so it can’t drift.
Conventions#
- Offline-first IDs: anything a unit can create, like rides and clips, gets a unit-minted UUID. That keeps creation idempotent and safe to retry.
- Migrations: schema changes are numbered SQL migrations in
backend/migrations/, and you should never edit one that’s already been applied. - Docs as part of the release: when behavior, endpoints, or the schema change, the matching page here and the repo docs go out in the same release.
- Design language: monochrome, with a warm off-white background, near-black ink, serif display headings, and a single red held back for alerts. Keep new UI inside those lines.