# saivighnesh811/meditwin architecture

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

- Interactive diagram: https://gitdiagram.com/saivighnesh811/meditwin
- Repository: https://github.com/saivighnesh811/meditwin

## Overview

MediTwin AI is a healthcare screening and intelligence platform. A user signs in, enters profile and clinical information or uploads documents and X-rays in the analysis wizard, then receives a coordinated analysis that can be saved and revisited. The backend routes requests to the ML service, whose API exposes individual and full-analysis endpoints; the multi-agent orchestrator coordinates extraction, memory, feature assembly, explanations, and recommendations. The README also identifies risk prediction and XAI as distinct capabilities. Some agent-to-agent details and frontend result rendering are unsampled, so those relationships are omitted where not evidenced.

Main entry points: [`agents/coordination/orchestrator.py`](https://github.com/saivighnesh811/meditwin/blob/main/agents/coordination/orchestrator.py) (Pipeline orchestrator), [`ml_service/routes/api.py`](https://github.com/saivighnesh811/meditwin/blob/main/ml_service/routes/api.py) (ML API), [`frontend/src/App.jsx`](https://github.com/saivighnesh811/meditwin/blob/main/frontend/src/App.jsx) (Web application), [`backend/src/app.js`](https://github.com/saivighnesh811/meditwin/blob/main/backend/src/app.js) (HTTP application)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["User application"]
  node_app["Web application<br/>[App.jsx]"]
  node_wizard["Analysis wizard<br/>[Wizard.jsx]"]
  node_api_client["API client<br/>[api.js]"]
  node_result["Analysis results"]
end

subgraph group_backend["Backend and persistence"]
  node_server["HTTP application<br/>[app.js]"]
  node_analysis_routes["Analysis routes<br/>[analysis.routes.js]"]
  node_analysis_controller["Analysis controller"]
  node_auth_controller["Authentication<br/>[auth.controller.js]"]
  node_user_store[("User records<br/>[User.js]")]
  node_analysis_store[("Analysis records<br/>[Analysis.js]")]
  node_ml_client["ML client<br/>[mlClient.js]"]
end

subgraph group_ml["ML service"]
  node_ml_api["ML API<br/>[api.py]"]
  node_inference["Inference wrapper<br/>[inference.py]"]
end

subgraph group_agents["Analysis agents"]
  node_orchestrator["Pipeline orchestrator<br/>[orchestrator.py]"]
  node_ocr["Document OCR<br/>[ocr_agent.py]"]
  node_nlp["Clinical NLP<br/>[nlp_agent.py]"]
  node_imaging["X-ray screening"]
  node_memory["Patient memory"]
  node_features["Feature assembly"]
  node_xai["Risk and XAI<br/>[xai_agent.py]"]
  node_recommend["Recommendations"]
end

subgraph group_shared["Shared inference"]
end

node_user(("Patient"))

node_user -->|"uses"| node_app
node_app -->|"routes to"| node_wizard
node_wizard -->|"submits via"| node_api_client
node_app -.->|"routes to"| node_result
node_app -.->|"calls API"| node_server
node_server -->|"mounts"| node_analysis_routes
node_analysis_routes -->|"dispatches"| node_analysis_controller
node_server -->|"mounts auth routes"| node_auth_controller
node_auth_controller -->|"reads and writes"| node_user_store
node_analysis_controller -->|"forwards requests"| node_ml_client
node_analysis_controller -->|"saves and queries"| node_analysis_store
node_ml_client -.->|"HTTP requests"| node_ml_api
node_ml_api -->|"runs inference"| node_inference
node_ml_api -->|"invokes pipeline"| node_orchestrator
node_orchestrator -->|"extracts documents"| node_ocr
node_orchestrator -->|"extracts entities"| node_nlp
node_orchestrator -->|"screens X-rays"| node_imaging
node_orchestrator -->|"updates memory"| node_memory
node_orchestrator -->|"assembles features"| node_features
node_orchestrator -->|"requests explanations"| node_xai
node_orchestrator -->|"requests recommendations"| node_recommend
node_ml_api -->|"assembles risk inputs"| node_features
node_ml_api -->|"explains risk"| node_xai

click node_app "https://github.com/saivighnesh811/meditwin/blob/main/frontend/src/App.jsx"
click node_wizard "https://github.com/saivighnesh811/meditwin/blob/main/frontend/src/pages/Wizard.jsx"
click node_api_client "https://github.com/saivighnesh811/meditwin/blob/main/frontend/src/lib/api.js"
click node_result "https://github.com/saivighnesh811/meditwin/blob/main/frontend/src/components/analysis/AnalysisResultView.jsx"
click node_server "https://github.com/saivighnesh811/meditwin/blob/main/backend/src/app.js"
click node_analysis_routes "https://github.com/saivighnesh811/meditwin/blob/main/backend/src/routes/analysis.routes.js"
click node_analysis_controller "https://github.com/saivighnesh811/meditwin/blob/main/backend/src/controllers/analysis.controller.js"
click node_auth_controller "https://github.com/saivighnesh811/meditwin/blob/main/backend/src/controllers/auth.controller.js"
click node_user_store "https://github.com/saivighnesh811/meditwin/blob/main/backend/src/models/User.js"
click node_analysis_store "https://github.com/saivighnesh811/meditwin/blob/main/backend/src/models/Analysis.js"
click node_ml_client "https://github.com/saivighnesh811/meditwin/blob/main/backend/src/services/mlClient.js"
click node_ml_api "https://github.com/saivighnesh811/meditwin/blob/main/ml_service/routes/api.py"
click node_inference "https://github.com/saivighnesh811/meditwin/blob/main/ml_service/inference.py"
click node_orchestrator "https://github.com/saivighnesh811/meditwin/blob/main/agents/coordination/orchestrator.py"
click node_ocr "https://github.com/saivighnesh811/meditwin/blob/main/agents/ocr_agent/ocr_agent.py"
click node_nlp "https://github.com/saivighnesh811/meditwin/blob/main/agents/nlp_agent/nlp_agent.py"
click node_imaging "https://github.com/saivighnesh811/meditwin/blob/main/agents/medical_image_agent/medical_image_agent.py"
click node_memory "https://github.com/saivighnesh811/meditwin/blob/main/agents/patient_memory_agent/patient_memory_agent.py"
click node_features "https://github.com/saivighnesh811/meditwin/blob/main/agents/coordination/feature_assembler.py"
click node_xai "https://github.com/saivighnesh811/meditwin/blob/main/agents/xai_agent/xai_agent.py"
click node_recommend "https://github.com/saivighnesh811/meditwin/blob/main/agents/recommendation_agent/recommendation_agent.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_app,node_wizard,node_api_client,node_result toneBlue
class node_server,node_analysis_routes,node_analysis_controller,node_auth_controller,node_user_store,node_analysis_store,node_ml_client toneAmber
class node_ml_api,node_inference toneMint
class node_orchestrator,node_ocr,node_nlp,node_imaging,node_memory,node_features,node_xai,node_recommend toneRose
class node_user toneIndigo
```

## Components

### User application

- [Web application](https://github.com/saivighnesh811/meditwin/blob/main/frontend/src/App.jsx): `frontend/src/App.jsx`
- [Analysis wizard](https://github.com/saivighnesh811/meditwin/blob/main/frontend/src/pages/Wizard.jsx): `frontend/src/pages/Wizard.jsx`
- [API client](https://github.com/saivighnesh811/meditwin/blob/main/frontend/src/lib/api.js): `frontend/src/lib/api.js`
- [Analysis results](https://github.com/saivighnesh811/meditwin/blob/main/frontend/src/components/analysis/AnalysisResultView.jsx): `frontend/src/components/analysis/AnalysisResultView.jsx`

### Backend and persistence

- [HTTP application](https://github.com/saivighnesh811/meditwin/blob/main/backend/src/app.js): `backend/src/app.js`
- [Analysis routes](https://github.com/saivighnesh811/meditwin/blob/main/backend/src/routes/analysis.routes.js): `backend/src/routes/analysis.routes.js`
- [Analysis controller](https://github.com/saivighnesh811/meditwin/blob/main/backend/src/controllers/analysis.controller.js): `backend/src/controllers/analysis.controller.js`
- [Authentication](https://github.com/saivighnesh811/meditwin/blob/main/backend/src/controllers/auth.controller.js): `backend/src/controllers/auth.controller.js`
- [User records](https://github.com/saivighnesh811/meditwin/blob/main/backend/src/models/User.js): `backend/src/models/User.js`
- [Analysis records](https://github.com/saivighnesh811/meditwin/blob/main/backend/src/models/Analysis.js): `backend/src/models/Analysis.js`
- [ML client](https://github.com/saivighnesh811/meditwin/blob/main/backend/src/services/mlClient.js): `backend/src/services/mlClient.js`

### ML service

- [ML API](https://github.com/saivighnesh811/meditwin/blob/main/ml_service/routes/api.py): `ml_service/routes/api.py`
- [Inference wrapper](https://github.com/saivighnesh811/meditwin/blob/main/ml_service/inference.py): `ml_service/inference.py`

### Analysis agents

- [Pipeline orchestrator](https://github.com/saivighnesh811/meditwin/blob/main/agents/coordination/orchestrator.py): `agents/coordination/orchestrator.py`
- [Document OCR](https://github.com/saivighnesh811/meditwin/blob/main/agents/ocr_agent/ocr_agent.py): `agents/ocr_agent/ocr_agent.py`
- [Clinical NLP](https://github.com/saivighnesh811/meditwin/blob/main/agents/nlp_agent/nlp_agent.py): `agents/nlp_agent/nlp_agent.py`
- [X-ray screening](https://github.com/saivighnesh811/meditwin/blob/main/agents/medical_image_agent/medical_image_agent.py): `agents/medical_image_agent/medical_image_agent.py`
- [Patient memory](https://github.com/saivighnesh811/meditwin/blob/main/agents/patient_memory_agent/patient_memory_agent.py): `agents/patient_memory_agent/patient_memory_agent.py`
- [Feature assembly](https://github.com/saivighnesh811/meditwin/blob/main/agents/coordination/feature_assembler.py): `agents/coordination/feature_assembler.py`
- [Risk and XAI](https://github.com/saivighnesh811/meditwin/blob/main/agents/xai_agent/xai_agent.py): `agents/xai_agent/xai_agent.py`
- [Recommendations](https://github.com/saivighnesh811/meditwin/blob/main/agents/recommendation_agent/recommendation_agent.py): `agents/recommendation_agent/recommendation_agent.py`

### Other components

- **Patient**

## Connections

- Patient → Web application: uses (evidence: `frontend/src/App.jsx`)
- Web application → Analysis wizard: routes to (evidence: `frontend/src/App.jsx`)
- Analysis wizard → API client: submits via (evidence: `frontend/src/pages/Wizard.jsx`)
- Web application → Analysis results: routes to
- Web application → HTTP application: calls API
- HTTP application → Analysis routes: mounts (evidence: `backend/src/app.js`)
- Analysis routes → Analysis controller: dispatches (evidence: `backend/src/routes/analysis.routes.js`)
- HTTP application → Authentication: mounts auth routes (evidence: `backend/src/app.js`)
- Authentication → User records: reads and writes (evidence: `backend/src/controllers/auth.controller.js`)
- Analysis controller → ML client: forwards requests (evidence: `backend/src/controllers/analysis.controller.js`)
- Analysis controller → Analysis records: saves and queries (evidence: `backend/src/controllers/analysis.controller.js`)
- ML client → ML API: HTTP requests
- ML API → Inference wrapper: runs inference (evidence: `ml_service/routes/api.py`)
- ML API → Pipeline orchestrator: invokes pipeline (evidence: `ml_service/routes/api.py`)
- Pipeline orchestrator → Document OCR: extracts documents (evidence: `agents/coordination/orchestrator.py`)
- Pipeline orchestrator → Clinical NLP: extracts entities (evidence: `agents/coordination/orchestrator.py`)
- Pipeline orchestrator → X-ray screening: screens X-rays (evidence: `agents/coordination/orchestrator.py`)
- Pipeline orchestrator → Patient memory: updates memory (evidence: `agents/coordination/orchestrator.py`)
- Pipeline orchestrator → Feature assembly: assembles features (evidence: `agents/coordination/orchestrator.py`)
- Pipeline orchestrator → Risk and XAI: requests explanations (evidence: `agents/coordination/orchestrator.py`)
- Pipeline orchestrator → Recommendations: requests recommendations (evidence: `agents/coordination/orchestrator.py`)
- ML API → Feature assembly: assembles risk inputs (evidence: `ml_service/routes/api.py`)
- ML API → Risk and XAI: explains risk (evidence: `ml_service/routes/api.py`)
