# mustafasedhom/smart-predictive-unit-spu- architecture

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

- Interactive diagram: https://gitdiagram.com/mustafasedhom/smart-predictive-unit-spu-
- Repository: https://github.com/mustafasedhom/smart-predictive-unit-spu-

## Overview

SPU is an industrial equipment monitoring system: sensor firmware samples motor, pump, belt and overall signals, then sends JSON for a Python service to process, persist, analyze and expose to an app. The tree and excerpts support the sensor, ingestion, database and AI branches; the README’s screen images indicate app capabilities, but Flutter application logic is not present in the supplied source excerpts. Some subsystem links are therefore omitted where their runtime caller is not shown.

Main entry points: [`code_of_project/Background_Process_Code/AI_Brain_Of_Project/AI_Main_module.py`](https://github.com/mustafasedhom/smart-predictive-unit-spu-/blob/Master/code_of_project/Background_Process_Code/AI_Brain_Of_Project/AI_Main_module.py) (AI runtime), [`code_of_project/Background_Process_Code/Handle_Data_Base_Code/Data_Base_Python/Data_Base_Manger/Data_Base_Manager.py`](https://github.com/mustafasedhom/smart-predictive-unit-spu-/blob/Master/code_of_project/Background_Process_Code/Handle_Data_Base_Code/Data_Base_Python/Data_Base_Manger/Data_Base_Manager.py) (Database manager), [`code_of_project/Background_Process_Code/Handle_Data_Base_Code/Data_Base_Python/SPU_main_Data_handlig.py`](https://github.com/mustafasedhom/smart-predictive-unit-spu-/blob/Master/code_of_project/Background_Process_Code/Handle_Data_Base_Code/Data_Base_Python/SPU_main_Data_handlig.py) (Database access), [`code_of_project/SPU_Sensors_and_Esp32_code/Sensors Code/src/main.cpp`](https://github.com/mustafasedhom/smart-predictive-unit-spu-/blob/Master/code_of_project/SPU_Sensors_and_Esp32_code/Sensors%20Code/src/main.cpp) (Sensor firmware)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_field["Sensing and ingestion"]
  node_firmware["Sensor firmware<br/>[main.cpp]"]
  node_uart["UART reader"]
  node_parser["Sensor JSON parser"]
  node_processing["Sensor processing"]
end

subgraph group_backend["Data backend"]
  node_dbaccess["Database access"]
  node_dbmanager["Database manager"]
  node_settings["Equipment settings"]
  node_jsonstore[("JSON database files")]
  node_csvstore[("Historical data files")]
  node_directstore["Direct data storage"]
end

subgraph group_ai["AI analysis"]
  node_runtime["AI runtime<br/>[AI_Main_module.py]"]
  node_analysis["Analysis dispatcher<br/>[Analysis_Data.py]"]
  node_actuatoranalysis["Actuator health analysis"]
  node_faultprediction["Fault prediction"]
  node_alarms["Alarm analysis"]
end

subgraph group_product["App and alerts"]
  node_email["Email notifications<br/>[Gmail_Massage.py]"]
  node_app["Monitoring app"]
end

node_hardware(("Sensors and actuators"))
node_operator(("Operator"))

node_hardware -.->|"provides readings"| node_firmware
node_firmware -.->|"sends JSON"| node_uart
node_runtime -->|"reads UART"| node_uart
node_runtime -->|"parses readings"| node_parser
node_runtime -->|"processes readings"| node_processing
node_parser -->|"builds sensor data"| node_processing
node_runtime -->|"updates database"| node_dbaccess
node_dbaccess -->|"creates manager"| node_dbmanager
node_dbmanager -->|"loads JSON"| node_jsonstore
node_dbmanager -->|"initializes settings"| node_settings
node_runtime -->|"stores readings"| node_directstore
node_directstore -->|"writes history"| node_csvstore
node_runtime -->|"runs analysis"| node_analysis
node_analysis -.->|"dispatches analysis"| node_actuatoranalysis
node_actuatoranalysis -->|"calculates faults"| node_faultprediction
node_runtime -->|"sends notices"| node_email
node_operator -.->|"views status"| node_app
node_alarms -.->|"notifies"| node_email
node_app -.->|"accesses status"| node_dbaccess

click node_firmware "https://github.com/mustafasedhom/smart-predictive-unit-spu-/blob/Master/code_of_project/SPU_Sensors_and_Esp32_code/Sensors%20Code/src/main.cpp"
click node_uart "https://github.com/mustafasedhom/smart-predictive-unit-spu-/blob/Master/code_of_project/Background_Process_Code/Handle_Data_Base_Code/Recieve_Data_from_Slave_Board/Recieve_Data_From_Slave_Board.py"
click node_parser "https://github.com/mustafasedhom/smart-predictive-unit-spu-/blob/Master/code_of_project/Background_Process_Code/Handle_Data_Base_Code/Rrocess_Data_From_Slave_Board/All_Sensor_Data_After_Processing/All_Sensor_Data_After_Processing.py"
click node_processing "https://github.com/mustafasedhom/smart-predictive-unit-spu-/tree/Master/code_of_project/Background_Process_Code/Handle_Data_Base_Code/Rrocess_Data_From_Slave_Board"
click node_runtime "https://github.com/mustafasedhom/smart-predictive-unit-spu-/blob/Master/code_of_project/Background_Process_Code/AI_Brain_Of_Project/AI_Main_module.py"
click node_analysis "https://github.com/mustafasedhom/smart-predictive-unit-spu-/blob/Master/code_of_project/Background_Process_Code/AI_Brain_Of_Project/AI_Analysis_Actuator_Data/Analysis_Data.py"
click node_actuatoranalysis "https://github.com/mustafasedhom/smart-predictive-unit-spu-/tree/Master/code_of_project/Background_Process_Code/AI_Brain_Of_Project/AI_Analysis_Actuator_Data/Actuator_Analysis"
click node_faultprediction "https://github.com/mustafasedhom/smart-predictive-unit-spu-/blob/Master/code_of_project/Background_Process_Code/AI_Brain_Of_Project/AI_Analysis_Actuator_Data/Actuator_Analysis/calc_predicated_fault_of_actuator/calc_predicated_fault_of_actuator.py"
click node_alarms "https://github.com/mustafasedhom/smart-predictive-unit-spu-/tree/Master/code_of_project/Background_Process_Code/AI_Brain_Of_Project/AI_Analysis_Actuator_Data/Alarm_Analysis"
click node_email "https://github.com/mustafasedhom/smart-predictive-unit-spu-/blob/Master/code_of_project/Background_Process_Code/AI_Brain_Of_Project/AI_Analysis_Actuator_Data/Alarm_Analysis/Send_Notification/Gmail_Massage.py"
click node_dbaccess "https://github.com/mustafasedhom/smart-predictive-unit-spu-/blob/Master/code_of_project/Background_Process_Code/Handle_Data_Base_Code/Data_Base_Python/SPU_main_Data_handlig.py"
click node_dbmanager "https://github.com/mustafasedhom/smart-predictive-unit-spu-/blob/Master/code_of_project/Background_Process_Code/Handle_Data_Base_Code/Data_Base_Python/Data_Base_Manger/Data_Base_Manager.py"
click node_settings "https://github.com/mustafasedhom/smart-predictive-unit-spu-/blob/Master/code_of_project/Background_Process_Code/Handle_Data_Base_Code/Data_Base_Python/Setting_Data/Min_Normal_Max_Values.py"
click node_csvstore "https://github.com/mustafasedhom/smart-predictive-unit-spu-/blob/Master/code_of_project/Background_Process_Code/AI_Brain_Of_Project/AI_Store_and_Read_process_Data/AI_Store_Process_Data.py"
click node_directstore "https://github.com/mustafasedhom/smart-predictive-unit-spu-/blob/Master/code_of_project/Background_Process_Code/AI_Brain_Of_Project/AI_Store_Data_directly/AI_Store_Data_directly.py"
click node_app "https://github.com/mustafasedhom/smart-predictive-unit-spu-/tree/Master/code_of_project/SPU_Flutter_app_code/spu_linux_app"

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_firmware,node_uart,node_parser,node_processing toneBlue
class node_dbaccess,node_dbmanager,node_settings,node_jsonstore,node_csvstore,node_directstore toneAmber
class node_runtime,node_analysis,node_actuatoranalysis,node_faultprediction,node_alarms toneMint
class node_email,node_app toneRose
class node_hardware,node_operator toneIndigo
```

## Components

### Sensing and ingestion

- [Sensor firmware](https://github.com/mustafasedhom/smart-predictive-unit-spu-/blob/Master/code_of_project/SPU_Sensors_and_Esp32_code/Sensors%20Code/src/main.cpp): `code_of_project/SPU_Sensors_and_Esp32_code/Sensors Code/src/main.cpp`
- [UART reader](https://github.com/mustafasedhom/smart-predictive-unit-spu-/blob/Master/code_of_project/Background_Process_Code/Handle_Data_Base_Code/Recieve_Data_from_Slave_Board/Recieve_Data_From_Slave_Board.py): `code_of_project/Background_Process_Code/Handle_Data_Base_Code/Recieve_Data_from_Slave_Board/Recieve_Data_From_Slave_Board.py`
- [Sensor JSON parser](https://github.com/mustafasedhom/smart-predictive-unit-spu-/blob/Master/code_of_project/Background_Process_Code/Handle_Data_Base_Code/Rrocess_Data_From_Slave_Board/All_Sensor_Data_After_Processing/All_Sensor_Data_After_Processing.py): `code_of_project/Background_Process_Code/Handle_Data_Base_Code/Rrocess_Data_From_Slave_Board/All_Sensor_Data_After_Processing/All_Sensor_Data_After_Processing.py`
- [Sensor processing](https://github.com/mustafasedhom/smart-predictive-unit-spu-/tree/Master/code_of_project/Background_Process_Code/Handle_Data_Base_Code/Rrocess_Data_From_Slave_Board): `code_of_project/Background_Process_Code/Handle_Data_Base_Code/Rrocess_Data_From_Slave_Board`

### Data backend

- [Database access](https://github.com/mustafasedhom/smart-predictive-unit-spu-/blob/Master/code_of_project/Background_Process_Code/Handle_Data_Base_Code/Data_Base_Python/SPU_main_Data_handlig.py): `code_of_project/Background_Process_Code/Handle_Data_Base_Code/Data_Base_Python/SPU_main_Data_handlig.py`
- [Database manager](https://github.com/mustafasedhom/smart-predictive-unit-spu-/blob/Master/code_of_project/Background_Process_Code/Handle_Data_Base_Code/Data_Base_Python/Data_Base_Manger/Data_Base_Manager.py): `code_of_project/Background_Process_Code/Handle_Data_Base_Code/Data_Base_Python/Data_Base_Manger/Data_Base_Manager.py`
- [Equipment settings](https://github.com/mustafasedhom/smart-predictive-unit-spu-/blob/Master/code_of_project/Background_Process_Code/Handle_Data_Base_Code/Data_Base_Python/Setting_Data/Min_Normal_Max_Values.py): `code_of_project/Background_Process_Code/Handle_Data_Base_Code/Data_Base_Python/Setting_Data/Min_Normal_Max_Values.py`
- **JSON database files**
- [Historical data files](https://github.com/mustafasedhom/smart-predictive-unit-spu-/blob/Master/code_of_project/Background_Process_Code/AI_Brain_Of_Project/AI_Store_and_Read_process_Data/AI_Store_Process_Data.py): `code_of_project/Background_Process_Code/AI_Brain_Of_Project/AI_Store_and_Read_process_Data/AI_Store_Process_Data.py`
- [Direct data storage](https://github.com/mustafasedhom/smart-predictive-unit-spu-/blob/Master/code_of_project/Background_Process_Code/AI_Brain_Of_Project/AI_Store_Data_directly/AI_Store_Data_directly.py): `code_of_project/Background_Process_Code/AI_Brain_Of_Project/AI_Store_Data_directly/AI_Store_Data_directly.py`

### AI analysis

- [AI runtime](https://github.com/mustafasedhom/smart-predictive-unit-spu-/blob/Master/code_of_project/Background_Process_Code/AI_Brain_Of_Project/AI_Main_module.py): `code_of_project/Background_Process_Code/AI_Brain_Of_Project/AI_Main_module.py`
- [Analysis dispatcher](https://github.com/mustafasedhom/smart-predictive-unit-spu-/blob/Master/code_of_project/Background_Process_Code/AI_Brain_Of_Project/AI_Analysis_Actuator_Data/Analysis_Data.py): `code_of_project/Background_Process_Code/AI_Brain_Of_Project/AI_Analysis_Actuator_Data/Analysis_Data.py`
- [Actuator health analysis](https://github.com/mustafasedhom/smart-predictive-unit-spu-/tree/Master/code_of_project/Background_Process_Code/AI_Brain_Of_Project/AI_Analysis_Actuator_Data/Actuator_Analysis): `code_of_project/Background_Process_Code/AI_Brain_Of_Project/AI_Analysis_Actuator_Data/Actuator_Analysis`
- [Fault prediction](https://github.com/mustafasedhom/smart-predictive-unit-spu-/blob/Master/code_of_project/Background_Process_Code/AI_Brain_Of_Project/AI_Analysis_Actuator_Data/Actuator_Analysis/calc_predicated_fault_of_actuator/calc_predicated_fault_of_actuator.py): `code_of_project/Background_Process_Code/AI_Brain_Of_Project/AI_Analysis_Actuator_Data/Actuator_Analysis/calc_predicated_fault_of_actuator/calc_predicated_fault_of_actuator.py`
- [Alarm analysis](https://github.com/mustafasedhom/smart-predictive-unit-spu-/tree/Master/code_of_project/Background_Process_Code/AI_Brain_Of_Project/AI_Analysis_Actuator_Data/Alarm_Analysis): `code_of_project/Background_Process_Code/AI_Brain_Of_Project/AI_Analysis_Actuator_Data/Alarm_Analysis`

### App and alerts

- [Email notifications](https://github.com/mustafasedhom/smart-predictive-unit-spu-/blob/Master/code_of_project/Background_Process_Code/AI_Brain_Of_Project/AI_Analysis_Actuator_Data/Alarm_Analysis/Send_Notification/Gmail_Massage.py): `code_of_project/Background_Process_Code/AI_Brain_Of_Project/AI_Analysis_Actuator_Data/Alarm_Analysis/Send_Notification/Gmail_Massage.py`
- [Monitoring app](https://github.com/mustafasedhom/smart-predictive-unit-spu-/tree/Master/code_of_project/SPU_Flutter_app_code/spu_linux_app): `code_of_project/SPU_Flutter_app_code/spu_linux_app`

### Other components

- **Sensors and actuators**
- **Operator**

## Connections

- Sensors and actuators → Sensor firmware: provides readings
- Sensor firmware → UART reader: sends JSON
- AI runtime → UART reader: reads UART (evidence: `code_of_project/Background_Process_Code/AI_Brain_Of_Project/AI_Main_module.py`)
- AI runtime → Sensor JSON parser: parses readings (evidence: `code_of_project/Background_Process_Code/AI_Brain_Of_Project/AI_Main_module.py`)
- AI runtime → Sensor processing: processes readings (evidence: `code_of_project/Background_Process_Code/AI_Brain_Of_Project/AI_Main_module.py`)
- Sensor JSON parser → Sensor processing: builds sensor data (evidence: `code_of_project/Background_Process_Code/Handle_Data_Base_Code/Rrocess_Data_From_Slave_Board/All_Sensor_Data_After_Processing/All_Sensor_Data_After_Processing.py`)
- AI runtime → Database access: updates database (evidence: `code_of_project/Background_Process_Code/AI_Brain_Of_Project/AI_Main_module.py`)
- Database access → Database manager: creates manager (evidence: `code_of_project/Background_Process_Code/Handle_Data_Base_Code/Data_Base_Python/SPU_main_Data_handlig.py`)
- Database manager → JSON database files: loads JSON (evidence: `code_of_project/Background_Process_Code/Handle_Data_Base_Code/Data_Base_Python/Data_Base_Manger/Data_Base_Manager.py`)
- Database manager → Equipment settings: initializes settings (evidence: `code_of_project/Background_Process_Code/Handle_Data_Base_Code/Data_Base_Python/Data_Base_Manger/Data_Base_Manager.py`)
- AI runtime → Direct data storage: stores readings (evidence: `code_of_project/Background_Process_Code/AI_Brain_Of_Project/AI_Main_module.py`)
- Direct data storage → Historical data files: writes history (evidence: `code_of_project/Background_Process_Code/AI_Brain_Of_Project/AI_Store_Data_directly/AI_Store_Data_directly.py`)
- AI runtime → Analysis dispatcher: runs analysis (evidence: `code_of_project/Background_Process_Code/AI_Brain_Of_Project/AI_Main_module.py`)
- Analysis dispatcher → Actuator health analysis: dispatches analysis (evidence: `code_of_project/Background_Process_Code/AI_Brain_Of_Project/AI_Analysis_Actuator_Data/Analysis_Data.py`)
- Actuator health analysis → Fault prediction: calculates faults (evidence: `code_of_project/Background_Process_Code/AI_Brain_Of_Project/AI_Analysis_Actuator_Data/Actuator_Analysis/Belt_Analysis.py`)
- AI runtime → Email notifications: sends notices (evidence: `code_of_project/Background_Process_Code/AI_Brain_Of_Project/AI_Main_module.py`)
- Operator → Monitoring app: views status
- Alarm analysis → Email notifications: notifies
- Monitoring app → Database access: accesses status
