Hardware Data Roadmap (IoT)
Ingestion Options
- HTTP Webhook: Gateway posts JSON to
/api/iot/ingestsigned with HMAC. - MQTT Broker: Devices publish to topics; subscriber service writes to DB.
- LoRaWAN (TTN/ChirpStack): Uplink webhooks to
/api/iot/ttn.
Data Model (Prisma)
Two core tables:
- SensorDevice: farmId, name, type, unit, connectivity, metadata, apiKeyHash, lastSeenAt.
- SensorReading: deviceId, at, value, unit, quality, raw (indexed by deviceId, at).
Security & Provisioning
- Admin registers SensorDevice → binds to Farm → issues device API key (store only hash).
- All ingestion over TLS. Verify HMAC signature per request. Rate-limit per device.
- Validate units and value ranges; mark quality: ok/warn/error.
Minimal Working Slice (1–2 days)
- Add SensorDevice & SensorReading models; migrate.
- Build
POST /api/iot/ingestwith HMAC auth. - Admin: Register sensor, bind to farm, generate API key (QR optional).
- POST from a test ESP32/gateway; store reading; update lastSeenAt.
- Dashboard: show latest soil moisture and last seen.
- Advisory: trigger low-moisture alert; push notification.
- Chat: include latest sensor snapshot in context for richer answers.
See repository root: HARDWARE_INTEGRATION.md for full details.