# pranavkumar2911/posture-detection-system-using-machine-learning architecture

> Architecture diagram of the GitHub repository pranavkumar2911/posture-detection-system-using-machine-learning, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-03-28). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/pranavkumar2911/posture-detection-system-using-machine-learning
- Repository: https://github.com/pranavkumar2911/posture-detection-system-using-machine-learning

## Overview

##### Project Type and Purpose
- This is an embedded machine learning project designed for real-time posture detection on resource-constrained microcontrollers. It uses a BMI270 sensor for capturing inertial data and TensorFlow Lite for executing the ML inference on the device.
- The system is divided into distinct phases: data collection, model training/conversion, and real-time inference (deployment) on the embedded hardware.

##### Main Components
- Hardware Layer:
– Arduino board (e.g., Arduino Nano 33 BLE Sense or similar), which serves as the primary microcontroller.
– BMI270 sensor connected via I2C for collecting IMU data.
– (Optional) USB connection for programming and powering the board.
- Data Collection Module:
– Represent the Arduino sketch “data_collection.ino” that collects sensor data.
– Indicate that this component connects to the sensor and streams raw sensor data (these data are then saved as CSV in the “data” directory).
- Model Training and Conversion Module:
– The “model_training.ipynb” notebook indicates the Python-based training pipeline.
– Show preprocessing, training, and conversion processes—resulting in the TensorFlow Lite (TFLite) model (shown in the “models” directory as model.tflite).
– You might optionally include the “plots” directory as part of the evaluation/visualization process.
- Inference Deployment Module:
– The Arduino sketch “inference.ino” is responsible for running real-time posture classification using the TFLite model.
- Documentation and Supporting Assets:
– Include ancillary components like README, usage/docs, and additional documentation in the “docs” folder, which help in understanding system setup and usage.

##### Relationships and Interactions
- Data flows start from the sensor reading captured by “data_collection.ino” running on the Arduino, which is then transferred to a PC for data labeling and saved as Data_Set.csv.
- The training environment (Python/Jupyter Notebook) takes the raw data, preprocesses it, trains the machine learning model, and converts it into a TFLite model.
- Once the model is generated, it is deployed back onto the Arduino using “inference.ino” for real-time prediction.

##### Architectural Patterns and Design Principles
- A modular design where each major function (data collection, training, inference) is encapsulated in separate modules.
- Demonstrate separation of concerns between offline training (Python notebook) and on-device inference (Arduino sketches).
- Clear integration points where the output of one stage (e.g., the TFLite model) becomes an input to another stage (the inference module).

##### Relevant Technologies and Tools
- Hardware: Arduino board and BMI270 sensor.
- Software: Arduino IDE (for programming), TensorFlow Lite for Microcontrollers, Python (for model training) and Jupyter Notebook.
- Languages: C++ (for Arduino sketches) and Python (for training).

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Hardware Layer
    subgraph "Hardware Layer"
        sensor["BMI270 Sensor"]:::hardware
        arduino["Arduino Board"]:::hardware
    end

    %% Data Collection Module
    subgraph "Data Collection Module"
        dc["Sensor Data Collection (data_collection.ino)"]:::code
    end

    %% Data Storage
    subgraph "Data Storage"
        csv["Data Storage (Data_Set.csv)"]:::data
    end

    %% Model Training & Conversion Module
    subgraph "Model Training & Conversion Module"
        training["Model Training & Conversion (model_training.ipynb)"]:::code
        model["TensorFlow Lite Model (model.tflite)"]:::model
        evaluation["Evaluation/Visualization (plots)"]:::code
    end

    %% Inference Deployment Module
    subgraph "Inference Deployment Module"
        inference["Real-Time Inference (infernace.ino)"]:::code
    end

    %% Documentation & Supporting Assets
    subgraph "Documentation & Supporting Assets"
        docs1["README.md"]:::docs
        docs2["Usage Docs (docs/usage.md)"]:::docs
    end

    %% Connections
    sensor -->|"I2C_Connection"| arduino
    arduino -->|"Runs"| dc
    dc -->|"SavesData"| csv
    csv -->|"TrainingInput"| training
    training -->|"GeneratesModel"| model
    training -->|"AnalysisOutput"| evaluation
    model -->|"DeployedTo"| inference
    inference -->|"ExecutesOn"| arduino
    training -->|"DocumentedIn"| docs1
    inference -->|"UsageGuide"| docs2

    %% Click Events
    click dc "https://github.com/pranavkumar2911/posture-detection-system-using-machine-learning/blob/main/src/data_collection.ino"
    click csv "https://github.com/pranavkumar2911/posture-detection-system-using-machine-learning/blob/main/data/Data_Set.csv"
    click training "https://github.com/pranavkumar2911/posture-detection-system-using-machine-learning/blob/main/src/model_training.ipynb"
    click model "https://github.com/pranavkumar2911/posture-detection-system-using-machine-learning/blob/main/models/model.tflite"
    click evaluation "https://github.com/pranavkumar2911/posture-detection-system-using-machine-learning/tree/main/plots"
    click inference "https://github.com/pranavkumar2911/posture-detection-system-using-machine-learning/blob/main/src/infernace.ino"
    click docs1 "https://github.com/pranavkumar2911/posture-detection-system-using-machine-learning/blob/main/README.md"
    click docs2 "https://github.com/pranavkumar2911/posture-detection-system-using-machine-learning/blob/main/docs/usage.md"

    %% Styles
    classDef hardware fill:#ADD8E6,stroke:#000,stroke-width:2px;
    classDef code fill:#90EE90,stroke:#000,stroke-width:2px;
    classDef data fill:#FFFF99,stroke:#000,stroke-width:2px;
    classDef model fill:#FFB6C1,stroke:#000,stroke-width:2px;
    classDef docs fill:#D3D3D3,stroke:#000,stroke-width:2px;
```
