# chamod-tharusha-alwis/medisync architecture

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

- Interactive diagram: https://gitdiagram.com/chamod-tharusha-alwis/medisync
- Repository: https://github.com/chamod-tharusha-alwis/medisync

## Overview

MediSync is a role-based healthcare platform spanning a React client, an Express/MongoDB backend, and a Flask ML service. Users enter through role-specific portals to manage clinical records and consultations; the platform also supports medication workflows, public health directories, and outbreak monitoring. Clinical and surveillance analysis form distinct domain stages, with authentication, consent, and audit controls as a supporting layer. Links between major services are partly based on README descriptions; unsampled implementation details are not asserted.

Main entry points: [`server/src/app.js`](https://github.com/chamod-tharusha-alwis/medisync/blob/main/server/src/app.js) (Express API), [`client/src/api/axiosInstance.js`](https://github.com/chamod-tharusha-alwis/medisync/blob/main/client/src/api/axiosInstance.js) (API client), [`client/src/App.js`](https://github.com/chamod-tharusha-alwis/medisync/blob/main/client/src/App.js) (Portal router), [`server/src/controllers/adminController.js`](https://github.com/chamod-tharusha-alwis/medisync/blob/main/server/src/controllers/adminController.js) (Admin operations)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Role-based client"]
  node_frontend["Portal router<br/>[App.js]"]
  node_consultation_ui["Doctor consultation"]
  node_pharmacy_ui["Pharmacy workflow<br/>[Dashboard.jsx]"]
  node_health_ui["Public health view<br/>[PublicHealth.jsx]"]
  node_api_client["API client<br/>[axiosInstance.js]"]
end

subgraph group_clinical["Clinical services"]
  node_api_server["Express API<br/>[app.js]"]
  node_clinical_records[("Clinical records<br/>[Patient.js]")]
  node_medicine_safety["Medication safety"]
  node_review_routes["Review routes<br/>[reviewRoutes.js]"]
  node_review_controller["Review controller"]
  node_review_service["Visit reviews<br/>[reviewService.js]"]
  node_review_store[("Review records<br/>[Review.js]")]
end

subgraph group_surveillance["Public health"]
  node_admin_ui["Admin portal<br/>[Dashboard.jsx]"]
  node_admin_controller["Admin operations<br/>[adminController.js]"]
  node_alerts["Outbreak alerts<br/>[alertController.js]"]
  node_surveillance_service["Surveillance analysis"]
  node_ml_service["Symptom and outbreak ML<br/>[app.py]"]
end

subgraph group_platform["Platform controls"]
  node_auth["Authentication<br/>[authController.js]"]
  node_auth_guard["Verified access<br/>[verifiedAuth.js]"]
  node_redis[("Redis services<br/>[redis.js]")]
end

node_users(("Patients and staff"))

node_users -->|"use portals"| node_frontend
node_frontend -->|"routes to"| node_consultation_ui
node_frontend -.->|"uses API"| node_api_client
node_consultation_ui -.->|"submits clinical data"| node_api_client
node_pharmacy_ui -.->|"uses API"| node_api_client
node_health_ui -.->|"uses API"| node_api_client
node_api_client -.->|"sends requests"| node_api_server
node_api_server -.->|"routes authentication"| node_auth
node_auth_guard -->|"checks access"| node_auth
node_api_server -.->|"serves clinical platform"| node_clinical_records
node_api_server -.->|"supports medication safety"| node_medicine_safety
node_review_routes -->|"protects submissions"| node_auth_guard
node_review_routes -->|"dispatches"| node_review_controller
node_review_controller -->|"submits reviews"| node_review_service
node_review_service -->|"persists reviews"| node_review_store
node_users -->|"administers surveillance"| node_admin_ui
node_admin_ui -.->|"requests operations"| node_admin_controller
node_admin_controller -->|"runs analysis"| node_surveillance_service
node_admin_controller -.->|"manages alerts"| node_alerts
node_surveillance_service -.->|"uses analysis engine"| node_ml_service
node_ml_service -.->|"returns predictions"| node_users
node_api_server -.->|"uses Redis"| node_redis

click node_frontend "https://github.com/chamod-tharusha-alwis/medisync/blob/main/client/src/App.js"
click node_consultation_ui "https://github.com/chamod-tharusha-alwis/medisync/blob/main/client/src/pages/doctor/NewConsultation.jsx"
click node_pharmacy_ui "https://github.com/chamod-tharusha-alwis/medisync/blob/main/client/src/pages/pharmacy/Dashboard.jsx"
click node_health_ui "https://github.com/chamod-tharusha-alwis/medisync/blob/main/client/src/pages/public/PublicHealth.jsx"
click node_api_client "https://github.com/chamod-tharusha-alwis/medisync/blob/main/client/src/api/axiosInstance.js"
click node_api_server "https://github.com/chamod-tharusha-alwis/medisync/blob/main/server/src/app.js"
click node_auth "https://github.com/chamod-tharusha-alwis/medisync/blob/main/server/src/controllers/authController.js"
click node_auth_guard "https://github.com/chamod-tharusha-alwis/medisync/blob/main/server/src/middleware/verifiedAuth.js"
click node_clinical_records "https://github.com/chamod-tharusha-alwis/medisync/blob/main/server/src/models/Patient.js"
click node_medicine_safety "https://github.com/chamod-tharusha-alwis/medisync/blob/main/server/src/utils/medicineSafetyEngine.js"
click node_review_routes "https://github.com/chamod-tharusha-alwis/medisync/blob/main/server/src/routes/reviewRoutes.js"
click node_review_controller "https://github.com/chamod-tharusha-alwis/medisync/blob/main/server/src/controllers/reviewController.js"
click node_review_service "https://github.com/chamod-tharusha-alwis/medisync/blob/main/server/src/services/reviewService.js"
click node_review_store "https://github.com/chamod-tharusha-alwis/medisync/blob/main/server/src/models/Review.js"
click node_admin_ui "https://github.com/chamod-tharusha-alwis/medisync/blob/main/client/src/pages/admin/Dashboard.jsx"
click node_admin_controller "https://github.com/chamod-tharusha-alwis/medisync/blob/main/server/src/controllers/adminController.js"
click node_alerts "https://github.com/chamod-tharusha-alwis/medisync/blob/main/server/src/controllers/alertController.js"
click node_surveillance_service "https://github.com/chamod-tharusha-alwis/medisync/blob/main/server/src/services/surveillanceService.js"
click node_ml_service "https://github.com/chamod-tharusha-alwis/medisync/blob/main/ml-engine/app.py"
click node_redis "https://github.com/chamod-tharusha-alwis/medisync/blob/main/server/src/config/redis.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_frontend,node_consultation_ui,node_pharmacy_ui,node_health_ui,node_api_client toneBlue
class node_api_server,node_clinical_records,node_medicine_safety,node_review_routes,node_review_controller,node_review_service,node_review_store toneAmber
class node_admin_ui,node_admin_controller,node_alerts,node_surveillance_service,node_ml_service toneMint
class node_auth,node_auth_guard,node_redis toneRose
class node_users toneIndigo
```

## Components

### Role-based client

- [Portal router](https://github.com/chamod-tharusha-alwis/medisync/blob/main/client/src/App.js): `client/src/App.js`
- [Doctor consultation](https://github.com/chamod-tharusha-alwis/medisync/blob/main/client/src/pages/doctor/NewConsultation.jsx): `client/src/pages/doctor/NewConsultation.jsx`
- [Pharmacy workflow](https://github.com/chamod-tharusha-alwis/medisync/blob/main/client/src/pages/pharmacy/Dashboard.jsx): `client/src/pages/pharmacy/Dashboard.jsx`
- [Public health view](https://github.com/chamod-tharusha-alwis/medisync/blob/main/client/src/pages/public/PublicHealth.jsx): `client/src/pages/public/PublicHealth.jsx`
- [API client](https://github.com/chamod-tharusha-alwis/medisync/blob/main/client/src/api/axiosInstance.js): `client/src/api/axiosInstance.js`

### Clinical services

- [Express API](https://github.com/chamod-tharusha-alwis/medisync/blob/main/server/src/app.js): `server/src/app.js`
- [Clinical records](https://github.com/chamod-tharusha-alwis/medisync/blob/main/server/src/models/Patient.js): `server/src/models/Patient.js`
- [Medication safety](https://github.com/chamod-tharusha-alwis/medisync/blob/main/server/src/utils/medicineSafetyEngine.js): `server/src/utils/medicineSafetyEngine.js`
- [Review routes](https://github.com/chamod-tharusha-alwis/medisync/blob/main/server/src/routes/reviewRoutes.js): `server/src/routes/reviewRoutes.js`
- [Review controller](https://github.com/chamod-tharusha-alwis/medisync/blob/main/server/src/controllers/reviewController.js): `server/src/controllers/reviewController.js`
- [Visit reviews](https://github.com/chamod-tharusha-alwis/medisync/blob/main/server/src/services/reviewService.js): `server/src/services/reviewService.js`
- [Review records](https://github.com/chamod-tharusha-alwis/medisync/blob/main/server/src/models/Review.js): `server/src/models/Review.js`

### Public health

- [Admin portal](https://github.com/chamod-tharusha-alwis/medisync/blob/main/client/src/pages/admin/Dashboard.jsx): `client/src/pages/admin/Dashboard.jsx`
- [Admin operations](https://github.com/chamod-tharusha-alwis/medisync/blob/main/server/src/controllers/adminController.js): `server/src/controllers/adminController.js`
- [Outbreak alerts](https://github.com/chamod-tharusha-alwis/medisync/blob/main/server/src/controllers/alertController.js): `server/src/controllers/alertController.js`
- [Surveillance analysis](https://github.com/chamod-tharusha-alwis/medisync/blob/main/server/src/services/surveillanceService.js): `server/src/services/surveillanceService.js`
- [Symptom and outbreak ML](https://github.com/chamod-tharusha-alwis/medisync/blob/main/ml-engine/app.py): `ml-engine/app.py`

### Platform controls

- [Authentication](https://github.com/chamod-tharusha-alwis/medisync/blob/main/server/src/controllers/authController.js): `server/src/controllers/authController.js`
- [Verified access](https://github.com/chamod-tharusha-alwis/medisync/blob/main/server/src/middleware/verifiedAuth.js): `server/src/middleware/verifiedAuth.js`
- [Redis services](https://github.com/chamod-tharusha-alwis/medisync/blob/main/server/src/config/redis.js): `server/src/config/redis.js`

### Other components

- **Patients and staff**

## Connections

- Patients and staff → Portal router: use portals (evidence: `README.md`)
- Portal router → Doctor consultation: routes to (evidence: `client/src/App.js`)
- Portal router → API client: uses API
- Doctor consultation → API client: submits clinical data
- Pharmacy workflow → API client: uses API
- Public health view → API client: uses API
- API client → Express API: sends requests
- Express API → Authentication: routes authentication
- Verified access → Authentication: checks access (evidence: `server/src/middleware/verifiedAuth.js`)
- Express API → Clinical records: serves clinical platform (evidence: `server/src/app.js`)
- Express API → Medication safety: supports medication safety
- Review routes → Verified access: protects submissions (evidence: `server/src/routes/reviewRoutes.js`)
- Review routes → Review controller: dispatches (evidence: `server/src/routes/reviewRoutes.js`)
- Review controller → Visit reviews: submits reviews (evidence: `server/src/controllers/reviewController.js`)
- Visit reviews → Review records: persists reviews (evidence: `server/src/services/reviewService.js`)
- Patients and staff → Admin portal: administers surveillance (evidence: `README.md`)
- Admin portal → Admin operations: requests operations
- Admin operations → Surveillance analysis: runs analysis (evidence: `server/src/controllers/adminController.js`)
- Admin operations → Outbreak alerts: manages alerts (evidence: `server/src/controllers/adminController.js`)
- Surveillance analysis → Symptom and outbreak ML: uses analysis engine
- Symptom and outbreak ML → Patients and staff: returns predictions
- Express API → Redis services: uses Redis (evidence: `server/src/app.js`)
