# tayyabsohail/physiovision-ai-powered-physiotherapy-system architecture

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

- Interactive diagram: https://gitdiagram.com/tayyabsohail/physiovision-ai-powered-physiotherapy-system
- Repository: https://github.com/tayyabsohail/physiovision-ai-powered-physiotherapy-system

## Overview

##### Main Components
- Client Layer (Web Browser/Mobile App)
– React + Vite + Tailwind UI
– Video-capture module for live posture streaming
– Chat interface for RAG-based chatbot
- API Gateway / Load Balancer
– Single ingress point for all HTTP/WebSocket requests
– Routes requests to auth, chatbot, CV, progress-tracking services
- Authentication & User Management Service
– SignUp / SignIn / Forgot-Password flows
– Issues JWTs or OAuth tokens
- Chatbot Service (Adaptive RAG)
– Query Handler
– Retriever (Vector Database)
– LLM Interface (e.g., OpenAI, HuggingFace)
– Bilingual NLP / Translation submodule
- Computer Vision Service
– Inference Engine running Deep-Learning Pose-Estimation models (Leg Raises, Lunges, Squats, Warrior Pose)
– Real-time analysis & audio-visual feedback generator
- Progress Tracking & Analytics Service
– Stores session data, exercise performance, user progress metrics
– Exposes REST/WebSocket APIs for frontend dashboards
- Data Layer
– Relational or NoSQL Database (Users, Sessions, Progress)
– Vector Database (embeddings for RAG retrieval)
– Object Storage or Blob Storage (video snapshots, logs)
- External/Third-Party Services
– LLM Provider API
– CDN for static frontend assets
– Monitoring / Logging / Alerting (Prometheus, Grafana, ELK)

##### Relationships & Data Flows
a. User ↔ Frontend: HTTP(S) for UI, WebSocket/MediaStream for live video
b. Frontend → API Gateway: routes to
- Auth Service for login/signup
- Chatbot Service for recommendations
- CV Service for posture analysis
- Tracking Service for saving progress
c. Chatbot Service → Vector DB & LLM API: retrieval + generation
d. CV Service → Deep-Learning Models → Feedback → Frontend
e. Tracking Service → Database → Frontend dashboards
f. Shared Data Layer: all services read/write to central DB(s)

##### Architectural Patterns
- Microservices: each major feature is its own service; independently deployable
- API-First Design: consistent REST/WebSocket contracts
- RAG Pattern: separates retrieval (Vector DB) from generation (LLM)
- Real-Time Streaming: video frames via WebRTC or WebSockets to CV service
- Event-Driven Progress Tracking: emit events on exercise completion

##### Technologies & Frameworks (annotate near each component)
- Frontend: React, Vite, Tailwind CSS
- Auth: JWT / OAuth
- Chatbot: Python/NodeJS service, FAISS or Pinecone (Vector DB), OpenAI API
- CV: TensorFlow/PyTorch models, FastAPI/gRPC service
- Database: PostgreSQL/MongoDB; Redis cache (optional)
- Storage: AWS S3/GCP Cloud Storage
- Message Bus (optional): Kafka or RabbitMQ for async events

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "Client Layer"
        UI["Web Browser/Mobile App<br/>React, Vite, Tailwind UI"]:::frontend
        Video["Video Capture Module"]:::frontend
        ChatUI["Chat Interface for RAG Chatbot"]:::frontend
    end

    UI -->|HTTP/HTTPS| Gateway
    Video -->|WebSocket/MediaStream| Gateway
    ChatUI -->|WebSocket| Gateway

    Gateway["API Gateway / Load Balancer"]:::gateway

    subgraph "Backend Services"
        Auth["Authentication & User Management Service<br/>SignUp/SignIn/Forgot-Password<br/>JWT/OAuth"]:::backend
        Chatbot["Chatbot Service (Adaptive RAG)<br/>Query Handler, Retriever, NLP/Translation"]:::backend
        CV["Computer Vision Service<br/>Pose-Estimation Models, Feedback Generator"]:::backend
        Tracking["Progress Tracking & Analytics Service<br/>Session Data, Metrics"]:::backend
    end

    Gateway -->|routes HTTP| Auth
    Gateway -->|routes HTTP| Chatbot
    Gateway -->|routes HTTP| CV
    Gateway -->|routes HTTP| Tracking

    subgraph "Machine Learning Zone"
        Chatbot
        CV
    end

    Auth -->|reads/writes| DBMain[(Relational/NoSQL Database)]:::db
    Chatbot -->|queries| VectorDB[(Vector Database)]:::db
    Chatbot -->|calls| LLMCloud("LLM Provider API"):::external
    CV -->|reads/writes| DBMain
    CV -->|stores snapshots| ObjectStorage[(Object Storage / Blob Storage)]:::db
    Tracking -->|reads/writes| DBMain
    Tracking -->|streams data| UI

    subgraph "Data Layer"
        DBMain
        VectorDB
        ObjectStorage
    end

    subgraph "External Services"
        CDN("CDN for Static Frontend Assets"):::external
        Monitoring("Monitoring/Logging/Alerting<br/>Prometheus, Grafana, ELK"):::external
    end

    UI -->|fetch assets| CDN
    Auth -->|logs/metrics| Monitoring
    Chatbot -->|logs/metrics| Monitoring
    CV -->|logs/metrics| Monitoring
    Tracking -->|logs/metrics| Monitoring

    classDef frontend fill:#D0E8FF,stroke:#024;
    classDef gateway fill:#B3E5FC,stroke:#0288D1;
    classDef backend fill:#C8E6C9,stroke:#2E7D32;
    classDef db fill:#FFE0B2,stroke:#EF6C00;
    classDef external fill:#E1BEE7,stroke:#8E24AA;
```
