# lbou55/smart-classroom architecture

> Architecture diagram of the GitHub repository lbou55/smart-classroom, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-05). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/lbou55/smart-classroom
- Repository: https://github.com/lbou55/smart-classroom

## Overview

Smart Classroom monitors classroom conditions, predicts near-term temperature, and uses those readings to guide AC control. The main flow runs from ESP32 sensors (or the simulator) through Flask ingestion and prediction to Firebase-backed state and the web dashboard. The web app also provides authentication, historical statistics, chat, account and admin management, translations/themes, and blueprint downloads. Source excerpts confirm selected API and Firebase interactions; other capability links below rely on README descriptions, not inspection of unsampled implementation.

Main entry points: [`app.py`](https://github.com/lbou55/smart-classroom/blob/main/app.py) (Flask API), [`static/js/admin.js`](https://github.com/lbou55/smart-classroom/blob/main/static/js/admin.js) (Admin controls), [`static/js/dashboard.js`](https://github.com/lbou55/smart-classroom/blob/main/static/js/dashboard.js) (Live dashboard), [`static/js/stat.js`](https://github.com/lbou55/smart-classroom/blob/main/static/js/stat.js) (Historical statistics)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_field["Sensing and control"]
  node_esp32["ESP32 sensors<br/>[sketch_mar30a.ino]"]
  node_simulator["Sensor simulator"]
  node_ac["AC relay<br/>[sketch_mar30a.ino]"]
end

subgraph group_server["Backend services"]
  node_flask["Flask API<br/>[app.py]"]
  node_prediction["Temperature prediction<br/>[app.py]"]
  node_auth["Sessions and accounts<br/>[app.py]"]
end

subgraph group_web["Web application"]
  node_admin["Admin controls<br/>[admin.js]"]
  node_dashboard["Live dashboard<br/>[dashboard.js]"]
  node_statistics["Historical statistics<br/>[stat.js]"]
  node_chat["Private chat<br/>[chat.js]"]
  node_conversation_viewer["Admin conversations"]
  node_profile["User profile<br/>[profile.js]"]
  node_signup["Signup<br/>[signup.js]"]
  node_settings["User management<br/>[Settings.js]"]
  node_localization["Themes and translation<br/>[lang.js]"]
  node_blueprints["Blueprint downloads<br/>[blueprints.html]"]
end

subgraph group_data["Persistence and prediction"]
  node_firebase[("Firebase Realtime DB")]
  node_model["Trained regression model"]
end

node_teacher(("Classroom users"))

node_teacher -->|"views live data"| node_dashboard
node_esp32 -->|"posts sensor data"| node_flask
node_simulator -->|"posts readings"| node_flask
node_flask -->|"predicts temperature"| node_prediction
node_prediction -->|"uses model"| node_model
node_flask -->|"synchronizes state"| node_firebase
node_flask -.->|"controls AC"| node_ac
node_dashboard -->|"fetches latest readings"| node_flask
node_teacher -->|"consults history"| node_statistics
node_statistics -.->|"reads sensor history"| node_firebase
node_teacher -->|"exchanges messages"| node_chat
node_chat -->|"reads and writes chats"| node_firebase
node_admin -.->|"manages AC settings"| node_firebase
node_admin -.->|"sets AC mode"| node_ac
node_conversation_viewer -->|"reads conversations"| node_firebase
node_profile -->|"updates profile"| node_firebase
node_signup -.->|"registers account"| node_auth
node_settings -->|"manages users"| node_firebase
node_teacher -->|"edits profile"| node_profile
node_teacher -->|"downloads plans"| node_blueprints
node_teacher -->|"selects language or theme"| node_localization

click node_esp32 "https://github.com/lbou55/smart-classroom/blob/main/sketch_mar30a.ino"
click node_simulator "https://github.com/lbou55/smart-classroom/blob/main/simulate_sensors.py"
click node_ac "https://github.com/lbou55/smart-classroom/blob/main/sketch_mar30a.ino"
click node_flask "https://github.com/lbou55/smart-classroom/blob/main/app.py"
click node_prediction "https://github.com/lbou55/smart-classroom/blob/main/app.py"
click node_auth "https://github.com/lbou55/smart-classroom/blob/main/app.py"
click node_admin "https://github.com/lbou55/smart-classroom/blob/main/static/js/admin.js"
click node_dashboard "https://github.com/lbou55/smart-classroom/blob/main/static/js/dashboard.js"
click node_statistics "https://github.com/lbou55/smart-classroom/blob/main/static/js/stat.js"
click node_chat "https://github.com/lbou55/smart-classroom/blob/main/static/js/chat.js"
click node_conversation_viewer "https://github.com/lbou55/smart-classroom/blob/main/static/js/admin_conversations.js"
click node_profile "https://github.com/lbou55/smart-classroom/blob/main/static/js/profile.js"
click node_signup "https://github.com/lbou55/smart-classroom/blob/main/static/js/signup.js"
click node_settings "https://github.com/lbou55/smart-classroom/blob/main/static/js/Settings.js"
click node_localization "https://github.com/lbou55/smart-classroom/blob/main/static/js/lang.js"
click node_blueprints "https://github.com/lbou55/smart-classroom/blob/main/templates/blueprints.html"
click node_model "https://github.com/lbou55/smart-classroom/blob/main/temperature_model.pkl"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_esp32,node_simulator,node_ac,node_teacher toneBlue
class node_flask,node_prediction,node_auth toneAmber
class node_admin,node_dashboard,node_statistics,node_chat,node_conversation_viewer,node_profile,node_signup,node_settings,node_localization,node_blueprints toneMint
class node_firebase,node_model toneRose
```

## Components

### Sensing and control

- [ESP32 sensors](https://github.com/lbou55/smart-classroom/blob/main/sketch_mar30a.ino): `sketch_mar30a.ino`
- [Sensor simulator](https://github.com/lbou55/smart-classroom/blob/main/simulate_sensors.py): `simulate_sensors.py`
- [AC relay](https://github.com/lbou55/smart-classroom/blob/main/sketch_mar30a.ino): `sketch_mar30a.ino`

### Backend services

- [Flask API](https://github.com/lbou55/smart-classroom/blob/main/app.py): `app.py`
- [Temperature prediction](https://github.com/lbou55/smart-classroom/blob/main/app.py): `app.py`
- [Sessions and accounts](https://github.com/lbou55/smart-classroom/blob/main/app.py): `app.py`

### Web application

- [Admin controls](https://github.com/lbou55/smart-classroom/blob/main/static/js/admin.js): `static/js/admin.js`
- [Live dashboard](https://github.com/lbou55/smart-classroom/blob/main/static/js/dashboard.js): `static/js/dashboard.js`
- [Historical statistics](https://github.com/lbou55/smart-classroom/blob/main/static/js/stat.js): `static/js/stat.js`
- [Private chat](https://github.com/lbou55/smart-classroom/blob/main/static/js/chat.js): `static/js/chat.js`
- [Admin conversations](https://github.com/lbou55/smart-classroom/blob/main/static/js/admin_conversations.js): `static/js/admin_conversations.js`
- [User profile](https://github.com/lbou55/smart-classroom/blob/main/static/js/profile.js): `static/js/profile.js`
- [Signup](https://github.com/lbou55/smart-classroom/blob/main/static/js/signup.js): `static/js/signup.js`
- [User management](https://github.com/lbou55/smart-classroom/blob/main/static/js/Settings.js): `static/js/Settings.js`
- [Themes and translation](https://github.com/lbou55/smart-classroom/blob/main/static/js/lang.js): `static/js/lang.js`
- [Blueprint downloads](https://github.com/lbou55/smart-classroom/blob/main/templates/blueprints.html): `templates/blueprints.html`

### Persistence and prediction

- **Firebase Realtime DB**
- [Trained regression model](https://github.com/lbou55/smart-classroom/blob/main/temperature_model.pkl): `temperature_model.pkl`

### Other components

- **Classroom users**

## Connections

- Classroom users → Live dashboard: views live data (evidence: `README.md`)
- ESP32 sensors → Flask API: posts sensor data (evidence: `README.md`)
- Sensor simulator → Flask API: posts readings (evidence: `simulate_sensors.py`)
- Flask API → Temperature prediction: predicts temperature (evidence: `README.md`)
- Temperature prediction → Trained regression model: uses model (evidence: `README.md`)
- Flask API → Firebase Realtime DB: synchronizes state (evidence: `README.md`)
- Flask API → AC relay: controls AC
- Live dashboard → Flask API: fetches latest readings (evidence: `static/js/dashboard.js`)
- Classroom users → Historical statistics: consults history (evidence: `README.md`)
- Historical statistics → Firebase Realtime DB: reads sensor history
- Classroom users → Private chat: exchanges messages (evidence: `README.md`)
- Private chat → Firebase Realtime DB: reads and writes chats (evidence: `static/js/chat.js`)
- Admin controls → Firebase Realtime DB: manages AC settings
- Admin controls → AC relay: sets AC mode
- Admin conversations → Firebase Realtime DB: reads conversations (evidence: `static/js/admin_conversations.js`)
- User profile → Firebase Realtime DB: updates profile (evidence: `static/js/profile.js`)
- Signup → Sessions and accounts: registers account
- User management → Firebase Realtime DB: manages users (evidence: `static/js/Settings.js`)
- Classroom users → User profile: edits profile (evidence: `README.md`)
- Classroom users → Blueprint downloads: downloads plans (evidence: `README.md`)
- Classroom users → Themes and translation: selects language or theme (evidence: `README.md`)
