# lazgl/yogaliveposecorrector architecture

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

- Interactive diagram: https://gitdiagram.com/lazgl/yogaliveposecorrector
- Repository: https://github.com/lazgl/yogaliveposecorrector

## Overview

##### Project type and purpose
- This is an on-device, AI-powered yoga coaching application. It combines computer-vision (pose detection), machine-learning inference (LLM prompt engineering), text-to-speech, and a browser-based UI using Gradio. Its purpose is to run entirely offline on a local device, providing real-time visual and voice guidance for yoga posture correction.

##### File structure
- Top-level scripts:
- app_llm.py: Orchestrator that ties together UI, pose detection, scoring, LLM calls, and TTS.
- inference_new.py: Handles local LLM inference using Qwen/Qwen2.5.
- calculate_difference.py: Computes pose-similarity scores (cosine similarity) between detected keypoints and template poses.
- tts_utils.py: Wraps Piper TTS functionality for voice feedback.
- Configuration: requirements.txt lists Python dependencies (MediaPipe, OpenCV, Gradio, Qwen bindings, Piper).
- No separate “frontend” or “backend” folders—these are logical components in a single Python application.

##### README for additional insights
- Architecture hints:
- MediaPipe BlazePose + OpenCV for skeleton tracking
- Qwen-based LLM on-device for NLP corrections
- Piper TTS for audio feedback
- Gradio UI for interactive display and camera capture
- Emphasis on multi-threading, caching, offline operation, and adaptive feedback loops.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% UI Layer
    UI["Gradio UI & Camera Input Module"]:::frontend
    click UI "https://github.com/lazgl/yogaliveposecorrector/blob/main/app_llm.py"

    %% Pipeline Components
    PD["Pose Detection Engine<br/>(MediaPipe BlazePose + OpenCV)"]:::processor
    click PD "https://github.com/lazgl/yogaliveposecorrector/blob/main/app_llm.py"

    PS["Pose Scoring Service<br/>(calculate_difference.py)"]:::processor
    click PS "https://github.com/lazgl/yogaliveposecorrector/blob/main/calculate_difference.py"

    LLM["LLM Inference Engine<br/>(Qwen2.5)"]:::ai
    click LLM "https://github.com/lazgl/yogaliveposecorrector/blob/main/inference_new.py"

    TTS["TTS Module<br/>(Piper)"]:::ai
    click TTS "https://github.com/lazgl/yogaliveposecorrector/blob/main/tts_utils.py"

    %% Static Assets
    TR["Template Repository<br/>(Yoga Poses)"]:::static

    %% Performance Optimizer
    subgraph "Performance Optimizer"
        CMT["Caching & Multi-Threading Layer"]:::opt
    end

    %% Dependencies (config)
    DEPS["Python Dependencies<br/>(requirements.txt)"]:::static
    click DEPS "https://github.com/lazgl/yogaliveposecorrector/blob/main/requirements.txt"

    %% Data Flow
    UI -->|"capture frame"| PD
    PD -->|"keypoints"| PS
    PS -->|"score & session data"| LLM
    LLM -->|"text feedback"| TTS
    TTS -->|"audio feedback"| UI

    PD -->|"frame + overlay"| UI

    PS -->|"pose templates"| TR
    TR -.-> PS

    CMT --> PD
    CMT --> LLM

    classDef frontend fill:#F8B195,stroke:#355C7D,color:#000;
    classDef processor fill:#A8E6CF,stroke:#355C7D,color:#000;
    classDef ai fill:#FFD3B6,stroke:#355C7D,color:#000;
    classDef static fill:#E0E0E0,stroke:#355C7D,color:#000,stroke-dasharray: 5 5;
    classDef opt fill:#D3D3D3,stroke:#355C7D,color:#000,stroke-dasharray: 2 2;
```
