# purusottamsaha2024/yoga_virtual_teacher architecture

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

- Interactive diagram: https://gitdiagram.com/purusottamsaha2024/yoga_virtual_teacher
- Repository: https://github.com/purusottamsaha2024/yoga_virtual_teacher

## Overview

##### Project Type and Purpose
- This is a small full-stack, Python-based pose-estimation web application with a separate data-processing and model-training pipeline.
- From the README and file tree:
- app.py plus templates/ and static/ indicate a Flask (or similar) web server exposing an HTML/JS UI.
- A suite of scripts (poseLandmark_csv.py, create_landmarks.py, create_angles.py, calc_angles.py, outliers_removal.py, recommendations.py) ingest raw image data, extract joint landmarks, compute joint angles, clean outliers, and produce recommendations.
- poseModel.py trains a Keras model (model.h5) from the generated CSV data.

##### File Structure Analysis
- Top-level:
- Dataset/ & poses_dataset/: raw images and precomputed landmarks/angles for each pose class.
- .csv files & csv_files/: intermediate datasets (landmarks.csv, poses_angles.csv, refined_pose_angles_with_tolerance.csv).
- model.h5: trained ML model.
- app.py, detection.py, recommendations.py: serving scripts.
- templates/index.html & static/main.js: front-end presentation.
- No external microservices or databases; data lives in files.

##### Key Architectural Patterns
- Separation of Concerns:
- Data-processing pipeline (scripts that generate CSVs and train the model)
- Model-serving Web application
- Batch pipeline for training vs. request/response pipeline for inference.

##### Main Components
a. Data Ingestion & Processing Pipeline
- Component: Dataset (images folder)
- poseLandmark_csv.py → create_landmarks.py → create_angles.py → calc_angles.py → outliers_removal.py → recommendations.py
- Artifacts: landmarks.csv, poses_angles.csv, refined CSVs
b. Model Training
- Component: poseModel.py
- Input: refined CSV data
- Output: model.h5
c. Model Serving (Web Application)
- Component: app.py + detection.py
- UI Layer: templates/index.html + static/main.js
- ML Component: loads model.h5, detection pipeline (landmark extraction + angle calc), and recommendation logic
d. User & Browser
- User interacts with front-end in a browser, images uploaded to app.py
e. Storage
- File‐system storage for CSVs, model artifacts

##### Relationships & Data Flow
1. Raw Images → Data-Processing Scripts → CSV Files
2. CSV Files → Training Script → model.h5
3. model.h5 + Real-Time Image Input → Inference Scripts → Recommendations
4. Inference Results → Front-end → User

