# sswetha2121/ayurag-xai architecture

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

- Interactive diagram: https://gitdiagram.com/sswetha2121/ayurag-xai
- Repository: https://github.com/sswetha2121/ayurag-xai

## Overview

AyuRAG-XAI is a patient intake and clinician-facing Ayurvedic decision-support application. Patients enter demographic, Prakriti, lifestyle, diet, and symptom information, review it, and request personalized analysis; clinicians can inspect patient records and manage reviews and diet plans. The frontend includes demo analysis, while the backend contains clinical personalization and classical-text retrieval services. The README describes ML, SHAP, and LIME capabilities, but the sampled source does not establish their implementation or runtime wiring, so those links are not asserted.

Main entry points: [`src/pages`](https://github.com/sswetha2121/ayurag-xai/tree/main/src/pages) (Assessment stages), [`src/context/AssessmentContext.jsx`](https://github.com/sswetha2121/ayurag-xai/blob/main/src/context/AssessmentContext.jsx) (Assessment state), [`backend/clinical/services/personalization.py`](https://github.com/sswetha2121/ayurag-xai/blob/main/backend/clinical/services/personalization.py) (Personalization service), [`src/services/api.js`](https://github.com/sswetha2121/ayurag-xai/blob/main/src/services/api.js) (API client)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_patient_workflow["Patient assessment"]
  node_app_routes["Application routes<br/>[App.jsx]"]
  node_assessment_pages["Assessment stages"]
  node_assessment_engine["Assessment engine"]
  node_assessment_state["Assessment state"]
  node_review_page["Assessment review<br/>[ReviewPage.jsx]"]
  node_dashboard["Patient dashboard<br/>[DashboardPage.jsx]"]
  node_diet_questions["Diet assessment content<br/>[dietQuestions.js]"]
  node_lifestyle_questions["Lifestyle assessment content"]
  node_symptom_questions["Symptom assessment content"]
end

subgraph group_analysis["Clinical analysis"]
  node_profile_derivation["Profile derivation<br/>[personalization.js]"]
  node_demo_analysis["Demo analysis<br/>[mockAnalysis.js]"]
  node_personalization_service["Personalization service<br/>[personalization.py]"]
  node_rag_service["Classical knowledge retrieval<br/>[rag_service.py]"]
end

subgraph group_clinical_data["Clinical data"]
  node_clinical_api["Clinical API<br/>[views.py]"]
  node_patient_resolver["Patient data resolver"]
  node_clinical_records[("Clinical records<br/>[models.py]")]
  node_api_client["API client<br/>[api.js]"]
end

subgraph group_care_team["Clinician workspace"]
  node_doctor_workspace["Doctor workspace"]
  node_doctor_reviews["Review management"]
  node_review_notes["Review notes form"]
end

subgraph group_identity["Identity and access"]
  node_account_records[("Account records<br/>[models.py]")]
  node_auth_context["Frontend authentication<br/>[AuthContext.jsx]"]
end

node_patient(("Patient"))
node_clinician(("Clinician"))

node_patient -->|"opens"| node_app_routes
node_app_routes -->|"routes to"| node_assessment_pages
node_assessment_pages -.->|"uses"| node_assessment_engine
node_assessment_engine -.->|"records answers"| node_assessment_state
node_review_page -->|"reviews and submits"| node_assessment_state
node_assessment_state -->|"generates demo analysis"| node_demo_analysis
node_assessment_state -->|"derives profile"| node_profile_derivation
node_assessment_state -.->|"may request analysis"| node_clinical_api
node_clinical_api -.->|"may invoke"| node_personalization_service
node_personalization_service -->|"uses patient data"| node_patient_resolver
node_personalization_service -->|"retrieves knowledge"| node_rag_service
node_patient_resolver -->|"reads"| node_clinical_records
node_patient_resolver -->|"reads"| node_account_records
node_personalization_service -->|"accesses"| node_clinical_records
node_app_routes -->|"routes to"| node_dashboard
node_clinician -.->|"opens"| node_doctor_workspace
node_doctor_workspace -.->|"loads clinical data"| node_api_client
node_doctor_reviews -->|"loads and saves reviews"| node_api_client
node_doctor_reviews -->|"opens form"| node_review_notes
node_api_client -.->|"sends HTTP requests"| node_clinical_api
node_auth_context -->|"authenticates through"| node_api_client
node_assessment_pages -.->|"uses content"| node_diet_questions
node_assessment_pages -.->|"uses content"| node_lifestyle_questions
node_assessment_pages -.->|"uses content"| node_symptom_questions

click node_app_routes "https://github.com/sswetha2121/ayurag-xai/blob/main/src/App.jsx"
click node_assessment_pages "https://github.com/sswetha2121/ayurag-xai/tree/main/src/pages"
click node_assessment_engine "https://github.com/sswetha2121/ayurag-xai/blob/main/src/components/assessment/AssessmentEngine.jsx"
click node_assessment_state "https://github.com/sswetha2121/ayurag-xai/blob/main/src/context/AssessmentContext.jsx"
click node_review_page "https://github.com/sswetha2121/ayurag-xai/blob/main/src/pages/ReviewPage.jsx"
click node_dashboard "https://github.com/sswetha2121/ayurag-xai/blob/main/src/pages/DashboardPage.jsx"
click node_profile_derivation "https://github.com/sswetha2121/ayurag-xai/blob/main/src/utils/personalization.js"
click node_demo_analysis "https://github.com/sswetha2121/ayurag-xai/blob/main/src/data/mockAnalysis.js"
click node_clinical_api "https://github.com/sswetha2121/ayurag-xai/blob/main/backend/clinical/views.py"
click node_personalization_service "https://github.com/sswetha2121/ayurag-xai/blob/main/backend/clinical/services/personalization.py"
click node_patient_resolver "https://github.com/sswetha2121/ayurag-xai/blob/main/backend/clinical/services/patient_data_resolver.py"
click node_rag_service "https://github.com/sswetha2121/ayurag-xai/blob/main/backend/clinical/services/rag_service.py"
click node_clinical_records "https://github.com/sswetha2121/ayurag-xai/blob/main/backend/clinical/models.py"
click node_account_records "https://github.com/sswetha2121/ayurag-xai/blob/main/backend/accounts/models.py"
click node_auth_context "https://github.com/sswetha2121/ayurag-xai/blob/main/src/context/AuthContext.jsx"
click node_api_client "https://github.com/sswetha2121/ayurag-xai/blob/main/src/services/api.js"
click node_doctor_workspace "https://github.com/sswetha2121/ayurag-xai/blob/main/src/pages/DoctorDashboardPage.jsx"
click node_doctor_reviews "https://github.com/sswetha2121/ayurag-xai/blob/main/src/pages/DoctorReviewsPage.jsx"
click node_review_notes "https://github.com/sswetha2121/ayurag-xai/blob/main/src/components/doctor/DoctorReviewNotesModal.jsx"
click node_diet_questions "https://github.com/sswetha2121/ayurag-xai/blob/main/src/data/dietQuestions.js"
click node_lifestyle_questions "https://github.com/sswetha2121/ayurag-xai/blob/main/src/data/lifestyleQuestions.js"
click node_symptom_questions "https://github.com/sswetha2121/ayurag-xai/blob/main/src/data/symptomQuestions.js"

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_routes,node_assessment_pages,node_assessment_engine,node_assessment_state,node_review_page,node_dashboard,node_diet_questions,node_lifestyle_questions,node_symptom_questions toneBlue
class node_profile_derivation,node_demo_analysis,node_personalization_service,node_rag_service toneAmber
class node_clinical_api,node_patient_resolver,node_clinical_records,node_api_client toneMint
class node_doctor_workspace,node_doctor_reviews,node_review_notes toneRose
class node_account_records,node_auth_context,node_patient,node_clinician toneIndigo
```

## Components

### Patient assessment

- [Application routes](https://github.com/sswetha2121/ayurag-xai/blob/main/src/App.jsx): `src/App.jsx`
- [Assessment stages](https://github.com/sswetha2121/ayurag-xai/tree/main/src/pages): `src/pages`
- [Assessment engine](https://github.com/sswetha2121/ayurag-xai/blob/main/src/components/assessment/AssessmentEngine.jsx): `src/components/assessment/AssessmentEngine.jsx`
- [Assessment state](https://github.com/sswetha2121/ayurag-xai/blob/main/src/context/AssessmentContext.jsx): `src/context/AssessmentContext.jsx`
- [Assessment review](https://github.com/sswetha2121/ayurag-xai/blob/main/src/pages/ReviewPage.jsx): `src/pages/ReviewPage.jsx`
- [Patient dashboard](https://github.com/sswetha2121/ayurag-xai/blob/main/src/pages/DashboardPage.jsx): `src/pages/DashboardPage.jsx`
- [Diet assessment content](https://github.com/sswetha2121/ayurag-xai/blob/main/src/data/dietQuestions.js): `src/data/dietQuestions.js`
- [Lifestyle assessment content](https://github.com/sswetha2121/ayurag-xai/blob/main/src/data/lifestyleQuestions.js): `src/data/lifestyleQuestions.js`
- [Symptom assessment content](https://github.com/sswetha2121/ayurag-xai/blob/main/src/data/symptomQuestions.js): `src/data/symptomQuestions.js`

### Clinical analysis

- [Profile derivation](https://github.com/sswetha2121/ayurag-xai/blob/main/src/utils/personalization.js): `src/utils/personalization.js`
- [Demo analysis](https://github.com/sswetha2121/ayurag-xai/blob/main/src/data/mockAnalysis.js): `src/data/mockAnalysis.js`
- [Personalization service](https://github.com/sswetha2121/ayurag-xai/blob/main/backend/clinical/services/personalization.py): `backend/clinical/services/personalization.py`
- [Classical knowledge retrieval](https://github.com/sswetha2121/ayurag-xai/blob/main/backend/clinical/services/rag_service.py): `backend/clinical/services/rag_service.py`

### Clinical data

- [Clinical API](https://github.com/sswetha2121/ayurag-xai/blob/main/backend/clinical/views.py): `backend/clinical/views.py`
- [Patient data resolver](https://github.com/sswetha2121/ayurag-xai/blob/main/backend/clinical/services/patient_data_resolver.py): `backend/clinical/services/patient_data_resolver.py`
- [Clinical records](https://github.com/sswetha2121/ayurag-xai/blob/main/backend/clinical/models.py): `backend/clinical/models.py`
- [API client](https://github.com/sswetha2121/ayurag-xai/blob/main/src/services/api.js): `src/services/api.js`

### Clinician workspace

- [Doctor workspace](https://github.com/sswetha2121/ayurag-xai/blob/main/src/pages/DoctorDashboardPage.jsx): `src/pages/DoctorDashboardPage.jsx`
- [Review management](https://github.com/sswetha2121/ayurag-xai/blob/main/src/pages/DoctorReviewsPage.jsx): `src/pages/DoctorReviewsPage.jsx`
- [Review notes form](https://github.com/sswetha2121/ayurag-xai/blob/main/src/components/doctor/DoctorReviewNotesModal.jsx): `src/components/doctor/DoctorReviewNotesModal.jsx`

### Identity and access

- [Account records](https://github.com/sswetha2121/ayurag-xai/blob/main/backend/accounts/models.py): `backend/accounts/models.py`
- [Frontend authentication](https://github.com/sswetha2121/ayurag-xai/blob/main/src/context/AuthContext.jsx): `src/context/AuthContext.jsx`

### Other components

- **Patient**
- **Clinician**

## Connections

- Patient → Application routes: opens (evidence: `src/App.jsx`)
- Application routes → Assessment stages: routes to (evidence: `src/App.jsx`)
- Assessment stages → Assessment engine: uses
- Assessment engine → Assessment state: records answers
- Assessment review → Assessment state: reviews and submits (evidence: `src/pages/ReviewPage.jsx`)
- Assessment state → Demo analysis: generates demo analysis (evidence: `src/context/AssessmentContext.jsx`)
- Assessment state → Profile derivation: derives profile (evidence: `src/context/AssessmentContext.jsx`)
- Assessment state → Clinical API: may request analysis
- Clinical API → Personalization service: may invoke
- Personalization service → Patient data resolver: uses patient data (evidence: `backend/clinical/services/personalization.py`)
- Personalization service → Classical knowledge retrieval: retrieves knowledge (evidence: `backend/clinical/services/personalization.py`)
- Patient data resolver → Clinical records: reads (evidence: `backend/clinical/services/patient_data_resolver.py`)
- Patient data resolver → Account records: reads (evidence: `backend/clinical/services/patient_data_resolver.py`)
- Personalization service → Clinical records: accesses (evidence: `backend/clinical/services/personalization.py`)
- Application routes → Patient dashboard: routes to (evidence: `src/App.jsx`)
- Clinician → Doctor workspace: opens
- Doctor workspace → API client: loads clinical data
- Review management → API client: loads and saves reviews (evidence: `src/pages/DoctorReviewsPage.jsx`)
- Review management → Review notes form: opens form (evidence: `src/pages/DoctorReviewsPage.jsx`)
- API client → Clinical API: sends HTTP requests
- Frontend authentication → API client: authenticates through (evidence: `src/context/AuthContext.jsx`)
- Assessment stages → Diet assessment content: uses content
- Assessment stages → Lifestyle assessment content: uses content
- Assessment stages → Symptom assessment content: uses content
