Skip to main content

🏠 Station Overview

A "station" is everything that runs on a single Raspberry Pi: backend (Fastify), frontend (React SPA), Postgres, MQTT broker, plus the native station-agent that manages them. Source lives in the smart-home/ β†— monorepo.

What a Station Owns​

  • All ESP32 device data (devices, telemetry, events)
  • Local user accounts (synced from Cloud or LAN-only)
  • Automations and kits
  • Firmware artefacts and OTA distribution
  • Wi-Fi network configuration (via station-agent + captive portal)

It works fully offline β€” Cloud connection is optional and only needed for remote/mobile access.

Topology​

Monorepo Layout​

smart-home/
β”œβ”€β”€ packages/
β”‚ β”œβ”€β”€ backend/ β€” Fastify API + WS + MQTT bridge
β”‚ β”œβ”€β”€ frontend/ β€” React 18 + Vite SPA
β”‚ └── shared/ β€” Cross-package TypeScript types + Zod schemas
β”œβ”€β”€ firmware/
β”‚ β”œβ”€β”€ lib/smart-home-core/ β€” shared C++ library (Wi-Fi, MQTT, BLE, OTA)
β”‚ β”œβ”€β”€ esp32-climate/ β€” temperature + humidity + pressure sensor
β”‚ β”œβ”€β”€ esp32-pir/ β€” motion detector
β”‚ β”œβ”€β”€ esp32-light/ β€” LED actuator (dimmable)
β”‚ └── esp32-switch-pir/ β€” wall switch with PIR
β”œβ”€β”€ station-agent/ β€” Native Node binary on RPi (SEA, self-managed via systemd)
β”œβ”€β”€ deployment/ β€” Docker Compose, install scripts, nginx config
└── docs/ β€” Internal design notes (mqtt-protocol, kits, hardware, etc.)

Run Commands​

From the monorepo root:

npm run dev # Turbo: backend + frontend in watch mode
npm run build # Turbo: build all packages
npm run lint # eslint across all packages
npm run check-types # tsc --noEmit
npm run format # prettier --write
npm run firmware:build # build ESP32 firmware (scripts/build-firmware.js)

Release​

All releases via scripts/release.sh β†— β€” never edit package.json versions or create tags manually.

TagWhat gets builtWhere it lands
v0.2.77backend + frontend Docker imagesDocker Hub + release.json updated
backend-v0.2.77backend onlyDocker Hub + release.json (frontend untouched)
frontend-v0.2.77frontend onlyDocker Hub + release.json (backend untouched)
firmware-v0.1.5all firmware variantsPublic registry + firmware/manifest.json
firmware-esp32-climate-v0.1.5one firmware variantPublic registry + manifest
agent-v1.0.1station-agent SEA binarysmart-home-updates repo

See Release Flow.

Conventions​

  • Default branch: develop
  • Jira prefix: SHS- (e.g. SHS-42 add device pairing)
  • TS conventions: arrow functions, no classes, enum + Record dispatch β€” see TypeScript rules β†—

Reference​