# airscholar/ai-workout-manager architecture

> Architecture diagram of the GitHub repository airscholar/ai-workout-manager, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-04-01). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/airscholar/ai-workout-manager
- Repository: https://github.com/airscholar/ai-workout-manager

## Overview

##### Project Type & Purpose
- This is a single-script application (main.py) aimed at analyzing video input (or live camera feed) to detect human poses, count exercise repetitions, and display real-time performance metrics.
- Its core functionality includes pose detection, calculating angles between body landmarks, counting repetitions, and displaying UI elements.

##### File Structure
- The root directory contains the main application logic (main.py) along with a requirements file that lists the dependencies, such as OpenCV, MediaPipe, and Numpy.
- The assets directory holds external resources like video files (e.g., pushup.mp4) which might be used for demonstrations or testing.
- This organized, compact structure suggests that the main application coordinates all major functionalities from a central script.

##### Core Architectural Components
a. Input Component:
- Video Feed/Input: This could be either from a camera feed or a video file (as seen with pushup.mp4 in the assets).

b. Processing Component:
- Pose Detection Module: Utilizes MediaPipe for detecting human pose landmarks.
- Video Processing Module: Uses OpenCV for frame acquisition, pre-processing, and post-processing of video frames.
- Repetition Counting Module: Implements algorithms that use detected poses and calculated angles to determine exercise counts.
- Angle Calculation: Uses provided algorithms (likely with numpy and math libraries) for determining body joint angles.

c. Output/UI Component:
- Metrics and Timing: Elapsed time tracking and rep count feedback presented visually.

##### Relationships & Data Flow
- The Video Input feeds into the Processing Component where the frame is analyzed.
- The processing chain then splits into separate functionalities: one branch for pose detection (using MediaPipe with input from OpenCV) and another for repetition counting (using the detected landmarks).
- The results from processing are then passed to the UI/Visualization Module to update the on-screen feedback.

##### Technical Stack & Libraries
- Python 3 acts as the runtime environment.
- OpenCV is used for image capture and frame manipulation.
- MediaPipe is utilized for pose detection.
- Numpy provides numerical support for computations.
- Standard libraries such as math and time handle calculation and tracking.

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "Input Components"
        VI("Video Input (Camera/Video File)"):::input
        EA("External Assets"):::external
    end

    subgraph "Processing Components"
        FP("Frame Processing (OpenCV)"):::processing
        PD("Pose Detection (MediaPipe)"):::processing
        RC("Repetition Counting & Angle Calculation"):::processing
    end

    subgraph "Output Components"
        UI("Visualization/UI (Display Metrics)"):::output
    end

    VI -->|"feeds"| FP
    EA -->|"provides_media"| VI
    FP -->|"analyzes"| PD
    FP -->|"analyzes"| RC
    PD -->|"sends_pose_data"| UI
    RC -->|"sends_count_data"| UI

    classDef input fill:#f9c,stroke:#333,stroke-width:2px;
    classDef processing fill:#cce,stroke:#333,stroke-width:2px;
    classDef output fill:#cfc,stroke:#333,stroke-width:2px;
    classDef external fill:#fc9,stroke:#333,stroke-width:2px;

    click VI "https://github.com/airscholar/ai-workout-manager/blob/main/main.py"
    click FP "https://github.com/airscholar/ai-workout-manager/blob/main/main.py"
    click PD "https://github.com/airscholar/ai-workout-manager/blob/main/main.py"
    click RC "https://github.com/airscholar/ai-workout-manager/blob/main/main.py"
    click EA "https://github.com/airscholar/ai-workout-manager/tree/main/assets/"
```
