# vijayanish11/yogasage architecture

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

- Interactive diagram: https://gitdiagram.com/vijayanish11/yogasage
- Repository: https://github.com/vijayanish11/yogasage

## Overview

##### What this project is (type + purpose)
**YogaSage** is a small **AI-powered yoga training web app**. It combines:
- A **web UI** (multiple `.html` pages for different poses/flows/days)
- A **Python web backend** (strongly suggests **Django** because of `views.py`, `urls.py`, `models.py`, `db.sqlite3`)
- A **pose-accuracy ML model** shipped as static artifacts (`model.json`, `weights.bin`, `metadata.json`) which is typical of **TensorFlow.js / Teachable Machine** style models used in-browser.

The README describes modules like login, user data, BMI, recommendations, and pose accuracy. The file tree indicates:
- The app is likely **monolithic** (single backend + static pages) rather than microservices.
- Pose inference may happen **client-side** (browser loads `model.json` + `weights.bin`) with the backend used for authentication, user profile/BMI, and persistence.

##### Backend
- `models.py` → data model for users / profiles / BMI / pose sessions (likely)
- `views.py` → request handlers: render pages, accept form posts, maybe store results
- `urls.py` → URL routing to views
- `db.sqlite3` → persisted relational store (SQLite)

##### Frontend / UX pages (server-rendered templates or static)
Many `.html` pages: `home.html`, `getstarted.html`, `details.html`, plus pose pages like `triangle.html`, `diamond.html`, `treePose.html`, `warrior.html`, etc. Also “day” pages (`nday1.html`, `oday1.html`, `uday1.html`) and difficulty pages (`easy.html`).

##### ML model artifacts
- `model.json`, `weights.bin`, `metadata.json` → browser-loadable model package
This strongly suggests:
- webcam/video frames → pose/keypoints/classification → accuracy feedback in real time
- either computed in the browser (common) or served to the backend for inference (less likely with these artifacts present)

##### User / Browser
- interacts with the site
- grants webcam access for pose checking

##### Web Frontend (HTML pages + JS pose logic)
- Pages: Home/Get Started/Details; Pose pages (Triangle/Tree/Warrior/etc.); Plans (Day pages); Difficulty selection
- **Pose Accuracy UI module** (client-side): loads model artifacts and runs inference
- **Recommendation/BMI UI**: forms for user data, results display

##### ML Inference (Client-side TensorFlow.js model)
- Inputs: webcam frames (or pose landmarks)
- Model files: `model.json`, `weights.bin`, `metadata.json`
- Outputs: predicted pose class + confidence/accuracy score + feedback

##### Python Web Backend (Django app)
- `urls.py` routes requests to `views.py`
- `views.py` renders HTML / handles POSTs (login, details submission, BMI calc, storing sessions)
- `models.py` defines persistence entities

##### Database (SQLite)
- `db.sqlite3`
- stores users, profiles (age/height/weight), BMI, recommendations, pose session summaries (if implemented)

##### (Optional) External dependencies
- If TF.js is loaded from CDN, represent **CDN/External JS libraries**
- If using browser APIs: represent **Webcam API**

At minimum, show these flows:

##### Auth / Profile
- Browser → Django Backend: login/register requests
- Django Backend ↔ SQLite: read/write user records
- Django Backend → Browser: render `home.html`, `details.html`, etc.

##### User Data → BMI → Recommendation
- Browser → Django Backend: submit age/height/weight (details form)
- Django Backend: compute BMI + classification
- Django Backend ↔ SQLite: persist profile/BMI
- Django Backend → Browser: return recommended pose plan / link to pose pages

##### (If results are stored) Session logging
- Browser → Django Backend: send final score / completion event
- Django Backend ↔ SQLite: store session history
- Django Backend → Browser: confirmation/progress page

##### Architectural patterns to call out (what matters to be “accurate”)
- **Monolithic Django backend**: routing + controller logic (`views.py`) + ORM models (`models.py`) + SQLite persistence.
- **Client-side ML inference**: model artifacts strongly indicate the ML is shipped to the browser; this is important because it changes:
- latency (real-time)
- privacy (video stays on device)
- backend load (lower)
- **Page-oriented UI**: multiple distinct HTML pages mapped from Django routes (or served statically).

Tell the engineer to confirm these from `urls.py`, `views.py`, and the HTML pages:
- Actual routes (e.g., `/login`, `/details`, `/pose/triangle`, etc.)
- Whether the HTML is Django templates or static served files
- Whether pose inference truly runs client-side (look for TF.js usage in HTML/JS)
- Whether pose results are posted back to backend (session history) or kept local only
- What entities exist in `models.py` (UserProfile, BMIRecord, PoseSession, etc.)

