# deepanshumody/physiocoach architecture

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

- Interactive diagram: https://gitdiagram.com/deepanshumody/physiocoach
- Repository: https://github.com/deepanshumody/physiocoach

## Overview

PhysioCoach turns live camera video into parallel AI coaching and pose-based exercise metrics, presenting cues and progress in the browser. The README documents the main streaming and analysis workflow; source excerpts and the SOURCE INDEX confirm the server’s use of the processing, session, monitoring, and RTSP modules. Some server routing details and browser/server event wiring are not shown, so the graph limits those connections to documented relationships.

Main entry points: [`src/live_vlm_webui/server.py`](https://github.com/deepanshumody/physiocoach/blob/main/src/live_vlm_webui/server.py) (WebRTC server), [`src/live_vlm_webui/static/index.html`](https://github.com/deepanshumody/physiocoach/blob/main/src/live_vlm_webui/static/index.html) (PhysioCoach UI), [`src/live_vlm_webui/video_processor.py`](https://github.com/deepanshumody/physiocoach/blob/main/src/live_vlm_webui/video_processor.py) (Frame pipeline), [`src/live_vlm_webui/vlm_service.py`](https://github.com/deepanshumody/physiocoach/blob/main/src/live_vlm_webui/vlm_service.py) (Coaching service)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Browser experience"]
  node_browser["PhysioCoach UI<br/>[index.html]"]
end

subgraph group_runtime["Streaming runtime"]
  node_server["WebRTC server<br/>[server.py]"]
  node_processor["Frame pipeline<br/>[video_processor.py]"]
  node_rtsp["RTSP track<br/>[rtsp_track.py]"]
end

subgraph group_therapy["Therapy analysis"]
  node_exercise["Exercise library"]
  node_pose["Pose, reps and ROM<br/>[pose_detector.py]"]
  node_vlm["Coaching service<br/>[vlm_service.py]"]
end

subgraph group_support["State and monitoring"]
  node_sessions["Session manager<br/>[session_manager.py]"]
  node_database[("Session database")]
  node_monitor["System monitor<br/>[gpu_monitor.py]"]
end

node_user(("Patient"))
node_webcam(("Webcam feed"))
node_model["Local vision model"]

node_user -->|"selects exercise"| node_browser
node_webcam -->|"streams video"| node_server
node_browser -->|"starts coaching"| node_server
node_server -->|"routes frames"| node_processor
node_server -->|"starts RTSP"| node_rtsp
node_processor -->|"processes frames"| node_pose
node_processor -->|"submits frames"| node_vlm
node_vlm -->|"requests analysis"| node_model
node_server -->|"loads exercise"| node_exercise
node_server -->|"manages sessions"| node_sessions
node_sessions -->|"reads and writes"| node_database
node_server -->|"starts monitoring"| node_monitor
node_server -->|"sends feedback"| node_browser
node_browser -->|"speaks cues"| node_user

click node_browser "https://github.com/deepanshumody/physiocoach/blob/main/src/live_vlm_webui/static/index.html"
click node_server "https://github.com/deepanshumody/physiocoach/blob/main/src/live_vlm_webui/server.py"
click node_processor "https://github.com/deepanshumody/physiocoach/blob/main/src/live_vlm_webui/video_processor.py"
click node_rtsp "https://github.com/deepanshumody/physiocoach/blob/main/src/live_vlm_webui/rtsp_track.py"
click node_exercise "https://github.com/deepanshumody/physiocoach/blob/main/src/live_vlm_webui/exercise_library.py"
click node_pose "https://github.com/deepanshumody/physiocoach/blob/main/src/live_vlm_webui/pose_detector.py"
click node_vlm "https://github.com/deepanshumody/physiocoach/blob/main/src/live_vlm_webui/vlm_service.py"
click node_sessions "https://github.com/deepanshumody/physiocoach/blob/main/src/live_vlm_webui/session_manager.py"
click node_monitor "https://github.com/deepanshumody/physiocoach/blob/main/src/live_vlm_webui/gpu_monitor.py"

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_browser toneBlue
class node_server,node_processor,node_rtsp toneAmber
class node_exercise,node_pose,node_vlm toneMint
class node_sessions,node_database,node_monitor toneRose
class node_user,node_webcam,node_model toneIndigo
```

## Components

### Browser experience

- [PhysioCoach UI](https://github.com/deepanshumody/physiocoach/blob/main/src/live_vlm_webui/static/index.html): `src/live_vlm_webui/static/index.html`

### Streaming runtime

- [WebRTC server](https://github.com/deepanshumody/physiocoach/blob/main/src/live_vlm_webui/server.py): `src/live_vlm_webui/server.py`
- [Frame pipeline](https://github.com/deepanshumody/physiocoach/blob/main/src/live_vlm_webui/video_processor.py): `src/live_vlm_webui/video_processor.py`
- [RTSP track](https://github.com/deepanshumody/physiocoach/blob/main/src/live_vlm_webui/rtsp_track.py): `src/live_vlm_webui/rtsp_track.py`

### Therapy analysis

- [Exercise library](https://github.com/deepanshumody/physiocoach/blob/main/src/live_vlm_webui/exercise_library.py): `src/live_vlm_webui/exercise_library.py`
- [Pose, reps and ROM](https://github.com/deepanshumody/physiocoach/blob/main/src/live_vlm_webui/pose_detector.py): `src/live_vlm_webui/pose_detector.py`
- [Coaching service](https://github.com/deepanshumody/physiocoach/blob/main/src/live_vlm_webui/vlm_service.py): `src/live_vlm_webui/vlm_service.py`

### State and monitoring

- [Session manager](https://github.com/deepanshumody/physiocoach/blob/main/src/live_vlm_webui/session_manager.py): `src/live_vlm_webui/session_manager.py`
- **Session database**
- [System monitor](https://github.com/deepanshumody/physiocoach/blob/main/src/live_vlm_webui/gpu_monitor.py): `src/live_vlm_webui/gpu_monitor.py`

### Other components

- **Patient**
- **Webcam feed**
- **Local vision model**

## Connections

- Patient → PhysioCoach UI: selects exercise (evidence: `README.md`)
- Webcam feed → WebRTC server: streams video (evidence: `README.md`)
- PhysioCoach UI → WebRTC server: starts coaching (evidence: `README.md`)
- WebRTC server → Frame pipeline: routes frames (evidence: `README.md`)
- WebRTC server → RTSP track: starts RTSP (evidence: `src/live_vlm_webui/server.py`)
- Frame pipeline → Pose, reps and ROM: processes frames (evidence: `src/live_vlm_webui/video_processor.py`)
- Frame pipeline → Coaching service: submits frames (evidence: `src/live_vlm_webui/video_processor.py`)
- Coaching service → Local vision model: requests analysis (evidence: `README.md`)
- WebRTC server → Exercise library: loads exercise (evidence: `src/live_vlm_webui/server.py`)
- WebRTC server → Session manager: manages sessions (evidence: `src/live_vlm_webui/server.py`)
- Session manager → Session database: reads and writes (evidence: `src/live_vlm_webui/session_manager.py`)
- WebRTC server → System monitor: starts monitoring (evidence: `src/live_vlm_webui/server.py`)
- WebRTC server → PhysioCoach UI: sends feedback (evidence: `README.md`)
- PhysioCoach UI → Patient: speaks cues (evidence: `README.md`)
