How zedattran/embedded_energymanagement-basetasmota works
Smart Home Energy Monitoring and Optimization is a full-stack IoT system: homeowners use a Next.js dashboard to monitor and control CoreIoT-connected Tasmota plugs, manage schedules and budgets, and review forecasts and recommendations. The Flask backend handles authentication, device and energy APIs, chatbot requests, and background polling and schedule execution; it also persists user, device, energy, and optimization data. The README documents the IoT and frontend/backend flow; source-index references and excerpts support the internal registration, route, worker, shared-service, and persistence links shown. Some feature implementation paths are unsampled, so their links are documented rather than inferred from code.
Main entry points: shared.py IoT and energy services · app.py Flask application · auth_routes.py Authentication · api.py API registration
Components 24
User experience
- Dashboard pages
frontend/app/(dashboard) - Login and registration
frontend/app/(auth) - Frontend API client
frontend/lib/api-client.ts
Backend services
- Flask application
backend/app.py - API registration
backend/app_core/api.py - Authentication
backend/app_core/auth_routes.py - Device and control APIs
backend/app_core/routes/device_routes.py - Energy APIs
backend/app_core/routes/energy_routes.py - AI chatbot
backend/app_core/chatbot_api.py - IoT and energy services
backend/app_core/shared.py - Polling and scheduler
backend/app_core/workers.py - Realtime events
backend/app_core/socket_events.py - Email alerts
backend/app_core/email_utils.py
Energy optimization
- Forecast and budget APIs
backend/app_core/routes/forecast_routes.py - Energy analysis
backend/app_core/analysis_routes.py - Schedule APIs
backend/app_core/routes/schedule_routes.py - Forecast model
backend/ml/ensemble_model_improved.py - Forecast server
backend/ml/forecast_server.py
Persistence
- Database access
backend/database.py - User records
backend/db_users.py - MongoDB
backend/db_connection.py
IoT platform
- CoreIoT cloud
- Tasmota smart plugs
Other components
- Homeowner
Connections 45
- Homeowner → Login and registration: signs in
README.md - Homeowner → Dashboard pages: uses
README.md - Login and registration → Frontend API client: requests auth
- Dashboard pages → Frontend API client: requests data
- Frontend API client → Flask application: calls HTTP API
README.md - Flask application → API registration: registers routes
backend/app.py - Flask application → Authentication: registers auth
backend/app.py - Flask application → AI chatbot: registers blueprint
backend/app.py - Flask application → Realtime events: registers handlers
backend/app.py - Flask application → Polling and scheduler: starts jobs
backend/app.py - API registration → Device and control APIs: registers
backend/app_core/api.py - API registration → Energy APIs: registers
backend/app_core/api.py - API registration → Forecast and budget APIs: registers
backend/app_core/api.py - API registration → Schedule APIs: registers
backend/app_core/api.py - API registration → Energy analysis: registers
backend/app_core/api.py - Authentication → Database access: reads and updates users
backend/app_core/auth_routes.py - Authentication → Email alerts: sends verification mail
backend/app_core/auth_routes.py - Device and control APIs → IoT and energy services: uses device services
backend/app_core/routes/device_routes.py - Device and control APIs → Authentication: checks identity
backend/app_core/routes/device_routes.py - Energy APIs → IoT and energy services: uses energy state
backend/app_core/routes/energy_routes.py - Energy APIs → Authentication: checks identity
backend/app_core/routes/energy_routes.py - Forecast and budget APIs → IoT and energy services: uses device services
backend/app_core/routes/forecast_routes.py - Forecast and budget APIs → Authentication: checks identity
backend/app_core/routes/forecast_routes.py - Energy analysis → IoT and energy services: reads device data
backend/app_core/analysis_routes.py - Energy analysis → Authentication: checks identity
backend/app_core/analysis_routes.py - Schedule APIs → IoT and energy services: uses schedule services
backend/app_core/routes/schedule_routes.py - Schedule APIs → Authentication: checks identity
backend/app_core/routes/schedule_routes.py - AI chatbot → IoT and energy services: uses device services
backend/app_core/chatbot_api.py - Polling and scheduler → IoT and energy services: polls and schedules
backend/app_core/workers.py - Polling and scheduler → Email alerts: sends alerts
backend/app_core/workers.py - Polling and scheduler → Database access: persists telemetry
backend/app_core/workers.py - IoT and energy services → Database access: loads and saves data
backend/app_core/shared.py - IoT and energy services → Forecast server: uses forecast client
backend/app_core/shared.py - Database access → User records: re-exports user access
backend/database.py - Database access → MongoDB: initializes indexes
backend/database.py - User records → MongoDB: uses database connection
backend/db_users.py - Forecast server → Forecast model: uses model
backend/ml/forecast_server.py - IoT and energy services → CoreIoT cloud: requests telemetry and RPC
README.md - CoreIoT cloud → Tasmota smart plugs: forwards MQTT commands
README.md - Tasmota smart plugs → CoreIoT cloud: sends telemetry
README.md - CoreIoT cloud → IoT and energy services: provides device data
README.md - Flask application → Homeowner: serves dashboard API
README.md - Flask application → Realtime events: emits live updates
backend/app.py - Forecast and budget APIs → Forecast model: produces forecasts
- Forecast and budget APIs → Schedule APIs: supports optimizer schedules