# dhileepk-18/mediguide architecture

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

- Interactive diagram: https://gitdiagram.com/dhileepk-18/mediguide
- Repository: https://github.com/dhileepk-18/mediguide

## Overview

MediGuide is a role-based healthcare portal for patients, doctors, and administrators. Users authenticate into role-specific workflows; patients can consult the AI assistant, check symptoms, discover doctors and book appointments, and manage prescriptions, medicines, and health records, while doctors and administrators manage clinical and operational records. React pages call the Express REST API, whose controllers use MongoDB when connected and otherwise the local in-memory store. The README documents Gemini as the AI provider. Some domain modules were not sampled, so their internal call paths are not asserted here.

Main entry points: [`backend/src/server.js`](https://github.com/dhileepk-18/mediguide/blob/main/backend/src/server.js) (Express REST API), [`frontend/src/services/api.js`](https://github.com/dhileepk-18/mediguide/blob/main/frontend/src/services/api.js) (API client), [`backend/src/controllers/prescriptionController.js`](https://github.com/dhileepk-18/mediguide/blob/main/backend/src/controllers/prescriptionController.js) (Prescription management), [`frontend/src/App.jsx`](https://github.com/dhileepk-18/mediguide/blob/main/frontend/src/App.jsx) (Role-based portal)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_frontend["Web application"]
  node_webapp["Role-based portal<br/>[App.jsx]"]
  node_auth_ui["Login and registration<br/>[LoginPage.jsx]"]
  node_assistant_ui["AI assistant"]
  node_symptom_ui["Symptom checker"]
  node_appointment_ui["Appointments"]
  node_patient_records_ui["Patient records"]
  node_medicines_ui["Medicine reminders<br/>[MedicinesPage.jsx]"]
  node_prescriptions_ui["Prescriptions"]
  node_admin_ui["Administration<br/>[AdminDashboard.jsx]"]
  node_auth_state["Authentication state<br/>[authStore.js]"]
  node_api_client["API client<br/>[api.js]"]
end

subgraph group_backend["REST backend"]
  node_api_server["Express REST API<br/>[server.js]"]
  node_auth_routes["Authentication routes<br/>[authRoutes.js]"]
  node_admin_routes["Admin routes<br/>[adminRoutes.js]"]
  node_auth_controller["Authentication<br/>[authController.js]"]
  node_admin_controller["Administration<br/>[adminController.js]"]
end

subgraph group_clinical["AI and triage"]
  node_ai_controller["AI requests<br/>[aiController.js]"]
  node_ai_service["Clinical AI service<br/>[aiService.js]"]
  node_triage_engine["Triage model service<br/>[app.py]"]
end

subgraph group_records["Clinical records"]
  node_appointment_controller["Appointment management"]
  node_prescription_controller["Prescription management"]
  node_pdf_service["Prescription PDF<br/>[pdfService.js]"]
  node_health_controller["Health records"]
  node_medicine_controller["Medicine schedules"]
end

subgraph group_persistence["Persistence and identity"]
  node_database[("MongoDB<br/>[db.js]")]
  node_store[("Local data store<br/>[inMemoryStore.js]")]
  node_schemas["Domain schemas<br/>[schemas.js]"]
end

node_patient(("Patient"))
node_doctor(("Doctor"))
node_admin(("Administrator"))
node_gemini["Google Gemini"]

node_patient -->|"uses"| node_webapp
node_doctor -->|"uses"| node_webapp
node_admin -->|"uses"| node_webapp
node_webapp -->|"checks access"| node_auth_state
node_auth_ui -->|"updates session"| node_auth_state
node_auth_state -->|"requests identity"| node_api_client
node_assistant_ui -->|"sends prompts"| node_api_client
node_symptom_ui -.->|"submits symptoms"| node_api_client
node_appointment_ui -->|"books visits"| node_api_client
node_patient_records_ui -.->|"manages records"| node_api_client
node_medicines_ui -.->|"tracks doses"| node_api_client
node_prescriptions_ui -->|"manages prescriptions"| node_api_client
node_admin_ui -->|"manages operations"| node_api_client
node_api_client -->|"calls REST API"| node_api_server
node_api_server -->|"mounts routes"| node_auth_routes
node_api_server -->|"mounts routes"| node_admin_routes
node_auth_routes -->|"dispatches"| node_auth_controller
node_admin_routes -->|"dispatches"| node_admin_controller
node_api_server -.->|"serves appointment routes"| node_appointment_controller
node_api_server -->|"serves AI routes"| node_ai_controller
node_api_server -.->|"serves record routes"| node_health_controller
node_api_server -.->|"serves medicine routes"| node_medicine_controller
node_api_server -->|"serves prescription routes"| node_prescription_controller
node_auth_controller -->|"reads and writes"| node_database
node_auth_controller -->|"fallback reads and writes"| node_store
node_admin_controller -->|"reads and writes"| node_database
node_admin_controller -->|"fallback reads and writes"| node_store
node_appointment_controller -->|"reads and writes"| node_database
node_appointment_controller -->|"fallback reads and writes"| node_store
node_prescription_controller -->|"reads and writes"| node_database
node_prescription_controller -->|"fallback reads and writes"| node_store
node_prescription_controller -->|"generates PDF"| node_pdf_service
node_ai_controller -.->|"delegates requests"| node_ai_service
node_ai_service -.->|"uses provider"| node_gemini
node_symptom_ui -.->|"requests triage"| node_triage_engine

click node_webapp "https://github.com/dhileepk-18/mediguide/blob/main/frontend/src/App.jsx"
click node_auth_ui "https://github.com/dhileepk-18/mediguide/blob/main/frontend/src/pages/public/LoginPage.jsx"
click node_assistant_ui "https://github.com/dhileepk-18/mediguide/blob/main/frontend/src/pages/patient/AiAssistantPage.jsx"
click node_symptom_ui "https://github.com/dhileepk-18/mediguide/blob/main/frontend/src/pages/patient/SymptomCheckerPage.jsx"
click node_appointment_ui "https://github.com/dhileepk-18/mediguide/blob/main/frontend/src/pages/patient/AppointmentsPage.jsx"
click node_patient_records_ui "https://github.com/dhileepk-18/mediguide/blob/main/frontend/src/pages/patient/HealthRecordsPage.jsx"
click node_medicines_ui "https://github.com/dhileepk-18/mediguide/blob/main/frontend/src/pages/patient/MedicinesPage.jsx"
click node_prescriptions_ui "https://github.com/dhileepk-18/mediguide/blob/main/frontend/src/pages/doctor/DoctorPrescriptionsPage.jsx"
click node_admin_ui "https://github.com/dhileepk-18/mediguide/blob/main/frontend/src/pages/admin/AdminDashboard.jsx"
click node_auth_state "https://github.com/dhileepk-18/mediguide/blob/main/frontend/src/store/authStore.js"
click node_api_client "https://github.com/dhileepk-18/mediguide/blob/main/frontend/src/services/api.js"
click node_api_server "https://github.com/dhileepk-18/mediguide/blob/main/backend/src/server.js"
click node_auth_routes "https://github.com/dhileepk-18/mediguide/blob/main/backend/src/routes/authRoutes.js"
click node_admin_routes "https://github.com/dhileepk-18/mediguide/blob/main/backend/src/routes/adminRoutes.js"
click node_auth_controller "https://github.com/dhileepk-18/mediguide/blob/main/backend/src/controllers/authController.js"
click node_admin_controller "https://github.com/dhileepk-18/mediguide/blob/main/backend/src/controllers/adminController.js"
click node_ai_controller "https://github.com/dhileepk-18/mediguide/blob/main/backend/src/controllers/aiController.js"
click node_ai_service "https://github.com/dhileepk-18/mediguide/blob/main/backend/src/services/aiService.js"
click node_triage_engine "https://github.com/dhileepk-18/mediguide/blob/main/ml-service/app.py"
click node_appointment_controller "https://github.com/dhileepk-18/mediguide/blob/main/backend/src/controllers/appointmentController.js"
click node_prescription_controller "https://github.com/dhileepk-18/mediguide/blob/main/backend/src/controllers/prescriptionController.js"
click node_pdf_service "https://github.com/dhileepk-18/mediguide/blob/main/backend/src/services/pdfService.js"
click node_health_controller "https://github.com/dhileepk-18/mediguide/blob/main/backend/src/controllers/healthRecordController.js"
click node_medicine_controller "https://github.com/dhileepk-18/mediguide/blob/main/backend/src/controllers/medicineController.js"
click node_database "https://github.com/dhileepk-18/mediguide/blob/main/backend/src/config/db.js"
click node_store "https://github.com/dhileepk-18/mediguide/blob/main/backend/src/store/inMemoryStore.js"
click node_schemas "https://github.com/dhileepk-18/mediguide/blob/main/backend/src/models/schemas.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_webapp,node_auth_ui,node_assistant_ui,node_symptom_ui,node_appointment_ui,node_patient_records_ui,node_medicines_ui,node_prescriptions_ui,node_admin_ui,node_auth_state,node_api_client toneBlue
class node_api_server,node_auth_routes,node_admin_routes,node_auth_controller,node_admin_controller toneAmber
class node_ai_controller,node_ai_service,node_triage_engine toneMint
class node_appointment_controller,node_prescription_controller,node_pdf_service,node_health_controller,node_medicine_controller toneRose
class node_database,node_store,node_schemas,node_patient,node_doctor,node_admin,node_gemini toneIndigo
```

## Components

### Web application

- [Role-based portal](https://github.com/dhileepk-18/mediguide/blob/main/frontend/src/App.jsx): `frontend/src/App.jsx`
- [Login and registration](https://github.com/dhileepk-18/mediguide/blob/main/frontend/src/pages/public/LoginPage.jsx): `frontend/src/pages/public/LoginPage.jsx`
- [AI assistant](https://github.com/dhileepk-18/mediguide/blob/main/frontend/src/pages/patient/AiAssistantPage.jsx): `frontend/src/pages/patient/AiAssistantPage.jsx`
- [Symptom checker](https://github.com/dhileepk-18/mediguide/blob/main/frontend/src/pages/patient/SymptomCheckerPage.jsx): `frontend/src/pages/patient/SymptomCheckerPage.jsx`
- [Appointments](https://github.com/dhileepk-18/mediguide/blob/main/frontend/src/pages/patient/AppointmentsPage.jsx): `frontend/src/pages/patient/AppointmentsPage.jsx`
- [Patient records](https://github.com/dhileepk-18/mediguide/blob/main/frontend/src/pages/patient/HealthRecordsPage.jsx): `frontend/src/pages/patient/HealthRecordsPage.jsx`
- [Medicine reminders](https://github.com/dhileepk-18/mediguide/blob/main/frontend/src/pages/patient/MedicinesPage.jsx): `frontend/src/pages/patient/MedicinesPage.jsx`
- [Prescriptions](https://github.com/dhileepk-18/mediguide/blob/main/frontend/src/pages/doctor/DoctorPrescriptionsPage.jsx): `frontend/src/pages/doctor/DoctorPrescriptionsPage.jsx`
- [Administration](https://github.com/dhileepk-18/mediguide/blob/main/frontend/src/pages/admin/AdminDashboard.jsx): `frontend/src/pages/admin/AdminDashboard.jsx`
- [Authentication state](https://github.com/dhileepk-18/mediguide/blob/main/frontend/src/store/authStore.js): `frontend/src/store/authStore.js`
- [API client](https://github.com/dhileepk-18/mediguide/blob/main/frontend/src/services/api.js): `frontend/src/services/api.js`

### REST backend

- [Express REST API](https://github.com/dhileepk-18/mediguide/blob/main/backend/src/server.js): `backend/src/server.js`
- [Authentication routes](https://github.com/dhileepk-18/mediguide/blob/main/backend/src/routes/authRoutes.js): `backend/src/routes/authRoutes.js`
- [Admin routes](https://github.com/dhileepk-18/mediguide/blob/main/backend/src/routes/adminRoutes.js): `backend/src/routes/adminRoutes.js`
- [Authentication](https://github.com/dhileepk-18/mediguide/blob/main/backend/src/controllers/authController.js): `backend/src/controllers/authController.js`
- [Administration](https://github.com/dhileepk-18/mediguide/blob/main/backend/src/controllers/adminController.js): `backend/src/controllers/adminController.js`

### AI and triage

- [AI requests](https://github.com/dhileepk-18/mediguide/blob/main/backend/src/controllers/aiController.js): `backend/src/controllers/aiController.js`
- [Clinical AI service](https://github.com/dhileepk-18/mediguide/blob/main/backend/src/services/aiService.js): `backend/src/services/aiService.js`
- [Triage model service](https://github.com/dhileepk-18/mediguide/blob/main/ml-service/app.py): `ml-service/app.py`

### Clinical records

- [Appointment management](https://github.com/dhileepk-18/mediguide/blob/main/backend/src/controllers/appointmentController.js): `backend/src/controllers/appointmentController.js`
- [Prescription management](https://github.com/dhileepk-18/mediguide/blob/main/backend/src/controllers/prescriptionController.js): `backend/src/controllers/prescriptionController.js`
- [Prescription PDF](https://github.com/dhileepk-18/mediguide/blob/main/backend/src/services/pdfService.js): `backend/src/services/pdfService.js`
- [Health records](https://github.com/dhileepk-18/mediguide/blob/main/backend/src/controllers/healthRecordController.js): `backend/src/controllers/healthRecordController.js`
- [Medicine schedules](https://github.com/dhileepk-18/mediguide/blob/main/backend/src/controllers/medicineController.js): `backend/src/controllers/medicineController.js`

### Persistence and identity

- [MongoDB](https://github.com/dhileepk-18/mediguide/blob/main/backend/src/config/db.js): `backend/src/config/db.js`
- [Local data store](https://github.com/dhileepk-18/mediguide/blob/main/backend/src/store/inMemoryStore.js): `backend/src/store/inMemoryStore.js`
- [Domain schemas](https://github.com/dhileepk-18/mediguide/blob/main/backend/src/models/schemas.js): `backend/src/models/schemas.js`

### Other components

- **Patient**
- **Doctor**
- **Administrator**
- **Google Gemini**

## Connections

- Patient → Role-based portal: uses (evidence: `README.md`)
- Doctor → Role-based portal: uses (evidence: `README.md`)
- Administrator → Role-based portal: uses (evidence: `README.md`)
- Role-based portal → Authentication state: checks access (evidence: `frontend/src/App.jsx`)
- Login and registration → Authentication state: updates session (evidence: `frontend/src/store/authStore.js`)
- Authentication state → API client: requests identity (evidence: `frontend/src/store/authStore.js`)
- AI assistant → API client: sends prompts (evidence: `frontend/src/pages/patient/AiAssistantPage.jsx`)
- Symptom checker → API client: submits symptoms
- Appointments → API client: books visits (evidence: `frontend/src/pages/patient/AppointmentsPage.jsx`)
- Patient records → API client: manages records
- Medicine reminders → API client: tracks doses
- Prescriptions → API client: manages prescriptions (evidence: `frontend/src/pages/doctor/DoctorPrescriptionsPage.jsx`)
- Administration → API client: manages operations
- API client → Express REST API: calls REST API (evidence: `README.md`)
- Express REST API → Authentication routes: mounts routes (evidence: `backend/src/server.js`)
- Express REST API → Admin routes: mounts routes (evidence: `backend/src/server.js`)
- Authentication routes → Authentication: dispatches (evidence: `backend/src/routes/authRoutes.js`)
- Admin routes → Administration: dispatches (evidence: `backend/src/routes/adminRoutes.js`)
- Express REST API → Appointment management: serves appointment routes
- Express REST API → AI requests: serves AI routes (evidence: `backend/src/server.js`)
- Express REST API → Health records: serves record routes
- Express REST API → Medicine schedules: serves medicine routes
- Express REST API → Prescription management: serves prescription routes (evidence: `backend/src/server.js`)
- Authentication → MongoDB: reads and writes (evidence: `backend/src/controllers/authController.js`)
- Authentication → Local data store: fallback reads and writes (evidence: `backend/src/controllers/authController.js`)
- Administration → MongoDB: reads and writes (evidence: `backend/src/controllers/adminController.js`)
- Administration → Local data store: fallback reads and writes (evidence: `backend/src/controllers/adminController.js`)
- Appointment management → MongoDB: reads and writes (evidence: `backend/src/controllers/appointmentController.js`)
- Appointment management → Local data store: fallback reads and writes (evidence: `backend/src/controllers/appointmentController.js`)
- Prescription management → MongoDB: reads and writes (evidence: `backend/src/controllers/prescriptionController.js`)
- Prescription management → Local data store: fallback reads and writes (evidence: `backend/src/controllers/prescriptionController.js`)
- Prescription management → Prescription PDF: generates PDF (evidence: `backend/src/controllers/prescriptionController.js`)
- AI requests → Clinical AI service: delegates requests
- Clinical AI service → Google Gemini: uses provider (evidence: `README.md`)
- Symptom checker → Triage model service: requests triage
