How karansarda-cell/smart-home-cade works
CADE receives classroom telemetry over MQTT, filters and evaluates it, applies safety/mode priorities, publishes actuator commands, and records events for API logs and metrics. A separate data-preparation and Random Forest training workflow produces the model used by runtime predictions. The README also describes the FastAPI/MQTT product; source excerpts expose the runtime decisions and training path. The tree and imports disagree on anomaly-filter and model module names, so those links are omitted where their implementation cannot be matched confidently.
Main entry points: mqtt_client.py MQTT handler · main.py FastAPI endpoints · database.py Database sessions · ml_model.py Hazard predictions
Components 18
Telemetry decisions
- MQTT handler
backend/app/mqtt_client.py - Anomaly filter
backend/app/anomly_filter.py - Fuzzy decisions
backend/app/fuzzy_engine.py - Priority overrides
backend/app/conflict_resolver.py - Runtime settings
backend/app/config.py - Hazard predictions
backend/app/ml_model.py
Backend API
- FastAPI endpoints
backend/app/main.py
Event storage
- Audit event model
backend/app/model.py - Database sessions
backend/app/database.py
Model data and training
- Dataset preparation
backend/ml/download_dataset.py - Prepared datasets
backend/data/processed - Telemetry export
backend/ml/export_db_data.py - Random Forest training
backend/ml/train_model.py - Trained model
backend/app/cade_ml_model.pkl
Other components
- Classroom sensors
- MQTT broker
- Classroom actuators
- API operator
Connections 23
- Classroom sensors → MQTT broker: publish telemetry
README.md - MQTT broker → MQTT handler: deliver telemetry
backend/app/mqtt_client.py - MQTT handler → Anomaly filter: filter readings
- MQTT handler → Fuzzy decisions: evaluate readings
backend/app/mqtt_client.py - MQTT handler → Priority overrides: resolve priorities
backend/app/mqtt_client.py - MQTT handler → Hazard predictions: predict hazards
backend/app/mqtt_client.py - MQTT handler → MQTT broker: publish commands
backend/app/mqtt_client.py - MQTT broker → Classroom actuators: deliver commands
README.md - MQTT handler → Runtime settings: read topics
backend/app/mqtt_client.py - FastAPI endpoints → MQTT handler: start service
backend/app/main.py - API operator → FastAPI endpoints: request endpoints
backend/app/main.py - FastAPI endpoints → Hazard predictions: load and predict
backend/app/main.py - FastAPI endpoints → Database sessions: query logs
backend/app/main.py - MQTT handler → Database sessions: save events
backend/app/mqtt_client.py - MQTT handler → Audit event model: create audit event
backend/app/mqtt_client.py - FastAPI endpoints → Audit event model: query audit events
- Audit event model → Database sessions: map to tables
backend/app/model.py - Dataset preparation → Prepared datasets: write datasets
backend/ml/download_dataset.py - Telemetry export → Prepared datasets: export telemetry
backend/ml/export_db_data.py - Database sessions → Telemetry export: supply telemetry
- Prepared datasets → Random Forest training: provide training data
backend/ml/train_model.py - Random Forest training → Trained model: save model
backend/ml/train_model.py - Hazard predictions → Trained model: load model
backend/app/ml_model.py