# enzofernandezz11/software-quality-0x43 architecture

> Architecture diagram of the GitHub repository enzofernandezz11/software-quality-0x43, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-18). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/enzofernandezz11/software-quality-0x43
- Repository: https://github.com/enzofernandezz11/software-quality-0x43

## Overview

This is an end-to-end IoT room-monitoring and access-control system: ESP32 firmware samples sensors and accepts keypad PINs, a Flask API processes telemetry and authentication, PostgreSQL-backed repositories retain readings and audits, and a Next.js dashboard presents live status, history, security logs, and room settings. The central workflow runs from device sampling through HTTP submission and backend persistence to dashboard polling. The graph also preserves authentication and configuration branches. Some routes and UI wiring are unsampled, so uncertain connections are omitted or marked unverified.

Main entry points: [`firmware/esp32/src/network/networkClient.cpp`](https://github.com/enzofernandezz11/software-quality-0x43/blob/main/firmware/esp32/src/network/networkClient.cpp) (Network client), [`backend/flask/final_project/app/controllers/dashboard_controller.py`](https://github.com/enzofernandezz11/software-quality-0x43/blob/main/backend/flask/final_project/app/controllers/dashboard_controller.py) (Dashboard API), [`frontend/dashboard/src/services/sensors.service.ts`](https://github.com/enzofernandezz11/software-quality-0x43/blob/main/frontend/dashboard/src/services/sensors.service.ts) (API service), [`firmware/esp32/src/main.cpp`](https://github.com/enzofernandezz11/software-quality-0x43/blob/main/firmware/esp32/src/main.cpp) (Device loop)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_device["ESP32 firmware"]
  node_esp_loop["Device loop<br/>[main.cpp]"]
  node_device_config["Device config<br/>[appConfig.hpp]"]
  node_sensor_service["Sensor acquisition<br/>[sensorService.cpp]"]
  node_sensor_types["Reading types<br/>[sensorTypes.hpp]"]
  node_network_client["Network client<br/>[networkClient.cpp]"]
  node_network_types["Network types<br/>[networkTypes.hpp]"]
end

subgraph group_api["Flask backend"]
  node_api_entry["Flask app<br/>[__init__.py]"]
  node_telemetry_api["Telemetry API"]
  node_dashboard_api["Dashboard API"]
  node_auth_api["Authentication API<br/>[auth_controller.py]"]
  node_config_api["Room config API"]
  node_processing["Telemetry processing"]
  node_auth_service["Authentication service<br/>[auth_service.py]"]
  node_auth_strategy["Auth strategies<br/>[auth_strategies.py]"]
  node_sensor_service_backend["Sensor service<br/>[sensors_service.py]"]
end

subgraph group_data["Persistence and domain"]
  node_db_extension["Database extension<br/>[extensions.py]"]
  node_sensor_repo["Sensor repository"]
  node_config_repo["Config repository"]
  node_auth_repo["Audit repository<br/>[auth_repository.py]"]
  node_entities["Domain entities"]
end

subgraph group_web["Dashboard"]
  node_dashboard_client["Dashboard client"]
  node_sensor_polling["Sensor polling"]
  node_api_service["API service<br/>[sensors.service.ts]"]
  node_sensor_types_web["Dashboard types<br/>[sensor.types.ts]"]
  node_history_view["History view<br/>[page.tsx]"]
  node_settings_view["Settings view<br/>[page.tsx]"]
  node_access_monitor["Access monitoring"]
  node_access_widgets["Access notifications"]
end

node_room_user(("Room user"))
node_postgres[("PostgreSQL")]

node_room_user -->|"enters PIN"| node_esp_loop
node_esp_loop -->|"polls and reads"| node_sensor_service
node_esp_loop -->|"submits telemetry"| node_network_client
node_esp_loop -->|"validates PIN"| node_network_client
node_esp_loop -->|"uses config"| node_device_config
node_sensor_service -->|"produces readings"| node_sensor_types
node_network_client -->|"serializes readings"| node_sensor_types
node_network_client -->|"uses types"| node_network_types
node_network_client -->|"uses config"| node_device_config
node_network_client -.->|"posts telemetry"| node_telemetry_api
node_network_client -.->|"sends PIN"| node_auth_api
node_api_entry -->|"registers routes"| node_telemetry_api
node_api_entry -->|"registers routes"| node_dashboard_api
node_api_entry -->|"registers routes"| node_auth_api
node_api_entry -->|"registers routes"| node_config_api
node_dashboard_api -->|"queries readings"| node_sensor_repo
node_dashboard_api -->|"loads config"| node_config_repo
node_dashboard_api -->|"calculates baseline"| node_processing
node_dashboard_api -->|"loads audit logs"| node_auth_repo
node_auth_api -->|"authenticates PIN"| node_auth_service
node_auth_api -->|"updates room mode"| node_config_repo
node_auth_service -->|"delegates validation"| node_auth_strategy
node_auth_service -->|"records audit"| node_entities
node_sensor_service_backend -->|"uses repository"| node_sensor_repo
node_sensor_repo -->|"uses session"| node_db_extension
node_config_repo -->|"uses session"| node_db_extension
node_auth_repo -->|"uses session"| node_db_extension
node_sensor_repo -->|"queries readings"| node_entities
node_config_repo -->|"queries config"| node_entities
node_auth_repo -->|"queries audits"| node_entities
node_db_extension -.->|"persists data"| node_postgres
node_dashboard_client -.->|"uses polling"| node_sensor_polling
node_sensor_polling -->|"fetches metrics"| node_api_service
node_api_service -->|"uses response types"| node_sensor_types_web
node_api_service -.->|"requests dashboard data"| node_dashboard_api
node_history_view -.->|"loads history"| node_api_service
node_settings_view -.->|"reads config"| node_api_service
node_access_monitor -.->|"loads audits"| node_api_service
node_access_widgets -.->|"displays events"| node_access_monitor

click node_esp_loop "https://github.com/enzofernandezz11/software-quality-0x43/blob/main/firmware/esp32/src/main.cpp"
click node_device_config "https://github.com/enzofernandezz11/software-quality-0x43/blob/main/firmware/esp32/include/appConfig.hpp"
click node_sensor_service "https://github.com/enzofernandezz11/software-quality-0x43/blob/main/firmware/esp32/src/sensors/sensorService.cpp"
click node_sensor_types "https://github.com/enzofernandezz11/software-quality-0x43/blob/main/firmware/esp32/include/sensors/sensorTypes.hpp"
click node_network_client "https://github.com/enzofernandezz11/software-quality-0x43/blob/main/firmware/esp32/src/network/networkClient.cpp"
click node_network_types "https://github.com/enzofernandezz11/software-quality-0x43/blob/main/firmware/esp32/include/network/networkTypes.hpp"
click node_api_entry "https://github.com/enzofernandezz11/software-quality-0x43/blob/main/backend/flask/final_project/app/__init__.py"
click node_telemetry_api "https://github.com/enzofernandezz11/software-quality-0x43/blob/main/backend/flask/final_project/app/controllers/telemetry_controller.py"
click node_dashboard_api "https://github.com/enzofernandezz11/software-quality-0x43/blob/main/backend/flask/final_project/app/controllers/dashboard_controller.py"
click node_auth_api "https://github.com/enzofernandezz11/software-quality-0x43/blob/main/backend/flask/final_project/app/controllers/auth_controller.py"
click node_config_api "https://github.com/enzofernandezz11/software-quality-0x43/blob/main/backend/flask/final_project/app/controllers/config_controller.py"
click node_processing "https://github.com/enzofernandezz11/software-quality-0x43/blob/main/backend/flask/final_project/app/services/processing_service.py"
click node_auth_service "https://github.com/enzofernandezz11/software-quality-0x43/blob/main/backend/flask/final_project/app/services/auth_service.py"
click node_auth_strategy "https://github.com/enzofernandezz11/software-quality-0x43/blob/main/backend/flask/final_project/app/services/auth_strategies.py"
click node_sensor_service_backend "https://github.com/enzofernandezz11/software-quality-0x43/blob/main/backend/flask/final_project/app/services/sensors_service.py"
click node_db_extension "https://github.com/enzofernandezz11/software-quality-0x43/blob/main/backend/flask/final_project/app/extensions.py"
click node_sensor_repo "https://github.com/enzofernandezz11/software-quality-0x43/blob/main/backend/flask/final_project/app/repositories/sensors_repository.py"
click node_config_repo "https://github.com/enzofernandezz11/software-quality-0x43/blob/main/backend/flask/final_project/app/repositories/config_repository.py"
click node_auth_repo "https://github.com/enzofernandezz11/software-quality-0x43/blob/main/backend/flask/final_project/app/repositories/auth_repository.py"
click node_entities "https://github.com/enzofernandezz11/software-quality-0x43/tree/main/backend/flask/final_project/app/models/entities"
click node_dashboard_client "https://github.com/enzofernandezz11/software-quality-0x43/blob/main/frontend/dashboard/src/components/DashboardClient.tsx"
click node_sensor_polling "https://github.com/enzofernandezz11/software-quality-0x43/blob/main/frontend/dashboard/src/hooks/useSensorPolling.ts"
click node_api_service "https://github.com/enzofernandezz11/software-quality-0x43/blob/main/frontend/dashboard/src/services/sensors.service.ts"
click node_sensor_types_web "https://github.com/enzofernandezz11/software-quality-0x43/blob/main/frontend/dashboard/src/types/sensor.types.ts"
click node_history_view "https://github.com/enzofernandezz11/software-quality-0x43/blob/main/frontend/dashboard/src/app/history/page.tsx"
click node_settings_view "https://github.com/enzofernandezz11/software-quality-0x43/blob/main/frontend/dashboard/src/app/settings/page.tsx"
click node_access_monitor "https://github.com/enzofernandezz11/software-quality-0x43/blob/main/frontend/dashboard/src/hooks/useAccessMonitoring.ts"
click node_access_widgets "https://github.com/enzofernandezz11/software-quality-0x43/blob/main/frontend/dashboard/src/components/widgets/AccessNotifications.tsx"

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_esp_loop,node_device_config,node_sensor_service,node_sensor_types,node_network_client,node_network_types,node_room_user toneBlue
class node_api_entry,node_telemetry_api,node_dashboard_api,node_auth_api,node_config_api,node_processing,node_auth_service,node_auth_strategy,node_sensor_service_backend,node_postgres toneAmber
class node_db_extension,node_sensor_repo,node_config_repo,node_auth_repo,node_entities toneMint
class node_dashboard_client,node_sensor_polling,node_api_service,node_sensor_types_web,node_history_view,node_settings_view,node_access_monitor,node_access_widgets toneRose
```

## Components

### ESP32 firmware

- [Device loop](https://github.com/enzofernandezz11/software-quality-0x43/blob/main/firmware/esp32/src/main.cpp): `firmware/esp32/src/main.cpp`
- [Device config](https://github.com/enzofernandezz11/software-quality-0x43/blob/main/firmware/esp32/include/appConfig.hpp): `firmware/esp32/include/appConfig.hpp`
- [Sensor acquisition](https://github.com/enzofernandezz11/software-quality-0x43/blob/main/firmware/esp32/src/sensors/sensorService.cpp): `firmware/esp32/src/sensors/sensorService.cpp`
- [Reading types](https://github.com/enzofernandezz11/software-quality-0x43/blob/main/firmware/esp32/include/sensors/sensorTypes.hpp): `firmware/esp32/include/sensors/sensorTypes.hpp`
- [Network client](https://github.com/enzofernandezz11/software-quality-0x43/blob/main/firmware/esp32/src/network/networkClient.cpp): `firmware/esp32/src/network/networkClient.cpp`
- [Network types](https://github.com/enzofernandezz11/software-quality-0x43/blob/main/firmware/esp32/include/network/networkTypes.hpp): `firmware/esp32/include/network/networkTypes.hpp`

### Flask backend

- [Flask app](https://github.com/enzofernandezz11/software-quality-0x43/blob/main/backend/flask/final_project/app/__init__.py): `backend/flask/final_project/app/__init__.py`
- [Telemetry API](https://github.com/enzofernandezz11/software-quality-0x43/blob/main/backend/flask/final_project/app/controllers/telemetry_controller.py): `backend/flask/final_project/app/controllers/telemetry_controller.py`
- [Dashboard API](https://github.com/enzofernandezz11/software-quality-0x43/blob/main/backend/flask/final_project/app/controllers/dashboard_controller.py): `backend/flask/final_project/app/controllers/dashboard_controller.py`
- [Authentication API](https://github.com/enzofernandezz11/software-quality-0x43/blob/main/backend/flask/final_project/app/controllers/auth_controller.py): `backend/flask/final_project/app/controllers/auth_controller.py`
- [Room config API](https://github.com/enzofernandezz11/software-quality-0x43/blob/main/backend/flask/final_project/app/controllers/config_controller.py): `backend/flask/final_project/app/controllers/config_controller.py`
- [Telemetry processing](https://github.com/enzofernandezz11/software-quality-0x43/blob/main/backend/flask/final_project/app/services/processing_service.py): `backend/flask/final_project/app/services/processing_service.py`
- [Authentication service](https://github.com/enzofernandezz11/software-quality-0x43/blob/main/backend/flask/final_project/app/services/auth_service.py): `backend/flask/final_project/app/services/auth_service.py`
- [Auth strategies](https://github.com/enzofernandezz11/software-quality-0x43/blob/main/backend/flask/final_project/app/services/auth_strategies.py): `backend/flask/final_project/app/services/auth_strategies.py`
- [Sensor service](https://github.com/enzofernandezz11/software-quality-0x43/blob/main/backend/flask/final_project/app/services/sensors_service.py): `backend/flask/final_project/app/services/sensors_service.py`

### Persistence and domain

- [Database extension](https://github.com/enzofernandezz11/software-quality-0x43/blob/main/backend/flask/final_project/app/extensions.py): `backend/flask/final_project/app/extensions.py`
- [Sensor repository](https://github.com/enzofernandezz11/software-quality-0x43/blob/main/backend/flask/final_project/app/repositories/sensors_repository.py): `backend/flask/final_project/app/repositories/sensors_repository.py`
- [Config repository](https://github.com/enzofernandezz11/software-quality-0x43/blob/main/backend/flask/final_project/app/repositories/config_repository.py): `backend/flask/final_project/app/repositories/config_repository.py`
- [Audit repository](https://github.com/enzofernandezz11/software-quality-0x43/blob/main/backend/flask/final_project/app/repositories/auth_repository.py): `backend/flask/final_project/app/repositories/auth_repository.py`
- [Domain entities](https://github.com/enzofernandezz11/software-quality-0x43/tree/main/backend/flask/final_project/app/models/entities): `backend/flask/final_project/app/models/entities`

### Dashboard

- [Dashboard client](https://github.com/enzofernandezz11/software-quality-0x43/blob/main/frontend/dashboard/src/components/DashboardClient.tsx): `frontend/dashboard/src/components/DashboardClient.tsx`
- [Sensor polling](https://github.com/enzofernandezz11/software-quality-0x43/blob/main/frontend/dashboard/src/hooks/useSensorPolling.ts): `frontend/dashboard/src/hooks/useSensorPolling.ts`
- [API service](https://github.com/enzofernandezz11/software-quality-0x43/blob/main/frontend/dashboard/src/services/sensors.service.ts): `frontend/dashboard/src/services/sensors.service.ts`
- [Dashboard types](https://github.com/enzofernandezz11/software-quality-0x43/blob/main/frontend/dashboard/src/types/sensor.types.ts): `frontend/dashboard/src/types/sensor.types.ts`
- [History view](https://github.com/enzofernandezz11/software-quality-0x43/blob/main/frontend/dashboard/src/app/history/page.tsx): `frontend/dashboard/src/app/history/page.tsx`
- [Settings view](https://github.com/enzofernandezz11/software-quality-0x43/blob/main/frontend/dashboard/src/app/settings/page.tsx): `frontend/dashboard/src/app/settings/page.tsx`
- [Access monitoring](https://github.com/enzofernandezz11/software-quality-0x43/blob/main/frontend/dashboard/src/hooks/useAccessMonitoring.ts): `frontend/dashboard/src/hooks/useAccessMonitoring.ts`
- [Access notifications](https://github.com/enzofernandezz11/software-quality-0x43/blob/main/frontend/dashboard/src/components/widgets/AccessNotifications.tsx): `frontend/dashboard/src/components/widgets/AccessNotifications.tsx`

### Other components

- **Room user**
- **PostgreSQL**

## Connections

- Room user → Device loop: enters PIN (evidence: `firmware/esp32/src/main.cpp`)
- Device loop → Sensor acquisition: polls and reads (evidence: `firmware/esp32/src/main.cpp`)
- Device loop → Network client: submits telemetry (evidence: `firmware/esp32/src/main.cpp`)
- Device loop → Network client: validates PIN (evidence: `firmware/esp32/src/main.cpp`)
- Device loop → Device config: uses config (evidence: `firmware/esp32/src/main.cpp`)
- Sensor acquisition → Reading types: produces readings
- Network client → Reading types: serializes readings
- Network client → Network types: uses types
- Network client → Device config: uses config
- Network client → Telemetry API: posts telemetry
- Network client → Authentication API: sends PIN
- Flask app → Telemetry API: registers routes (evidence: `backend/flask/final_project/app/__init__.py`)
- Flask app → Dashboard API: registers routes (evidence: `backend/flask/final_project/app/__init__.py`)
- Flask app → Authentication API: registers routes (evidence: `backend/flask/final_project/app/__init__.py`)
- Flask app → Room config API: registers routes (evidence: `backend/flask/final_project/app/__init__.py`)
- Dashboard API → Sensor repository: queries readings (evidence: `backend/flask/final_project/app/controllers/dashboard_controller.py`)
- Dashboard API → Config repository: loads config (evidence: `backend/flask/final_project/app/controllers/dashboard_controller.py`)
- Dashboard API → Telemetry processing: calculates baseline (evidence: `backend/flask/final_project/app/controllers/dashboard_controller.py`)
- Dashboard API → Audit repository: loads audit logs (evidence: `backend/flask/final_project/app/controllers/dashboard_controller.py`)
- Authentication API → Authentication service: authenticates PIN (evidence: `backend/flask/final_project/app/controllers/auth_controller.py`)
- Authentication API → Config repository: updates room mode (evidence: `backend/flask/final_project/app/controllers/auth_controller.py`)
- Authentication service → Auth strategies: delegates validation (evidence: `backend/flask/final_project/app/services/auth_service.py`)
- Authentication service → Domain entities: records audit (evidence: `backend/flask/final_project/app/services/auth_service.py`)
- Sensor service → Sensor repository: uses repository (evidence: `backend/flask/final_project/app/services/sensors_service.py`)
- Sensor repository → Database extension: uses session (evidence: `backend/flask/final_project/app/repositories/sensors_repository.py`)
- Config repository → Database extension: uses session (evidence: `backend/flask/final_project/app/repositories/config_repository.py`)
- Audit repository → Database extension: uses session (evidence: `backend/flask/final_project/app/repositories/auth_repository.py`)
- Sensor repository → Domain entities: queries readings (evidence: `backend/flask/final_project/app/repositories/sensors_repository.py`)
- Config repository → Domain entities: queries config (evidence: `backend/flask/final_project/app/repositories/config_repository.py`)
- Audit repository → Domain entities: queries audits (evidence: `backend/flask/final_project/app/repositories/auth_repository.py`)
- Database extension → PostgreSQL: persists data
- Dashboard client → Sensor polling: uses polling
- Sensor polling → API service: fetches metrics (evidence: `frontend/dashboard/src/hooks/useSensorPolling.ts`)
- API service → Dashboard types: uses response types (evidence: `frontend/dashboard/src/services/sensors.service.ts`)
- API service → Dashboard API: requests dashboard data
- History view → API service: loads history
- Settings view → API service: reads config
- Access monitoring → API service: loads audits
- Access notifications → Access monitoring: displays events