##### “Don’t overthink it” decomposition (max components)
To follow your guideline of separating into as many components as possible, break it into:
- UI Pages: Home, Get Started, Details, Easy, Day Plans, Pose Pages (Triangle/Tree/Warrior/etc.)
- Backend Modules: Auth, User Profile/Data Collection, BMI Calc, BMI Classification, Recommendation, Session Logging
- ML Modules: Model Loader, Webcam Capture, Preprocessing, Inference, Feedback Renderer
- Data: Users, Profiles, BMI, Recommendations, Sessions

## Diagram (Mermaid)

```mermaid
flowchart TD
  %% =========================
  %% Diagram A — Context (C4 L1)
  %% =========================
  subgraph "Diagram A — Context (C4 Level 1)"
    direction TB
    User["User"]:::external

    System["YogaSage (AI-powered yoga training web app)"]:::system

    WebcamAPI["Webcam / MediaDevices API (Browser)"]:::external
    CDN["External CDN (TF.js runtime / JS libs)"]:::external
  end

  User -->|"uses"| System
  System -->|"requestsCameraAccess"| WebcamAPI
  System -->|"loadsRuntimeLibraries"| CDN

  %% ==================================
  %% Diagram B — Containers (C4 Level 2)
  %% ==================================
  subgraph "Diagram B — Containers (C4 Level 2)"
    direction TB

    subgraph "Client (Browser)"
      direction TB
      BrowserUI["Web UI (HTML pages + JS)"]:::client
      ClientML["Client-side ML Inference (TensorFlow.js)"]:::ml
      ModelArtifacts["ML Model Artifacts (model.json + weights.bin + metadata.json)"]:::artifact
    end

    subgraph "Server (Django)"
      direction TB
      DjangoApp["Python Web Backend (Django monolith)"]:::backend
    end

    subgraph "Data"
      direction TB
      SQLite[("SQLite Database")]:::data
    end
  end

  User -->|"navigatesPages"| BrowserUI
  BrowserUI -->|"HTTP_GET_pageRender"| DjangoApp
  BrowserUI -->|"HTTP_POST_login/profile/BMI"| DjangoApp
  DjangoApp <-->|"ORM_read/write"| SQLite

  BrowserUI -->|"loadsModelFiles"| ModelArtifacts
  BrowserUI -->|"runsInference"| ClientML
  ClientML -->|"reads"| ModelArtifacts
  BrowserUI -->|"webcamFrames"| ClientML
  ClientML -->|"poseClass+confidence+feedback"| BrowserUI

  BrowserUI -->|"HTTP_POST_sessionSummary(optional)"| DjangoApp

  %% =================================================
  %% Diagram C — Components (Backend + Client ML detail)
  %% =================================================
  subgraph "Diagram C — Components (Backend + Client ML)"
    direction TB

    subgraph "Client Components"
      direction TB

      subgraph "UI Pages / Templates"
        direction TB
        Home["Home page"]:::page
        GetStarted["Get Started page"]:::page
        Details["User Details / BMI input"]:::page
        Difficulty["Difficulty selection (Easy)"]:::page

        subgraph "Plan Pages (Day flows)"
          direction TB
          NDay1["nday1 (plan/day)"]:::page
          ODay1["oday1 (plan/day)"]:::page
          UDay1["uday1 (plan/day)"]:::page
        end

        subgraph "Pose Pages"
          direction TB
          Triangle["Triangle pose page"]:::page
          TreePose["Tree pose page"]:::page
          Warrior["Warrior pose page"]:::page
          Diamond["Diamond pose page"]:::page
          Goddess["Goddess pose page"]:::page
        end

        EndPage["End / Completion page"]:::page
      end

      subgraph "Pose Accuracy Module (in-browser)"
        direction TB
        WebcamCapture["Webcam Capture"]:::ml
        Preprocess["Preprocessing"]:::ml
        Inference["Inference (TF.js runtime)"]:::ml
        FeedbackUI["Feedback Renderer (overlay/guidance)"]:::ml

        ModelJSON["model.json"]:::artifact
        WeightsBIN["weights.bin"]:::artifact
        MetadataJSON["metadata.json"]:::artifact
      end
    end

    subgraph "Backend Components (Django)"
      direction TB
      URLConf["urls.py (Routing)"]:::backend
      Views["views.py (Request handlers / controllers)"]:::backend
      Models["models.py (ORM models)"]:::backend

      AuthModule["Auth (login/register)"]:::backend
      ProfileModule["User Profile / Data collection"]:::backend
      BMIModule["BMI calculation + classification"]:::backend
      RecommendModule["Recommendations (pose plan)"]:::backend
      SessionModule["Session logging (optional)"]:::backend

      DBFile[("db.sqlite3")]:::data
    end
  end

  %% Client navigation + backend interactions
  Home -->|"linksTo"| GetStarted
  GetStarted -->|"startsFlow"| Details
  Details -->|"POST_details"| Views
  Difficulty -->|"selectsPlan"| NDay1
  Difficulty -->|"selectsPlan"| ODay1
  Difficulty -->|"selectsPlan"| UDay1
  NDay1 -->|"opensPose"| Triangle
  ODay1 -->|"opensPose"| TreePose
  UDay1 -->|"opensPose"| Warrior
  Triangle -->|"complete"| EndPage
  TreePose -->|"complete"| EndPage
  Warrior -->|"complete"| EndPage
  Diamond -->|"complete"| EndPage
  Goddess -->|"complete"| EndPage

  %% Pose accuracy real-time loop
  Triangle -->|"usesPoseAccuracy"| WebcamCapture
  TreePose -->|"usesPoseAccuracy"| WebcamCapture
  Warrior -->|"usesPoseAccuracy"| WebcamCapture
  Diamond -->|"usesPoseAccuracy"| WebcamCapture
  Goddess -->|"usesPoseAccuracy"| WebcamCapture

  WebcamCapture -->|"frames"| Preprocess
  Preprocess -->|"tensors/features"| Inference
  Inference -->|"poseClass+confidence"| FeedbackUI
  FeedbackUI -->|"UI_updates"| Triangle
  FeedbackUI -->|"UI_updates"| TreePose
  FeedbackUI -->|"UI_updates"| Warrior
  FeedbackUI -->|"UI_updates"| Diamond
  FeedbackUI -->|"UI_updates"| Goddess

  Inference -->|"loads"| ModelJSON
  Inference -->|"loads"| WeightsBIN
  Inference -->|"loads"| MetadataJSON

  %% Backend request flow breakdown
  URLConf -->|"routesTo"| Views
  Views -->|"uses"| AuthModule
  Views -->|"uses"| ProfileModule
  Views -->|"uses"| BMIModule
  Views -->|"uses"| RecommendModule
  Views -->|"uses"| SessionModule
  Views -->|"reads/writes"| Models
  Models -->|"persists"| DBFile

  BrowserUI -->|"GET/POST"| URLConf
  EndPage -->|"POST_sessionSummary(optional)"| Views

  %% =========================
  %% Click Events (mapped paths)
  %% =========================
  click URLConf "https://github.com/vijayanish11/yogasage/blob/main/urls.py"
  click Views "https://github.com/vijayanish11/yogasage/blob/main/views.py"
  click Models "https://github.com/vijayanish11/yogasage/blob/main/models.py"
  click DBFile "https://github.com/vijayanish11/yogasage/blob/main/db.sqlite3"

  click Home "https://github.com/vijayanish11/yogasage/blob/main/home.html"
  click GetStarted "https://github.com/vijayanish11/yogasage/blob/main/getstarted.html"
  click Details "https://github.com/vijayanish11/yogasage/blob/main/details.html"
  click Difficulty "https://github.com/vijayanish11/yogasage/blob/main/easy.html"
  click NDay1 "https://github.com/vijayanish11/yogasage/blob/main/nday1.html"
  click ODay1 "https://github.com/vijayanish11/yogasage/blob/main/oday1.html"
  click UDay1 "https://github.com/vijayanish11/yogasage/blob/main/uday1.html"
  click Triangle "https://github.com/vijayanish11/yogasage/blob/main/triangle.html"
  click TreePose "https://github.com/vijayanish11/yogasage/blob/main/treePose.html"
  click Warrior "https://github.com/vijayanish11/yogasage/blob/main/warrior.html"
  click Diamond "https://github.com/vijayanish11/yogasage/blob/main/diamond.html"
  click Goddess "https://github.com/vijayanish11/yogasage/blob/main/goddess.html"
  click EndPage "https://github.com/vijayanish11/yogasage/blob/main/End.html"

  click ModelJSON "https://github.com/vijayanish11/yogasage/blob/main/model.json"
  click WeightsBIN "https://github.com/vijayanish11/yogasage/blob/main/weights.bin"
  click MetadataJSON "https://github.com/vijayanish11/yogasage/blob/main/metadata.json"
  click ModelArtifacts "https://github.com/vijayanish11/yogasage/blob/main/model.json"
  click SQLite "https://github.com/vijayanish11/yogasage/blob/main/db.sqlite3"

  %% =========================
  %% Styles (color coding)
  %% =========================
  classDef external fill:#ECEFF4,stroke:#4C566A,stroke-width:1.5px,color:#2E3440
  classDef system fill:#D8DEE9,stroke:#3B4252,stroke-width:2px,color:#2E3440

  classDef client fill:#E3F2FD,stroke:#1E88E5,stroke-width:2px,color:#0D47A1
  classDef page fill:#E8F5E9,stroke:#43A047,stroke-width:1.5px,color:#1B5E20

  classDef backend fill:#FFF3E0,stroke:#FB8C00,stroke-width:2px,color:#E65100
  classDef data fill:#F3E5F5,stroke:#8E24AA,stroke-width:2px,color:#4A148C

  classDef ml fill:#FFEBEE,stroke:#E53935,stroke-width:2px,color:#B71C1C
  classDef artifact fill:#FCE4EC,stroke:#D81B60,stroke-width:2px,color:#880E4F
```
