How fabriziobc2005/smart-classroom works
Smart Classroom monitors classroom air and occupancy, computes health and risk, automates ventilation and lighting, and surfaces live status and human follow-up in a dashboard. The main flow is sensor or simulator telemetry over MQTT into the worker, which applies rules, stores readings and actions, and publishes live updates for the API and dashboard. Separate branches provide forecasts, compliance and ventilation reports, pending tasks, and a read-only AI assistant. The worker excerpts and README support the ingestion and live-update flow; unsampled frontend and service internals limit further call-level links.
Main entry points: app/main.py REST and WebSocket API · worker/main.py Ingestion worker · page.tsx Web dashboard · db.py PostgreSQL
Components 31
Telemetry ingestion
- Telemetry simulator
simulator/main.py - MQTT broker
- Ingestion worker
backend/worker/main.py - PostgreSQL
backend/app/db.py - Redis cache and pub/sub
Analysis and control
- Automation rules
backend/app/services/reglas.py - Comfort index
backend/app/services/indice.py - Occupancy estimate
backend/app/services/aforo.py - CO₂ prediction
backend/app/services/prediccion.py
API and reporting
- REST and WebSocket API
backend/app/main.py - Classroom data models
backend/app/models.py - Classroom status and history
backend/app/routers/aulas.py - Manual control
backend/app/routers/control.py - Events
backend/app/routers/eventos.py - Compliance and ACH reports
backend/app/routers/reportes.py - Human follow-up tasks
backend/app/services/pendientes.py - Read-only AI assistant
backend/app/services/asistente.py - Forecast review
backend/app/routers/pronostico.py - Redis WebSocket bridge
backend/app/realtime.py
Dashboard
- Web dashboard
web/src/app/page.tsx - Classroom detail
web/src/app/aula/[id]/page.tsx - Pending tasks view
web/src/app/pendientes/page.tsx - Compliance report view
web/src/app/reporte/page.tsx - Assistant bubble
web/src/components/Asistente.tsx - Dashboard data types
web/src/lib/tipos.ts
Forecast learning
- Historical training examples
backend/aprendizaje/ejemplos.py - Forecast features
backend/aprendizaje/que_mira.py - Forecast model
backend/aprendizaje/pronosticador.py
Other components
- Classroom sensors
- Ventilation and lights
- Classroom staff
Connections 38
- Classroom sensors → MQTT broker: send telemetry
README.md - Telemetry simulator → MQTT broker: publish telemetry
README.md - MQTT broker → Ingestion worker: deliver telemetry
README.md - Ingestion worker → Automation rules: evaluate readings
backend/worker/main.py - Automation rules → Comfort index: calculate index
backend/app/services/reglas.py - Automation rules → Occupancy estimate: estimate occupancy
backend/app/services/reglas.py - Automation rules → CO₂ prediction: project CO₂
backend/app/services/reglas.py - Ingestion worker → PostgreSQL: persist readings
backend/worker/main.py - Ingestion worker → PostgreSQL: save events and actions
backend/worker/main.py - Ingestion worker → Redis cache and pub/sub: publish live state
backend/worker/main.py - Ingestion worker → MQTT broker: send commands
README.md - MQTT broker → Ventilation and lights: deliver commands
README.md - REST and WebSocket API → Classroom status and history: register routes
backend/app/main.py - REST and WebSocket API → Manual control: register routes
backend/app/main.py - REST and WebSocket API → Events: register routes
backend/app/main.py - REST and WebSocket API → Compliance and ACH reports: register routes
backend/app/main.py - REST and WebSocket API → Forecast review: register routes
backend/app/main.py - REST and WebSocket API → Redis WebSocket bridge: start Redis listener
backend/app/main.py - Redis WebSocket bridge → Redis cache and pub/sub: receive updates
backend/app/realtime.py - REST and WebSocket API → Web dashboard: serve API and live updates
README.md - Classroom status and history → PostgreSQL: read classroom history
backend/app/routers/aulas.py - Classroom status and history → Redis cache and pub/sub: read cached state
backend/app/routers/aulas.py - Compliance and ACH reports → PostgreSQL: query report data
backend/app/routers/reportes.py - Human follow-up tasks → PostgreSQL: inspect incidents
backend/app/services/pendientes.py - Human follow-up tasks → Redis cache and pub/sub: read live state
backend/app/services/pendientes.py - Read-only AI assistant → Classroom staff: answer questions
README.md - Web dashboard → Classroom detail: open classroom
- Web dashboard → Pending tasks view: open tasks
- Web dashboard → Compliance report view: open reports
- Web dashboard → Assistant bubble: offer assistant
README.md - Classroom detail → Classroom staff: offer manual controls
README.md - Classroom staff → Manual control: request manual action
README.md - Assistant bubble → Read-only AI assistant: ask questions
README.md - Historical training examples → PostgreSQL: read historical samples
backend/aprendizaje/ejemplos.py - Historical training examples → Forecast features: build feature rows
backend/aprendizaje/ejemplos.py - Forecast features → Forecast model: provide forecast inputs
backend/aprendizaje/pronosticador.py - Ingestion worker → Forecast model: forecast live CO₂
backend/worker/main.py - Web dashboard → Dashboard data types: use typed API data