This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
A distributed smart home system with three layers:
devices/) — IoT devices exposing a REST APIserver/) — central backend that manages devices, events, and automation scriptswebclient-vue/) — Vue 3 + Pinia + Vite frontend using gnexus-ui-kitwebclient/) — old vanilla JS frontend (kept as fallback)cd webclient-vue npm install # install dependencies (Vue 3, Pinia, Vite, gnexus-ui-kit, Phosphor icons) npm run dev # starts Vite dev server with proxy to PHP backend npm run build # production build → dist/ npm test # runs Vitest unit/component/integration tests npm run test:coverage # tests with coverage report
cd webclient npm install # install dependencies (esbuild, sass, gulp, browser-sync, etc.) npm start # runs gulp: compiles SCSS → dist/css/main.css, bundles JS → dist/js/main.js, watches + live-reloads
No build step. PHP is served directly from server/. Entry point is server/index.php. Configure in server/SHServ/config.php (DB credentials, device IP scan range, debug flag).
cd devices ./build.sh # compiles all targets via arduino-cli, copies release binaries to devices/builds/
Build targets: relay for esp8266:generic and esp32:esp32c3; button for esp8266:d1_mini in x2 and x4 channel variants. Each device's .ino file #includes <sh_core.h> from devices/sh_core_esp8266/src/. Pre-built release binaries live in devices/builds/.
/about is public (no auth).192.168.x.2–254 (range from config), finds devices via /about.POST /setup on the device, pushing: auth token, server address, device name/alias, channel schema.Authorization: Bearer <token>.GET /about — always public, returns device type/firmware infoGET /status — current channel states (auth required)POST /action — control command (auth required)POST /events/new/api/v1/)/devices/scanning/* — scan network for new devices/devices/setup/new-device — register a found device/devices/id/{id}/* — info, status, control per device/devices/action — execute a device action/areas/* — logical groupings of devices/scripts/* — automation scriptsRoutes are defined as PHP traits in server/SHServ/Routes/ and mixed into the app via server/SHServ/App.php. The underlying framework is a custom MVC called Fury (server/Fury/).
PHP classes in server/ControlScripts/Scopes/, extending ControlScripts base class. Each Scope class implements four methods: register_sync_map, register_events_handlers, register_actions_scripts, register_regular_scripts. All Scopes are auto-loaded at startup. See docs/control-scripts-guide.md.
src/app/main.js — Vue app entry (createApp + Pinia + router)src/router/routes.js — hash-router routessrc/api/ — HTTP client: client.js, http.js, mappers.js, modules/{areas,devices,scripts,scanning}.jssrc/stores/ — Pinia stores: areas.js, devices.js, scripts.js, scanning.js, favorites.jssrc/components/ — thin UI adapters (AppShell, AppEmptyState, AppErrorState, AppLoadingState)src/features/{areas,devices,scripts}/pages/ — page components using gnexus-ui-kit componentssrc/test/mocks/handlers.js — MSW mock handlers for integration testsvitest.setup.js — test setup (jsdom, localStorage mock, router stubs, MSW server)gnexus-ui-kit semantic color classes (.text-success, .text-danger, .bg-primary, .badge-warning, etc.) instead of project-specific CSS custom properties (--color-accent, --color-danger).currentColor rather than hard-coding hex values.webclient/src/js/index.js — app entry pointwebclient/src/js/sh/SmartHomeApi.js — all server API callswebclient/src/js/components/ — UI components (hud, modals, toasts, etc.)webclient/src/js/routes.js — frontend routingwebclient/proxy.php — CORS proxy for API calls in devdevices/sh_core_esp8266/src/)Shared Arduino library used by all device firmware:
sh_core.h — EEPROM memory layout, constants, channel type definitionssh_core.cpp — WiFi, OTA, EEPROM helpersREST_API.cpp — device HTTP server and endpoint implementationsWebHandlers.cpp / WebPages.cpp — browser-accessible device config UI| Path | Purpose |
|---|---|
server/SHServ/config.php |
DB credentials, device IP scan range, debug mode |
server/SHServ/Routes/ |
API route definitions (trait-based) |
server/SHServ/Controllers/ |
Request handler logic |
server/SHServ/Models/ |
DB query layer |
server/console.php |
CLI entry point for server-side scripts |
webclient/src/js/sh/SmartHomeApi.js |
Legacy JS API client |
webclient-vue/src/api/client.js |
Vue API client wrapper |
webclient-vue/src/app/main.js |
Vue app entry point |
devices/sh_core_esp8266/src/sh_core.h |
EEPROM layout and all device-side constants |
docs/device-spec.md |
Device REST API contract (endpoints on the device itself) |
docs/server-api.md |
Server REST API — full reference of all implemented endpoints |
docs/architecture.md |
Full architecture: firmware contract, events routing, sync map, Fury framework |
docs/firmware-dev-guide.md |
How to write firmware for a new device type |
docs/control-scripts-guide.md |
How to write automation scripts (Scope classes) |
webclient-vue/docs/migration-plan.md |
Vue client migration plan (Phases 1–6) |
webclient-vue/docs/smoke-checklist.md |
UI smoke checklist for releases |