IoT_Master

Architecture

1. Purpose

A reusable, portable Raspberry Pi terminal for IoT and AI teaching. It serves as classroom demo kit, STEM workshop tool, sensor monitor, and host for multiple educational modules — all on the same software platform.

2. Principles

3. Logical architecture

+---------------------+
|  Sensors / devices  |
|  (Micro:bit, ESP32, |
|   USB sensors, ...) |
+----------+----------+
           |
           | MQTT publish
           v
+----------+----------------+
|     Mosquitto (MQTT)      |
+----+-----------------+----+
     |                 |
     | subscribe       | subscribe
     v                 v
+----+--------+    +---+----------+        +-------------------+
|  Node-RED   |    |   FastAPI    |        |   Anthropic API   |
|  (automation|    |  (REST + WS) |        |    (Claude        |
|   admin UI, |    |              |        |     Haiku 4.5)    |
|   debug)    |    +---+----------+        +---------+---------+
+-------------+        |       \                     ^
                       |        \                    | HTTPS
                       v         \                   | (user-triggered)
                +------+-----+    \                  |
                |   SQLite   |     \      +----------+----------+
                | sensors,   |      ----->|     AI service      |
                | ai_prompts,|<-----------|  (Claude SDK,       |
                | logs, ...  |  persist   |   prompt log)       |
                +------+-----+            +---------------------+
                       |
                       v
              +--------+---------+
              |  Vue + Tailwind  |
              | (touchscreen UI, |
              |  module launcher,|
              |  "Explain" btn)  |
              +------------------+

4. Component responsibilities

Component Responsibility Out of scope
Mosquitto Single MQTT broker, central pub/sub bus. Persistence, business logic.
Node-RED Automation flows, MQTT debugging, admin tooling, rapid prototyping. The primary user-facing UI.
FastAPI REST + WebSocket API for the Vue frontend; orchestrates DB, AI, and MQTT bridge. Real-time sensor ingestion (that’s MQTT).
AI service Calls Claude Haiku via the anthropic SDK, renders the prompt template, persists prompt/response pairs, exposes a single /ai/explain REST endpoint. Local inference. MQTT triggers. Multi-provider support.
SQLite Durable storage for sensors, readings, devices, AI history, logs, modules registry. High-frequency time-series (deferred to InfluxDB/Timescale if needed).
Vue + Tailwind Touchscreen dashboard, module launcher, settings, AI explainer surfaces. Automation flows (those live in Node-RED).
Docker Compose Service orchestration, single-command bring-up, version pinning. Multi-host orchestration (no k8s, no swarm).

5. Architecture Decision Records (ADRs)

ADRs are intentionally short. Each captures a decision, the alternatives, and the reasoning so future contributors don’t relitigate them.

ADR-001: SQLite for v1, behind a repository abstraction

ADR-002: MQTT as the central communication bus

ADR-003: Anthropic Claude only, Haiku as default model, user-triggered

ADR-004: Vue + Tailwind is the primary UI; Node-RED is automation/admin

ADR-005: Docker Compose for orchestration

ADR-006: arm64-only, no multi-arch builds

ADR-007: Pi 4B 8GB + official 5” touchscreen, no exotic hardware in v1

ADR-008: British English in documentation and UI copy

6. Cross-cutting concerns