# hnainiamohamedamine29/obc_cubesat_predictive_maintenance architecture

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

- Interactive diagram: https://gitdiagram.com/hnainiamohamedamine29/obc_cubesat_predictive_maintenance
- Repository: https://github.com/hnainiamohamedamine29/obc_cubesat_predictive_maintenance

## Overview

This repository is a CubeSat battery State-of-Health (SOH) prediction project, spanning data preparation, LSTM modeling, TensorFlow Lite conversion and embedded inference. The documented user-to-result workflow prepares cycle data into scaled time windows, predicts SOH, then can run inference on an STM32 board. The README also describes MATLAB battery simulation, but its source is absent from the supplied tree. Edges reflect README workflow statements or visible source references; unsampled notebook and conversion internals are not assumed.

Main entry points: [`10_edge_deployment/STM_U5DiscoveryKit_TEST_Copy_2_second_essay(confirmed)/App/app_inference.c`](https://github.com/hnainiamohamedamine29/obc_cubesat_predictive_maintenance/blob/master/10_edge_deployment/STM_U5DiscoveryKit_TEST_Copy_2_second_essay(confirmed)/App/app_inference.c) (U5 Inference App), [`04_pipline_data_preparing/config.py`](https://github.com/hnainiamohamedamine29/obc_cubesat_predictive_maintenance/blob/master/04_pipline_data_preparing/config.py) (Pipeline Config), [`04_pipline_data_preparing/feature_engineering.py`](https://github.com/hnainiamohamedamine29/obc_cubesat_predictive_maintenance/blob/master/04_pipline_data_preparing/feature_engineering.py) (Feature Engineering), [`04_pipline_data_preparing/split.py`](https://github.com/hnainiamohamedamine29/obc_cubesat_predictive_maintenance/blob/master/04_pipline_data_preparing/split.py) (Data Splitting)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_analysis["Analysis"]
  node_eda["Data Exploration"]
  node_plots["Visualization<br/>[visualization.py]"]
end

subgraph group_pipeline["Data Pipeline"]
  node_config["Pipeline Config<br/>[config.py]"]
  node_features["Feature Engineering"]
  node_split["Data Splitting<br/>[split.py]"]
  node_normalize["Feature Scaling<br/>[normalize.py]"]
  node_sequences["Window Building"]
end

subgraph group_models["Model and Runtime"]
  node_training["LSTM Training"]
  node_reference["Reference Model<br/>[lstm_core_5.py]"]
  node_quantization["Model Optimization"]
  node_tflite["TFLite Inference"]
  node_benchmark["Runtime Benchmark"]
  node_localpredict["Local Predictor"]
end

subgraph group_embedded["Embedded Deployment"]
  node_u5main["U5 Firmware<br/>[main.c]"]
  node_u5app["U5 Inference App<br/>[app_inference.c]"]
  node_preproc["Onboard Preprocessing<br/>[soh_preproc.c]"]
  node_uart["UART Protocol"]
  node_tflmapi["TFLM API<br/>[tflm_c_api.cpp]"]
  node_modeldata["Embedded Model Data<br/>[model_data.cc]"]
  node_f4main["F4 Firmware<br/>[main.c]"]
  node_f4app["F4 Inference App<br/>[app_inference.c]"]
end

node_analyst(("Engineer"))

node_analyst -->|"explores data"| node_eda
node_analyst -->|"configures pipeline"| node_config
node_config -->|"configures"| node_features
node_features -->|"engineers features"| node_split
node_split -->|"splits data"| node_normalize
node_normalize -->|"scales data"| node_sequences
node_sequences -->|"builds windows"| node_training
node_training -.->|"experiments with"| node_reference
node_training -.->|"exports model"| node_quantization
node_quantization -.->|"converts model"| node_tflite
node_tflite -.->|"runs inference"| node_localpredict
node_benchmark -->|"benchmarks"| node_localpredict
node_analyst -.->|"deploys to board"| node_u5main
node_u5main -->|"initializes app"| node_u5app
node_u5app -->|"preprocesses window"| node_preproc
node_u5app -->|"invokes inference"| node_tflmapi
node_u5app -->|"dispatches packets"| node_uart
node_f4main -->|"runs app"| node_f4app
node_f4app -->|"invokes inference"| node_tflmapi

click node_eda "https://github.com/hnainiamohamedamine29/obc_cubesat_predictive_maintenance/blob/master/03_visualization/data_analysis_normal_state/eda_distribution_analysis.py"
click node_plots "https://github.com/hnainiamohamedamine29/obc_cubesat_predictive_maintenance/blob/master/03_visualization/visualization.py"
click node_config "https://github.com/hnainiamohamedamine29/obc_cubesat_predictive_maintenance/blob/master/04_pipline_data_preparing/config.py"
click node_features "https://github.com/hnainiamohamedamine29/obc_cubesat_predictive_maintenance/blob/master/04_pipline_data_preparing/feature_engineering.py"
click node_split "https://github.com/hnainiamohamedamine29/obc_cubesat_predictive_maintenance/blob/master/04_pipline_data_preparing/split.py"
click node_normalize "https://github.com/hnainiamohamedamine29/obc_cubesat_predictive_maintenance/blob/master/04_pipline_data_preparing/normalize.py"
click node_sequences "https://github.com/hnainiamohamedamine29/obc_cubesat_predictive_maintenance/blob/master/04_pipline_data_preparing/sequences_construction.py"
click node_reference "https://github.com/hnainiamohamedamine29/obc_cubesat_predictive_maintenance/blob/master/06_Model_Test/test_bench_essay_Reference_Model/lstm_core_5.py"
click node_quantization "https://github.com/hnainiamohamedamine29/obc_cubesat_predictive_maintenance/blob/master/07_optimization_%26_quantization_conversion/optimize_v3_int8.py"
click node_tflite "https://github.com/hnainiamohamedamine29/obc_cubesat_predictive_maintenance/blob/master/08_inference_tflite/lstm_core_6_tflite%20_3.py"
click node_benchmark "https://github.com/hnainiamohamedamine29/obc_cubesat_predictive_maintenance/blob/master/09_runtime_test(latency_RAM)_on_local/benchmark_inference_fixed.py"
click node_localpredict "https://github.com/hnainiamohamedamine29/obc_cubesat_predictive_maintenance/blob/master/09_runtime_test(latency_RAM)_on_local/lstm_core_8_tflite.py"
click node_u5main "https://github.com/hnainiamohamedamine29/obc_cubesat_predictive_maintenance/blob/master/10_edge_deployment/STM_U5DiscoveryKit_TEST_Copy_2_second_essay(confirmed)/Core/Src/main.c"
click node_u5app "https://github.com/hnainiamohamedamine29/obc_cubesat_predictive_maintenance/blob/master/10_edge_deployment/STM_U5DiscoveryKit_TEST_Copy_2_second_essay(confirmed)/App/app_inference.c"
click node_preproc "https://github.com/hnainiamohamedamine29/obc_cubesat_predictive_maintenance/blob/master/10_edge_deployment/STM_U5DiscoveryKit_TEST_Copy_2_second_essay(confirmed)/App/soh_preproc.c"
click node_uart "https://github.com/hnainiamohamedamine29/obc_cubesat_predictive_maintenance/blob/master/10_edge_deployment/STM_U5DiscoveryKit_TEST_Copy_2_second_essay(confirmed)/App/app_uart_protocol.c"
click node_tflmapi "https://github.com/hnainiamohamedamine29/obc_cubesat_predictive_maintenance/blob/master/10_edge_deployment/STM_TEST_LSTM_first_essay_not_confirmed/TFLM/tflm_c_api.cpp"
click node_modeldata "https://github.com/hnainiamohamedamine29/obc_cubesat_predictive_maintenance/blob/master/10_edge_deployment/STM_TEST_LSTM_first_essay_not_confirmed/Model/model_data.cc"
click node_f4main "https://github.com/hnainiamohamedamine29/obc_cubesat_predictive_maintenance/blob/master/10_edge_deployment/STM_TEST_LSTM_first_essay_not_confirmed/Core/Src/main.c"
click node_f4app "https://github.com/hnainiamohamedamine29/obc_cubesat_predictive_maintenance/blob/master/10_edge_deployment/STM_TEST_LSTM_first_essay_not_confirmed/App/app_inference.c"

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_eda,node_plots toneBlue
class node_config,node_features,node_split,node_normalize,node_sequences toneAmber
class node_training,node_reference,node_quantization,node_tflite,node_benchmark,node_localpredict toneMint
class node_u5main,node_u5app,node_preproc,node_uart,node_tflmapi,node_modeldata,node_f4main,node_f4app toneRose
class node_analyst toneIndigo
```

## Components

### Analysis

- [Data Exploration](https://github.com/hnainiamohamedamine29/obc_cubesat_predictive_maintenance/blob/master/03_visualization/data_analysis_normal_state/eda_distribution_analysis.py): `03_visualization/data_analysis_normal_state/eda_distribution_analysis.py`
- [Visualization](https://github.com/hnainiamohamedamine29/obc_cubesat_predictive_maintenance/blob/master/03_visualization/visualization.py): `03_visualization/visualization.py`

### Data Pipeline

- [Pipeline Config](https://github.com/hnainiamohamedamine29/obc_cubesat_predictive_maintenance/blob/master/04_pipline_data_preparing/config.py): `04_pipline_data_preparing/config.py`
- [Feature Engineering](https://github.com/hnainiamohamedamine29/obc_cubesat_predictive_maintenance/blob/master/04_pipline_data_preparing/feature_engineering.py): `04_pipline_data_preparing/feature_engineering.py`
- [Data Splitting](https://github.com/hnainiamohamedamine29/obc_cubesat_predictive_maintenance/blob/master/04_pipline_data_preparing/split.py): `04_pipline_data_preparing/split.py`
- [Feature Scaling](https://github.com/hnainiamohamedamine29/obc_cubesat_predictive_maintenance/blob/master/04_pipline_data_preparing/normalize.py): `04_pipline_data_preparing/normalize.py`
- [Window Building](https://github.com/hnainiamohamedamine29/obc_cubesat_predictive_maintenance/blob/master/04_pipline_data_preparing/sequences_construction.py): `04_pipline_data_preparing/sequences_construction.py`

### Model and Runtime

- **LSTM Training**
- [Reference Model](https://github.com/hnainiamohamedamine29/obc_cubesat_predictive_maintenance/blob/master/06_Model_Test/test_bench_essay_Reference_Model/lstm_core_5.py): `06_Model_Test/test_bench_essay_Reference_Model/lstm_core_5.py`
- [Model Optimization](https://github.com/hnainiamohamedamine29/obc_cubesat_predictive_maintenance/blob/master/07_optimization_%26_quantization_conversion/optimize_v3_int8.py): `07_optimization_&_quantization_conversion/optimize_v3_int8.py`
- [TFLite Inference](https://github.com/hnainiamohamedamine29/obc_cubesat_predictive_maintenance/blob/master/08_inference_tflite/lstm_core_6_tflite%20_3.py): `08_inference_tflite/lstm_core_6_tflite _3.py`
- [Runtime Benchmark](https://github.com/hnainiamohamedamine29/obc_cubesat_predictive_maintenance/blob/master/09_runtime_test(latency_RAM)_on_local/benchmark_inference_fixed.py): `09_runtime_test(latency_RAM)_on_local/benchmark_inference_fixed.py`
- [Local Predictor](https://github.com/hnainiamohamedamine29/obc_cubesat_predictive_maintenance/blob/master/09_runtime_test(latency_RAM)_on_local/lstm_core_8_tflite.py): `09_runtime_test(latency_RAM)_on_local/lstm_core_8_tflite.py`

### Embedded Deployment

- [U5 Firmware](https://github.com/hnainiamohamedamine29/obc_cubesat_predictive_maintenance/blob/master/10_edge_deployment/STM_U5DiscoveryKit_TEST_Copy_2_second_essay(confirmed)/Core/Src/main.c): `10_edge_deployment/STM_U5DiscoveryKit_TEST_Copy_2_second_essay(confirmed)/Core/Src/main.c`
- [U5 Inference App](https://github.com/hnainiamohamedamine29/obc_cubesat_predictive_maintenance/blob/master/10_edge_deployment/STM_U5DiscoveryKit_TEST_Copy_2_second_essay(confirmed)/App/app_inference.c): `10_edge_deployment/STM_U5DiscoveryKit_TEST_Copy_2_second_essay(confirmed)/App/app_inference.c`
- [Onboard Preprocessing](https://github.com/hnainiamohamedamine29/obc_cubesat_predictive_maintenance/blob/master/10_edge_deployment/STM_U5DiscoveryKit_TEST_Copy_2_second_essay(confirmed)/App/soh_preproc.c): `10_edge_deployment/STM_U5DiscoveryKit_TEST_Copy_2_second_essay(confirmed)/App/soh_preproc.c`
- [UART Protocol](https://github.com/hnainiamohamedamine29/obc_cubesat_predictive_maintenance/blob/master/10_edge_deployment/STM_U5DiscoveryKit_TEST_Copy_2_second_essay(confirmed)/App/app_uart_protocol.c): `10_edge_deployment/STM_U5DiscoveryKit_TEST_Copy_2_second_essay(confirmed)/App/app_uart_protocol.c`
- [TFLM API](https://github.com/hnainiamohamedamine29/obc_cubesat_predictive_maintenance/blob/master/10_edge_deployment/STM_TEST_LSTM_first_essay_not_confirmed/TFLM/tflm_c_api.cpp): `10_edge_deployment/STM_TEST_LSTM_first_essay_not_confirmed/TFLM/tflm_c_api.cpp`
- [Embedded Model Data](https://github.com/hnainiamohamedamine29/obc_cubesat_predictive_maintenance/blob/master/10_edge_deployment/STM_TEST_LSTM_first_essay_not_confirmed/Model/model_data.cc): `10_edge_deployment/STM_TEST_LSTM_first_essay_not_confirmed/Model/model_data.cc`
- [F4 Firmware](https://github.com/hnainiamohamedamine29/obc_cubesat_predictive_maintenance/blob/master/10_edge_deployment/STM_TEST_LSTM_first_essay_not_confirmed/Core/Src/main.c): `10_edge_deployment/STM_TEST_LSTM_first_essay_not_confirmed/Core/Src/main.c`
- [F4 Inference App](https://github.com/hnainiamohamedamine29/obc_cubesat_predictive_maintenance/blob/master/10_edge_deployment/STM_TEST_LSTM_first_essay_not_confirmed/App/app_inference.c): `10_edge_deployment/STM_TEST_LSTM_first_essay_not_confirmed/App/app_inference.c`

### Other components

- **Engineer**

## Connections

- Engineer → Data Exploration: explores data
- Engineer → Pipeline Config: configures pipeline
- Pipeline Config → Feature Engineering: configures (evidence: `04_pipline_data_preparing/feature_engineering.py`)
- Feature Engineering → Data Splitting: engineers features
- Data Splitting → Feature Scaling: splits data
- Feature Scaling → Window Building: scales data
- Window Building → LSTM Training: builds windows
- LSTM Training → Reference Model: experiments with
- LSTM Training → Model Optimization: exports model
- Model Optimization → TFLite Inference: converts model
- TFLite Inference → Local Predictor: runs inference
- Runtime Benchmark → Local Predictor: benchmarks (evidence: `09_runtime_test(latency_RAM)_on_local/benchmark_inference_fixed.py`)
- Engineer → U5 Firmware: deploys to board
- U5 Firmware → U5 Inference App: initializes app (evidence: `10_edge_deployment/STM_U5DiscoveryKit_TEST_Copy_2_second_essay(confirmed)/Core/Src/main.c`)
- U5 Inference App → Onboard Preprocessing: preprocesses window (evidence: `10_edge_deployment/STM_U5DiscoveryKit_TEST_Copy_2_second_essay(confirmed)/App/app_inference.c`)
- U5 Inference App → TFLM API: invokes inference (evidence: `10_edge_deployment/STM_U5DiscoveryKit_TEST_Copy_2_second_essay(confirmed)/App/app_inference.c`)
- U5 Inference App → UART Protocol: dispatches packets (evidence: `10_edge_deployment/STM_U5DiscoveryKit_TEST_Copy_2_second_essay(confirmed)/App/app_inference.c`)
- F4 Firmware → F4 Inference App: runs app (evidence: `10_edge_deployment/STM_TEST_LSTM_first_essay_not_confirmed/Core/Src/main.c`)
- F4 Inference App → TFLM API: invokes inference (evidence: `10_edge_deployment/STM_TEST_LSTM_first_essay_not_confirmed/App/app_inference.c`)
