How ihor-panchuk/smart_home works
Smart Home is a small FastAPI application for managing binary-state home devices, with a browser interface and PostgreSQL-backed device records. The main workflow is user interaction in the frontend, API request handling and validation, then database access and a response. The API supports device listing, lookup, creation, deletion and renaming, on/off control, status retrieval, light brightness, thermostat temperature, and door-lock state. A separate OOP practice file describes an in-memory model and JSON serialization; it is not shown wired into the API. Source evidence is sampled, so uncertain interactions are omitted.
Main entry points: main.py FastAPI application · database.py Device data access · script.js Device controls · smart_home_oop.py Device model exercise
Components 12
Browser interface
- Device controls
frontend/script.js - Frontend page
frontend/index.html
Device API
- FastAPI application
main.py - Request validation
main.py - Device routes
main.py - Status routes
main.py - Device settings
main.py
Persistent data
- Device data access
database.py
OOP practice
- Device model exercise
oop_practice/smart_home_oop.py
Other components
- Home user
- PostgreSQL
- JSON file
Connections 12
- Home user → Device controls: uses
- FastAPI application → Frontend page: serves static files
- Device controls → FastAPI application: sends requests
- FastAPI application → Request validation: validates inputs
- FastAPI application → Device routes: dispatches requests
- FastAPI application → Status routes: dispatches requests
- FastAPI application → Device settings: dispatches requests
- Device routes → Device data access: calls CRUD
- Status routes → Device data access: reads device
- Device settings → Device data access: reads and updates
- Device data access → PostgreSQL: queries and updates
- Device model exercise → JSON file: reads and writes