# nagarjun00/ai-squat-analysis architecture

> Architecture diagram of the GitHub repository nagarjun00/ai-squat-analysis, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-12-02). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/nagarjun00/ai-squat-analysis
- Repository: https://github.com/nagarjun00/ai-squat-analysis

## Overview

SquatLab turns an uploaded side-view squat video into per-frame movement evidence, repetition summaries, and citation-grounded coaching findings. The main workflow runs from browser upload through FastAPI validation and orchestration, computer-vision tracking, then skill-based assessment and structured results. The frontend presents findings alongside a synchronized video overlay; users can also inspect the active standards. The graph includes the documented Ollama and Gemini options and deterministic fallback. Source excerpts establish backend calls and data contracts; some frontend-to-API wiring is supported by the README rather than shown source excerpts.

Main entry points: [`backend/skill_agent.py`](https://github.com/nagarjun00/ai-squat-analysis/blob/main/backend/skill_agent.py) (Assessment agent), [`frontend/src/app/page.tsx`](https://github.com/nagarjun00/ai-squat-analysis/blob/main/frontend/src/app/page.tsx) (Upload and findings), [`backend/main.py`](https://github.com/nagarjun00/ai-squat-analysis/blob/main/backend/main.py) (Analysis API), [`backend/cv_pipeline.py`](https://github.com/nagarjun00/ai-squat-analysis/blob/main/backend/cv_pipeline.py) (Tracking and reps)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_frontend["Consumer interface"]
  node_web_app["Upload and findings<br/>[page.tsx]"]
  node_video_overlay["Video overlay"]
end

subgraph group_backend["Analysis service"]
  node_api["Analysis API<br/>[main.py]"]
  node_video_intake["Video intake<br/>[main.py]"]
  node_cv["Tracking and reps<br/>[cv_pipeline.py]"]
  node_contracts["Evidence schemas<br/>[models.py]"]
end

subgraph group_assessment["Coaching assessment"]
  node_assessment_agent["Assessment agent<br/>[skill_agent.py]"]
  node_fallback["Rule fallback<br/>[skill_agent.py]"]
end

subgraph group_standards["Movement standards"]
  node_squat_skill["Squat standards<br/>[squat_standards.md]"]
end

node_user(("Lifter"))
node_ollama["Ollama"]
node_gemini["Google Gemini"]
node_browser_video["Uploaded video"]

node_user -->|"uploads video"| node_web_app
node_web_app -->|"requests analysis"| node_api
node_api -->|"validates and stages"| node_video_intake
node_video_intake -->|"analyzes video"| node_cv
node_api -->|"assesses evidence"| node_assessment_agent
node_cv -->|"builds evidence"| node_contracts
node_assessment_agent -->|"reads evidence and returns findings"| node_contracts
node_assessment_agent -->|"loads rules"| node_squat_skill
node_assessment_agent -.->|"queries optionally"| node_ollama
node_assessment_agent -.->|"queries optionally"| node_gemini
node_assessment_agent -->|"uses when unavailable"| node_fallback
node_api -->|"returns analysis"| node_web_app
node_web_app -.->|"presents tracked video"| node_video_overlay
node_browser_video -->|"plays with annotations"| node_video_overlay
node_web_app -->|"offers skill inspection"| node_squat_skill

click node_web_app "https://github.com/nagarjun00/ai-squat-analysis/blob/main/frontend/src/app/page.tsx"
click node_video_overlay "https://github.com/nagarjun00/ai-squat-analysis/blob/main/frontend/src/components/AnnotatedVideoPlayer.tsx"
click node_api "https://github.com/nagarjun00/ai-squat-analysis/blob/main/backend/main.py"
click node_video_intake "https://github.com/nagarjun00/ai-squat-analysis/blob/main/backend/main.py"
click node_cv "https://github.com/nagarjun00/ai-squat-analysis/blob/main/backend/cv_pipeline.py"
click node_contracts "https://github.com/nagarjun00/ai-squat-analysis/blob/main/backend/models.py"
click node_assessment_agent "https://github.com/nagarjun00/ai-squat-analysis/blob/main/backend/skill_agent.py"
click node_fallback "https://github.com/nagarjun00/ai-squat-analysis/blob/main/backend/skill_agent.py"
click node_squat_skill "https://github.com/nagarjun00/ai-squat-analysis/blob/main/skills/squat_standards.md"

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_web_app,node_video_overlay toneBlue
class node_api,node_video_intake,node_cv,node_contracts toneAmber
class node_assessment_agent,node_fallback toneMint
class node_squat_skill toneRose
class node_user,node_ollama,node_gemini,node_browser_video toneIndigo
```

## Components

### Consumer interface

- [Upload and findings](https://github.com/nagarjun00/ai-squat-analysis/blob/main/frontend/src/app/page.tsx): `frontend/src/app/page.tsx`
- [Video overlay](https://github.com/nagarjun00/ai-squat-analysis/blob/main/frontend/src/components/AnnotatedVideoPlayer.tsx): `frontend/src/components/AnnotatedVideoPlayer.tsx`

### Analysis service

- [Analysis API](https://github.com/nagarjun00/ai-squat-analysis/blob/main/backend/main.py): `backend/main.py`
- [Video intake](https://github.com/nagarjun00/ai-squat-analysis/blob/main/backend/main.py): `backend/main.py`
- [Tracking and reps](https://github.com/nagarjun00/ai-squat-analysis/blob/main/backend/cv_pipeline.py): `backend/cv_pipeline.py`
- [Evidence schemas](https://github.com/nagarjun00/ai-squat-analysis/blob/main/backend/models.py): `backend/models.py`

### Coaching assessment

- [Assessment agent](https://github.com/nagarjun00/ai-squat-analysis/blob/main/backend/skill_agent.py): `backend/skill_agent.py`
- [Rule fallback](https://github.com/nagarjun00/ai-squat-analysis/blob/main/backend/skill_agent.py): `backend/skill_agent.py`

### Movement standards

- [Squat standards](https://github.com/nagarjun00/ai-squat-analysis/blob/main/skills/squat_standards.md): `skills/squat_standards.md`

### Other components

- **Lifter**
- **Ollama**
- **Google Gemini**
- **Uploaded video**

## Connections

- Lifter → Upload and findings: uploads video (evidence: `README.md`)
- Upload and findings → Analysis API: requests analysis (evidence: `README.md`)
- Analysis API → Video intake: validates and stages (evidence: `backend/main.py`)
- Video intake → Tracking and reps: analyzes video (evidence: `backend/main.py`)
- Analysis API → Assessment agent: assesses evidence (evidence: `backend/main.py`)
- Tracking and reps → Evidence schemas: builds evidence (evidence: `backend/cv_pipeline.py`)
- Assessment agent → Evidence schemas: reads evidence and returns findings (evidence: `backend/skill_agent.py`)
- Assessment agent → Squat standards: loads rules (evidence: `README.md`)
- Assessment agent → Ollama: queries optionally (evidence: `README.md`)
- Assessment agent → Google Gemini: queries optionally (evidence: `README.md`)
- Assessment agent → Rule fallback: uses when unavailable (evidence: `backend/skill_agent.py`)
- Analysis API → Upload and findings: returns analysis (evidence: `README.md`)
- Upload and findings → Video overlay: presents tracked video (evidence: `README.md`)
- Uploaded video → Video overlay: plays with annotations (evidence: `frontend/src/components/AnnotatedVideoPlayer.tsx`)
- Upload and findings → Squat standards: offers skill inspection (evidence: `README.md`)