##### Technologies & Frameworks
- Python scripts (poseLandmark_csv.py, etc.)
- TensorFlow/Keras (model.h5)
- Flask (app.py)
- HTML/JS (templates/index.html, static/main.js)
- File system for storage

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Training Pipeline
    subgraph "Training Pipeline"
        direction TB
        RawImages["Raw Images\n(Dataset/)"]:::datastore
        PL["poseLandmark_csv.py"]:::batch
        CL["create_landmarks.py"]:::batch
        CA["create_angles.py"]:::batch
        CCalc["calc_angles.py"]:::batch
        OR["outliers_removal.py"]:::batch
        RecBatch["recommendations.py"]:::batch
        LandmarksCSV["landmarks.csv"]:::datastore
        DataCSV["data.csv"]:::datastore
        PosesAngles1["poses_angles.csv\n(csv_files/)"]:::datastore
        PosesAnglesR["poses_angle_ranges.csv\n(csv_files/)"]:::datastore
        PosesAngles2["poses_angles1.csv\n(csv_files/)"]:::datastore
        RefinedCSV["refined_pose_angles_with_tolerance.csv"]:::datastore
        PM["poseModel.py"]:::batch
        Model["model.h5"]:::datastore

        RawImages -->|ingest| PL
        PL -->|outputs landmarks.csv| LandmarksCSV
        LandmarksCSV -->|input| CL
        CL -->|outputs data.csv| DataCSV
        DataCSV -->|input| CA
        CA -->|outputs poses_angles.csv| PosesAngles1
        PosesAngles1 -->|input| CCalc
        CCalc -->|outputs poses_angle_ranges.csv| PosesAnglesR
        PosesAnglesR -->|input| OR
        OR -->|outputs poses_angles1.csv| PosesAngles2
        PosesAngles2 -->|input| RecBatch
        RecBatch -->|outputs refined CSV| RefinedCSV
        RefinedCSV -->|trains| PM
        PM -->|produces| Model
    end

    %% Serving Pipeline
    subgraph "Serving Pipeline"
        direction TB
        FE["Front-End UI\n(templates/index.html\nstatic/main.js)"]:::frontend
        App["app.py"]:::serve
        Detect["detection.py"]:::serve
        RecServe["recommendations.py"]:::serve
        ModelServe["model.h5"]:::datastore

        FE -->|uploads image| App
        App -->|loads model| ModelServe
        App -->|runs detection| Detect
        Detect -->|extracts landmarks & angles| App
        App -->|calls recommendation| RecServe
        RecServe -->|returns recommendations| App
        App -->|response| FE
    end

    %% Legend
    subgraph "Legend"
        direction TB
        A["Blue: Batch Pipeline"]:::batch
        B["Green: Data Store"]:::datastore
        C["Orange: Serving Components"]:::serve
        D["Purple: Front-End"]:::frontend
    end

    %% Click Events - Training Pipeline
    click PL "https://github.com/purusottamsaha2024/yoga_virtual_teacher/blob/main/poseLandmark_csv.py"
    click CL "https://github.com/purusottamsaha2024/yoga_virtual_teacher/blob/main/create_landmarks.py"
    click CA "https://github.com/purusottamsaha2024/yoga_virtual_teacher/blob/main/create_angles.py"
    click CCalc "https://github.com/purusottamsaha2024/yoga_virtual_teacher/blob/main/calc_angles.py"
    click OR "https://github.com/purusottamsaha2024/yoga_virtual_teacher/blob/main/outliers_removal.py"
    click RecBatch "https://github.com/purusottamsaha2024/yoga_virtual_teacher/blob/main/recommendations.py"
    click RawImages "https://github.com/purusottamsaha2024/yoga_virtual_teacher/tree/main/Dataset/"
    click LandmarksCSV "https://github.com/purusottamsaha2024/yoga_virtual_teacher/blob/main/landmarks.csv"
    click PosesAngles1 "https://github.com/purusottamsaha2024/yoga_virtual_teacher/blob/main/csv_files/poses_angles.csv"
    click PosesAnglesR "https://github.com/purusottamsaha2024/yoga_virtual_teacher/blob/main/csv_files/poses_angle_ranges.csv"
    click PosesAngles2 "https://github.com/purusottamsaha2024/yoga_virtual_teacher/blob/main/csv_files/poses_angles1.csv"
    click RefinedCSV "https://github.com/purusottamsaha2024/yoga_virtual_teacher/blob/main/refined_pose_angles_with_tolerance.csv"
    click PM "https://github.com/purusottamsaha2024/yoga_virtual_teacher/blob/main/poseModel.py"
    click Model "https://github.com/purusottamsaha2024/yoga_virtual_teacher/blob/main/model.h5"

    %% Click Events - Serving Pipeline
    click App "https://github.com/purusottamsaha2024/yoga_virtual_teacher/blob/main/app.py"
    click Detect "https://github.com/purusottamsaha2024/yoga_virtual_teacher/blob/main/detection.py"
    click RecServe "https://github.com/purusottamsaha2024/yoga_virtual_teacher/blob/main/recommendations.py"
    click FE "https://github.com/purusottamsaha2024/yoga_virtual_teacher/blob/main/templates/index.html"
    click FE "https://github.com/purusottamsaha2024/yoga_virtual_teacher/blob/main/static/main.js"

    %% Styles
    classDef batch fill:#D0E6FF,stroke:#007ACC,stroke-width:1px;
    classDef datastore fill:#DFFFE0,stroke:#2D9E00,stroke-width:1px;
    classDef serve fill:#FFE2B3,stroke:#FF8C00,stroke-width:1px;
    classDef frontend fill:#F3D9FF,stroke:#9B59B6,stroke-width:1px;
    classDef metadata fill:#E0E0E0,stroke:#888888,stroke-width:1px;
```
