# ismaeeeelshaikh/medisense-ai architecture

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

- Interactive diagram: https://gitdiagram.com/ismaeeeelshaikh/medisense-ai
- Repository: https://github.com/ismaeeeelshaikh/medisense-ai

## Overview

MediSense AI is a role-based hospital platform combining patient and staff workflows with clinical decision-support models and a Hindi/English/Hinglish voice assistant. The principal workflow is a patient consultation: the assistant gathers history, grounds advice in a knowledge base, applies independent safety checks, and produces a clinician-reviewable report; urgent cases can alert staff. The graph combines README-documented product capabilities with source-index references and excerpts. Several feature links are documented but their implementing source was not sampled, so those relationships are cited to the README.

Main entry points: [`frontend/src/pages/ConsultationPage.tsx`](https://github.com/ismaeeeelshaikh/medisense-ai/blob/main/frontend/src/pages/ConsultationPage.tsx) (Clinical pages), [`backend/src/modules/ai-doctor/ai-doctor.service.ts`](https://github.com/ismaeeeelshaikh/medisense-ai/blob/main/backend/src/modules/ai-doctor/ai-doctor.service.ts) (AI Doctor service), [`frontend/src/App.tsx`](https://github.com/ismaeeeelshaikh/medisense-ai/blob/main/frontend/src/App.tsx) (Role-based app), [`backend/src/config/database.ts`](https://github.com/ismaeeeelshaikh/medisense-ai/blob/main/backend/src/config/database.ts) (Clinical database)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web["Web experience"]
  node_webapp["Role-based app<br/>[App.tsx]"]
  node_ai_page["AI Doctor page<br/>[AiDoctorPage.tsx]"]
  node_patient_pages["Patient pages"]
  node_clinical_pages["Clinical pages"]
end

subgraph group_clinical["Hospital workflows"]
  node_patient_records["Patient records<br/>[patient.service.ts]"]
  node_appointments["Appointments"]
  node_consultations["Consultation workflow"]
  node_vitals["Vitals monitoring<br/>[vitals.service.ts]"]
  node_labs["Lab workflow<br/>[lab.service.ts]"]
  node_billing["Billing<br/>[billing.service.ts]"]
  node_alerts["Clinical alerts<br/>[alert.service.ts]"]
  node_reports["Reports and PDFs<br/>[report.service.ts]"]
end

subgraph group_assistant["AI consultation"]
  node_ai_backend["AI Doctor service"]
  node_safety["Safety checks"]
  node_knowledge["Knowledge retrieval<br/>[retriever.py]"]
end

subgraph group_ml["Clinical intelligence"]
  node_ml_api["ML API<br/>[main.py]"]
  node_risk_models["Risk prediction<br/>[bayesian_engine.py]"]
end

subgraph group_platform["Platform services"]
  node_auth["Identity and roles<br/>[auth.service.ts]"]
  node_data_store[("Clinical database<br/>[database.ts]")]
  node_realtime["Realtime events<br/>[socket.ts]"]
end

node_patient(("Patient"))
node_clinician(("Clinician"))
node_voice_provider["Voice provider"]

node_patient -->|"uses"| node_webapp
node_clinician -->|"uses"| node_webapp
node_webapp -->|"routes to"| node_ai_page
node_webapp -->|"routes to"| node_patient_pages
node_webapp -->|"routes to"| node_clinical_pages
node_patient -->|"registers"| node_auth
node_auth -->|"reads and writes"| node_data_store
node_ai_page -->|"starts and saves calls"| node_ai_backend
node_ai_backend -->|"starts voice call"| node_voice_provider
node_voice_provider -->|"returns transcript"| node_ai_backend
node_ai_backend -->|"grounds advice"| node_knowledge
node_ai_backend -->|"checks contraindications"| node_safety
node_ai_backend -->|"raises urgent alerts"| node_alerts
node_ai_backend -->|"creates report"| node_reports
node_reports -->|"presents report"| node_clinician
node_patient_pages -.->|"manages records"| node_patient_records
node_clinical_pages -.->|"manages scheduling"| node_appointments
node_clinical_pages -.->|"handles consultations"| node_consultations
node_clinical_pages -.->|"monitors vitals"| node_vitals
node_clinical_pages -.->|"handles lab work"| node_labs
node_clinical_pages -.->|"handles billing"| node_billing
node_clinical_pages -.->|"reviews alerts"| node_alerts
node_ml_api -->|"routes inference"| node_risk_models
node_ml_api -->|"warms retrieval"| node_knowledge
node_vitals -.->|"publishes updates"| node_realtime
node_alerts -.->|"publishes alerts"| node_realtime
node_appointments -->|"reads and writes"| node_data_store
node_labs -->|"reads and writes"| node_data_store
node_patient_records -.->|"reads and writes"| node_data_store

click node_webapp "https://github.com/ismaeeeelshaikh/medisense-ai/blob/main/frontend/src/App.tsx"
click node_ai_page "https://github.com/ismaeeeelshaikh/medisense-ai/blob/main/frontend/src/pages/AiDoctorPage.tsx"
click node_patient_pages "https://github.com/ismaeeeelshaikh/medisense-ai/blob/main/frontend/src/pages/PatientPortalPage.tsx"
click node_clinical_pages "https://github.com/ismaeeeelshaikh/medisense-ai/blob/main/frontend/src/pages/ConsultationPage.tsx"
click node_auth "https://github.com/ismaeeeelshaikh/medisense-ai/blob/main/backend/src/modules/auth/auth.service.ts"
click node_patient_records "https://github.com/ismaeeeelshaikh/medisense-ai/blob/main/backend/src/modules/patients/patient.service.ts"
click node_appointments "https://github.com/ismaeeeelshaikh/medisense-ai/blob/main/backend/src/modules/appointments/appointmentRequest.service.ts"
click node_consultations "https://github.com/ismaeeeelshaikh/medisense-ai/blob/main/backend/src/modules/consultations/consultation.service.ts"
click node_vitals "https://github.com/ismaeeeelshaikh/medisense-ai/blob/main/backend/src/modules/vitals/vitals.service.ts"
click node_labs "https://github.com/ismaeeeelshaikh/medisense-ai/blob/main/backend/src/modules/lab/lab.service.ts"
click node_billing "https://github.com/ismaeeeelshaikh/medisense-ai/blob/main/backend/src/modules/billing/billing.service.ts"
click node_alerts "https://github.com/ismaeeeelshaikh/medisense-ai/blob/main/backend/src/modules/alerts/alert.service.ts"
click node_reports "https://github.com/ismaeeeelshaikh/medisense-ai/blob/main/backend/src/modules/reports/report.service.ts"
click node_ai_backend "https://github.com/ismaeeeelshaikh/medisense-ai/blob/main/backend/src/modules/ai-doctor/ai-doctor.service.ts"
click node_safety "https://github.com/ismaeeeelshaikh/medisense-ai/blob/main/backend/src/modules/ai-doctor/emergencyDetection.ts"
click node_knowledge "https://github.com/ismaeeeelshaikh/medisense-ai/blob/main/ml-service/app/rag/retriever.py"
click node_ml_api "https://github.com/ismaeeeelshaikh/medisense-ai/blob/main/ml-service/app/main.py"
click node_risk_models "https://github.com/ismaeeeelshaikh/medisense-ai/blob/main/ml-service/app/api/routes/bayesian_engine.py"
click node_data_store "https://github.com/ismaeeeelshaikh/medisense-ai/blob/main/backend/src/config/database.ts"
click node_realtime "https://github.com/ismaeeeelshaikh/medisense-ai/blob/main/backend/src/config/socket.ts"

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_webapp,node_ai_page,node_patient_pages,node_clinical_pages toneBlue
class node_patient_records,node_appointments,node_consultations,node_vitals,node_labs,node_billing,node_alerts,node_reports toneAmber
class node_ai_backend,node_safety,node_knowledge toneMint
class node_ml_api,node_risk_models toneRose
class node_auth,node_data_store,node_realtime,node_patient,node_clinician,node_voice_provider toneIndigo
```

## Components

### Web experience

- [Role-based app](https://github.com/ismaeeeelshaikh/medisense-ai/blob/main/frontend/src/App.tsx): `frontend/src/App.tsx`
- [AI Doctor page](https://github.com/ismaeeeelshaikh/medisense-ai/blob/main/frontend/src/pages/AiDoctorPage.tsx): `frontend/src/pages/AiDoctorPage.tsx`
- [Patient pages](https://github.com/ismaeeeelshaikh/medisense-ai/blob/main/frontend/src/pages/PatientPortalPage.tsx): `frontend/src/pages/PatientPortalPage.tsx`
- [Clinical pages](https://github.com/ismaeeeelshaikh/medisense-ai/blob/main/frontend/src/pages/ConsultationPage.tsx): `frontend/src/pages/ConsultationPage.tsx`

### Hospital workflows

- [Patient records](https://github.com/ismaeeeelshaikh/medisense-ai/blob/main/backend/src/modules/patients/patient.service.ts): `backend/src/modules/patients/patient.service.ts`
- [Appointments](https://github.com/ismaeeeelshaikh/medisense-ai/blob/main/backend/src/modules/appointments/appointmentRequest.service.ts): `backend/src/modules/appointments/appointmentRequest.service.ts`
- [Consultation workflow](https://github.com/ismaeeeelshaikh/medisense-ai/blob/main/backend/src/modules/consultations/consultation.service.ts): `backend/src/modules/consultations/consultation.service.ts`
- [Vitals monitoring](https://github.com/ismaeeeelshaikh/medisense-ai/blob/main/backend/src/modules/vitals/vitals.service.ts): `backend/src/modules/vitals/vitals.service.ts`
- [Lab workflow](https://github.com/ismaeeeelshaikh/medisense-ai/blob/main/backend/src/modules/lab/lab.service.ts): `backend/src/modules/lab/lab.service.ts`
- [Billing](https://github.com/ismaeeeelshaikh/medisense-ai/blob/main/backend/src/modules/billing/billing.service.ts): `backend/src/modules/billing/billing.service.ts`
- [Clinical alerts](https://github.com/ismaeeeelshaikh/medisense-ai/blob/main/backend/src/modules/alerts/alert.service.ts): `backend/src/modules/alerts/alert.service.ts`
- [Reports and PDFs](https://github.com/ismaeeeelshaikh/medisense-ai/blob/main/backend/src/modules/reports/report.service.ts): `backend/src/modules/reports/report.service.ts`

### AI consultation

- [AI Doctor service](https://github.com/ismaeeeelshaikh/medisense-ai/blob/main/backend/src/modules/ai-doctor/ai-doctor.service.ts): `backend/src/modules/ai-doctor/ai-doctor.service.ts`
- [Safety checks](https://github.com/ismaeeeelshaikh/medisense-ai/blob/main/backend/src/modules/ai-doctor/emergencyDetection.ts): `backend/src/modules/ai-doctor/emergencyDetection.ts`
- [Knowledge retrieval](https://github.com/ismaeeeelshaikh/medisense-ai/blob/main/ml-service/app/rag/retriever.py): `ml-service/app/rag/retriever.py`

### Clinical intelligence

- [ML API](https://github.com/ismaeeeelshaikh/medisense-ai/blob/main/ml-service/app/main.py): `ml-service/app/main.py`
- [Risk prediction](https://github.com/ismaeeeelshaikh/medisense-ai/blob/main/ml-service/app/api/routes/bayesian_engine.py): `ml-service/app/api/routes/bayesian_engine.py`

### Platform services

- [Identity and roles](https://github.com/ismaeeeelshaikh/medisense-ai/blob/main/backend/src/modules/auth/auth.service.ts): `backend/src/modules/auth/auth.service.ts`
- [Clinical database](https://github.com/ismaeeeelshaikh/medisense-ai/blob/main/backend/src/config/database.ts): `backend/src/config/database.ts`
- [Realtime events](https://github.com/ismaeeeelshaikh/medisense-ai/blob/main/backend/src/config/socket.ts): `backend/src/config/socket.ts`

### Other components

- **Patient**
- **Clinician**
- **Voice provider**

## Connections

- Patient → Role-based app: uses (evidence: `README.md`)
- Clinician → Role-based app: uses (evidence: `README.md`)
- Role-based app → AI Doctor page: routes to (evidence: `frontend/src/App.tsx`)
- Role-based app → Patient pages: routes to (evidence: `frontend/src/App.tsx`)
- Role-based app → Clinical pages: routes to (evidence: `frontend/src/App.tsx`)
- Patient → Identity and roles: registers (evidence: `backend/src/modules/auth/auth.service.ts`)
- Identity and roles → Clinical database: reads and writes (evidence: `backend/src/modules/auth/auth.service.ts`)
- AI Doctor page → AI Doctor service: starts and saves calls (evidence: `README.md`)
- AI Doctor service → Voice provider: starts voice call (evidence: `README.md`)
- Voice provider → AI Doctor service: returns transcript (evidence: `README.md`)
- AI Doctor service → Knowledge retrieval: grounds advice (evidence: `README.md`)
- AI Doctor service → Safety checks: checks contraindications (evidence: `README.md`)
- AI Doctor service → Clinical alerts: raises urgent alerts (evidence: `README.md`)
- AI Doctor service → Reports and PDFs: creates report (evidence: `README.md`)
- Reports and PDFs → Clinician: presents report (evidence: `README.md`)
- Patient pages → Patient records: manages records
- Clinical pages → Appointments: manages scheduling
- Clinical pages → Consultation workflow: handles consultations
- Clinical pages → Vitals monitoring: monitors vitals
- Clinical pages → Lab workflow: handles lab work
- Clinical pages → Billing: handles billing
- Clinical pages → Clinical alerts: reviews alerts
- ML API → Risk prediction: routes inference (evidence: `ml-service/app/main.py`)
- ML API → Knowledge retrieval: warms retrieval (evidence: `ml-service/app/main.py`)
- Vitals monitoring → Realtime events: publishes updates
- Clinical alerts → Realtime events: publishes alerts
- Appointments → Clinical database: reads and writes (evidence: `backend/src/modules/appointments/appointmentRequest.service.ts`)
- Lab workflow → Clinical database: reads and writes (evidence: `backend/src/modules/lab/lab.service.ts`)
- Patient records → Clinical database: reads and writes
