# tanhuy2k2/exercise-support-system architecture

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

- Interactive diagram: https://gitdiagram.com/tanhuy2k2/exercise-support-system
- Repository: https://github.com/tanhuy2k2/exercise-support-system

## Overview

This is a browser-based AI exercise coaching system with a Flask API. The main workflow captures webcam frames, recognizes a returning user or collects profile details, then runs pose tracking, posture/repetition feedback, and exercise prescription. Profile and progress data live in Qdrant; prescription tables are read from Google Sheets. The README documents EMA smoothing and 33 pose landmarks. The available excerpts show the frontend worker/API calls and backend storage/sheet calls; exercise-session logic is excerpted only in part, so unsampled model and UI wiring is omitted.

Main entry points: [`frontend/js/detect_face.js`](https://github.com/tanhuy2k2/exercise-support-system/blob/main/frontend/js/detect_face.js) (Face and profile), [`frontend/js/Predict_AgeGender.js`](https://github.com/tanhuy2k2/exercise-support-system/blob/main/frontend/js/Predict_AgeGender.js) (Age gender inference), [`backend/main.py`](https://github.com/tanhuy2k2/exercise-support-system/blob/main/backend/main.py) (Flask routes), [`frontend/js/pose_estimation.js`](https://github.com/tanhuy2k2/exercise-support-system/blob/main/frontend/js/pose_estimation.js) (Exercise session)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Web coaching"]
  node_identity_ui["Face and profile<br/>[detect_face.js]"]
  node_age_gender["Age gender inference"]
  node_worker["API worker<br/>[worker.js]"]
  node_exercise_ui["Exercise session<br/>[pose_estimation.js]"]
end

subgraph group_api["API and domain"]
  node_api["Flask routes<br/>[main.py]"]
  node_face_embed["Face embedding<br/>[main.py]"]
end

subgraph group_persistence["Profile and plans"]
  node_profile_store[("Face and progress store<br/>[qdrant.py]")]
  node_plan_lookup["Exercise prescriptions<br/>[Access_sheet.py]"]
end

subgraph group_inference["Inference assets"]
  node_age_model["MobileNetV3 model"]
  node_age_labels["Age gender labels"]
  node_gender_labels["Gender labels"]
  node_pushup_model["Push-up classifier<br/>[MobileNet.onnx]"]
end

node_user(("Trainee"))
node_sheets[("Google Sheets")]
node_qdrant[("Qdrant service")]
node_pose_runtime["MediaPipe Pose"]
node_face_runtime["MediaPipe face detect"]

node_user -->|"provides webcam"| node_identity_ui
node_identity_ui -->|"detects face"| node_face_runtime
node_identity_ui -->|"predicts profile"| node_age_gender
node_age_gender -->|"runs inference"| node_age_model
node_age_gender -->|"loads labels"| node_age_labels
node_age_gender -->|"loads labels"| node_gender_labels
node_identity_ui -->|"posts requests"| node_worker
node_exercise_ui -->|"posts requests"| node_worker
node_worker -->|"calls REST routes"| node_api
node_api -->|"embeds images"| node_face_embed
node_api -->|"verifies and updates"| node_profile_store
node_profile_store -->|"reads and writes"| node_qdrant
node_api -->|"requests plans"| node_plan_lookup
node_plan_lookup -->|"reads worksheets"| node_sheets
node_exercise_ui -->|"tracks landmarks"| node_pose_runtime
node_exercise_ui -.->|"uses classifier"| node_pushup_model

click node_identity_ui "https://github.com/tanhuy2k2/exercise-support-system/blob/main/frontend/js/detect_face.js"
click node_age_gender "https://github.com/tanhuy2k2/exercise-support-system/blob/main/frontend/js/Predict_AgeGender.js"
click node_worker "https://github.com/tanhuy2k2/exercise-support-system/blob/main/frontend/js/worker.js"
click node_exercise_ui "https://github.com/tanhuy2k2/exercise-support-system/blob/main/frontend/js/pose_estimation.js"
click node_api "https://github.com/tanhuy2k2/exercise-support-system/blob/main/backend/main.py"
click node_face_embed "https://github.com/tanhuy2k2/exercise-support-system/blob/main/backend/main.py"
click node_profile_store "https://github.com/tanhuy2k2/exercise-support-system/blob/main/backend/qdrant.py"
click node_plan_lookup "https://github.com/tanhuy2k2/exercise-support-system/blob/main/backend/Access_sheet.py"
click node_age_model "https://github.com/tanhuy2k2/exercise-support-system/blob/main/model/MobileNetV3L_2.onnx"
click node_age_labels "https://github.com/tanhuy2k2/exercise-support-system/blob/main/model/dic_labels_age.json"
click node_gender_labels "https://github.com/tanhuy2k2/exercise-support-system/blob/main/model/dic_labels_gender.json"
click node_pushup_model "https://github.com/tanhuy2k2/exercise-support-system/blob/main/model/MobileNet.onnx"

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_identity_ui,node_age_gender,node_worker,node_exercise_ui toneBlue
class node_api,node_face_embed,node_sheets,node_qdrant toneAmber
class node_profile_store,node_plan_lookup,node_pose_runtime,node_face_runtime toneMint
class node_age_model,node_age_labels,node_gender_labels,node_pushup_model toneRose
class node_user toneIndigo
```

## Components

### Web coaching

- [Face and profile](https://github.com/tanhuy2k2/exercise-support-system/blob/main/frontend/js/detect_face.js): `frontend/js/detect_face.js`
- [Age gender inference](https://github.com/tanhuy2k2/exercise-support-system/blob/main/frontend/js/Predict_AgeGender.js): `frontend/js/Predict_AgeGender.js`
- [API worker](https://github.com/tanhuy2k2/exercise-support-system/blob/main/frontend/js/worker.js): `frontend/js/worker.js`
- [Exercise session](https://github.com/tanhuy2k2/exercise-support-system/blob/main/frontend/js/pose_estimation.js): `frontend/js/pose_estimation.js`

### API and domain

- [Flask routes](https://github.com/tanhuy2k2/exercise-support-system/blob/main/backend/main.py): `backend/main.py`
- [Face embedding](https://github.com/tanhuy2k2/exercise-support-system/blob/main/backend/main.py): `backend/main.py`

### Profile and plans

- [Face and progress store](https://github.com/tanhuy2k2/exercise-support-system/blob/main/backend/qdrant.py): `backend/qdrant.py`
- [Exercise prescriptions](https://github.com/tanhuy2k2/exercise-support-system/blob/main/backend/Access_sheet.py): `backend/Access_sheet.py`

### Inference assets

- [MobileNetV3 model](https://github.com/tanhuy2k2/exercise-support-system/blob/main/model/MobileNetV3L_2.onnx): `model/MobileNetV3L_2.onnx`
- [Age gender labels](https://github.com/tanhuy2k2/exercise-support-system/blob/main/model/dic_labels_age.json): `model/dic_labels_age.json`
- [Gender labels](https://github.com/tanhuy2k2/exercise-support-system/blob/main/model/dic_labels_gender.json): `model/dic_labels_gender.json`
- [Push-up classifier](https://github.com/tanhuy2k2/exercise-support-system/blob/main/model/MobileNet.onnx): `model/MobileNet.onnx`

### Other components

- **Trainee**
- **Google Sheets**
- **Qdrant service**
- **MediaPipe Pose**
- **MediaPipe face detect**

## Connections

- Trainee → Face and profile: provides webcam (evidence: `README.md`)
- Face and profile → MediaPipe face detect: detects face (evidence: `frontend/js/detect_face.js`)
- Face and profile → Age gender inference: predicts profile (evidence: `frontend/js/detect_face.js`)
- Age gender inference → MobileNetV3 model: runs inference (evidence: `frontend/js/Predict_AgeGender.js`)
- Age gender inference → Age gender labels: loads labels (evidence: `frontend/js/Predict_AgeGender.js`)
- Age gender inference → Gender labels: loads labels (evidence: `frontend/js/Predict_AgeGender.js`)
- Face and profile → API worker: posts requests (evidence: `frontend/js/detect_face.js`)
- Exercise session → API worker: posts requests (evidence: `frontend/js/pose_estimation.js`)
- API worker → Flask routes: calls REST routes (evidence: `frontend/js/worker.js`)
- Flask routes → Face embedding: embeds images (evidence: `backend/main.py`)
- Flask routes → Face and progress store: verifies and updates (evidence: `backend/main.py`)
- Face and progress store → Qdrant service: reads and writes (evidence: `backend/qdrant.py`)
- Flask routes → Exercise prescriptions: requests plans (evidence: `backend/main.py`)
- Exercise prescriptions → Google Sheets: reads worksheets (evidence: `backend/Access_sheet.py`)
- Exercise session → MediaPipe Pose: tracks landmarks (evidence: `frontend/js/pose_estimation.js`)
- Exercise session → Push-up classifier: uses classifier
