How motchiecmeowber/smart-home works
Smart Home is a web-based IoT monitoring and control system. Users authenticate, manage devices and locations, view live environmental readings and history, control actuators, create schedules, and submit service requests; administrators also manage devices, users, and requests. The client routes role-specific screens to backend APIs, while the server coordinates persistence and ThingsBoard connectivity. The graph preserves documented telemetry, emergency alerts, profile/settings, and reporting capabilities. Some client-to-endpoint and live-event wiring is not shown in the excerpts, so those relationships are omitted or marked unverified.
Main entry points: app.ts HTTP and WS server · App.tsx Route and role app · hardware.controller.ts Hardware API · actuator.service.ts Actuator service
Components 26
Web client
- Route and role app
app/client/src/App.tsx - Login and registration
app/client/src/pages/auth - Customer screens
app/client/src/pages/customer - Admin screens
app/client/src/pages/admin - Auth state and API
app/client/src/lib/authStore.ts - Device API
app/client/src/lib/deviceApi.ts
Identity and access
- Identity routes
app/server/src/modules/identity/identity.routes.ts - Identity controller
app/server/src/modules/identity/identity.controller.ts - Identity service
app/server/src/modules/identity/identity.service.ts
IoT device domain
- Hardware API
app/server/src/modules/hardware/hardware.controller.ts - Device service
app/server/src/modules/hardware/device.service.ts - Actuator service
app/server/src/modules/hardware/actuator.service.ts - Sensor service
app/server/src/modules/hardware/sensor.service.ts
Home operations
- Schedule automation
app/server/src/modules/automation/automation.service.ts - Service requests
app/server/src/modules/request/request.controller.ts - Notifications and control
app/server/src/modules/interaction/interaction.service.ts - Home locations
app/server/src/modules/location - Environmental analytics
app/server/src/modules/analytics
Server platform
- HTTP and WS server
app/server/src/app.ts - Postgres database
- Redis
- Client WebSocket
app/server/src/lib/ws/client-ws.ts - ThingsBoard WebSocket
app/server/src/lib/ws/tb-ws.ts
Other components
- Home user
- ThingsBoard Cloud
- Sensors and actuators
Connections 35
- Home user → Route and role app: uses
app/client/src/App.tsx - Route and role app → Login and registration: routes to
app/client/src/App.tsx - Route and role app → Customer screens: routes to
app/client/src/App.tsx - Route and role app → Admin screens: routes to
app/client/src/App.tsx - Route and role app → Auth state and API: restores session
app/client/src/App.tsx - Auth state and API → Identity routes: calls auth API
- Customer screens → Device API: uses device API
- Route and role app → HTTP and WS server: HTTP and WS
README.md - HTTP and WS server → Identity routes: mounts routes
app/server/src/app.ts - Identity routes → Identity controller: dispatches
app/server/src/modules/identity/identity.routes.ts - Identity controller → Identity service: calls
app/server/src/modules/identity/identity.controller.ts - Identity service → Postgres database: persists identity
- HTTP and WS server → Hardware API: mounts routes
app/server/src/app.ts - Hardware API → Device service: calls
app/server/src/modules/hardware/hardware.controller.ts - Hardware API → Actuator service: controls actuator
app/server/src/modules/hardware/hardware.controller.ts - Hardware API → Sensor service: reads sensor service
app/server/src/modules/hardware/hardware.controller.ts - Device service → ThingsBoard Cloud: syncs devices
- Device service → Postgres database: persists devices
- Actuator service → ThingsBoard Cloud: sends commands
README.md - ThingsBoard Cloud → Sensors and actuators: coordinates telemetry
README.md - HTTP and WS server → Schedule automation: initializes scheduler
app/server/src/app.ts - Schedule automation → Actuator service: controls scheduled devices
app/server/src/modules/automation/automation.service.ts - Schedule automation → Postgres database: stores schedules
- HTTP and WS server → Service requests: mounts request routes
app/server/src/app.ts - Service requests → Postgres database: stores requests
- HTTP and WS server → Notifications and control: mounts interaction routes
app/server/src/app.ts - Notifications and control → Actuator service: controls actuator
app/server/src/modules/interaction/interaction.service.ts - Notifications and control → Postgres database: stores interactions
- HTTP and WS server → Home locations: mounts location routes
app/server/src/app.ts - HTTP and WS server → Environmental analytics: mounts analytics routes
app/server/src/app.ts - HTTP and WS server → Redis: connects at startup
app/server/src/app.ts - HTTP and WS server → Client WebSocket: initializes WS
app/server/src/app.ts - HTTP and WS server → ThingsBoard WebSocket: connects listener
app/server/src/app.ts - ThingsBoard WebSocket → ThingsBoard Cloud: receives telemetry
README.md - Client WebSocket → Customer screens: streams live data