# timsina-suraj/medishield architecture

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

- Interactive diagram: https://gitdiagram.com/timsina-suraj/medishield
- Repository: https://github.com/timsina-suraj/medishield

## Overview

MediShield is a role-based hospital management system whose user workflows span account access, patient registration, appointments, clinical records, labs, prescriptions, and pharmacy, with dengue and diagnosis ML plus analytics and alerts. The frontend routes role-specific users to workflows and calls the FastAPI API; backend services coordinate repositories and persistence. Sampled source confirms app/router registration, frontend routing and API client behavior, registration and authentication details, and selected repository behavior. Other capability links reflect the README and module paths; unsampled internal wiring is not asserted.

Main entry points: [`backend/app/main.py`](https://github.com/timsina-suraj/medishield/blob/main/backend/app/main.py) (FastAPI application), [`backend/app/repositories`](https://github.com/timsina-suraj/medishield/tree/main/backend/app/repositories) (Repositories), [`backend/app/services/auth_service.py`](https://github.com/timsina-suraj/medishield/blob/main/backend/app/services/auth_service.py) (Authentication service), [`frontend/src/App.jsx`](https://github.com/timsina-suraj/medishield/blob/main/frontend/src/App.jsx) (Role-based interface)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_frontend["Frontend"]
  node_webapp["Role-based interface<br/>[App.jsx]"]
  node_authui["Login and session<br/>[AuthContext.jsx]"]
  node_apiclient["API client<br/>[client.js]"]
end

subgraph group_api["API and security"]
  node_server["FastAPI application<br/>[main.py]"]
  node_authroutes["Authentication routes<br/>[auth.py]"]
  node_authservice["Authentication service<br/>[auth_service.py]"]
  node_registration["Registration service"]
  node_security["Auth and access control"]
  node_email["Email notifications<br/>[email_service.py]"]
end

subgraph group_clinical["Clinical operations"]
  node_appointments["Appointments<br/>[appointments.py]"]
  node_records["Records and history<br/>[medical_records.py]"]
  node_labs["Lab workflow<br/>[lab.py]"]
  node_prescriptions["Prescriptions<br/>[prescriptions.py]"]
  node_pharmacy["Pharmacy inventory<br/>[pharmacy.py]"]
  node_documents["Documents and exports<br/>[documents.py]"]
end

subgraph group_intelligence["AI and oversight"]
  node_mlroutes["Prediction endpoints<br/>[ml_dengue.py]"]
  node_diagnosisroute["Diagnosis prediction<br/>[ml_diagnosis.py]"]
  node_models["ML models and metrics"]
  node_alerts["Alerts<br/>[alerts.py]"]
  node_analytics["Analytics dashboard API<br/>[analytics.py]"]
end

subgraph group_persistence["Persistence"]
  node_repos["Repositories"]
  node_dbsession["Async database setup<br/>[database.py]"]
  node_database[("Hospital database")]
end

node_users(("Hospital users"))
node_smtp["SMTP service"]

node_users -->|"use workflows"| node_webapp
node_webapp -->|"renders routes"| node_authui
node_authui -->|"requests API"| node_apiclient
node_webapp -->|"calls API"| node_apiclient
node_apiclient -->|"HTTP requests"| node_server
node_server -->|"dispatches auth"| node_authroutes
node_authroutes -->|"invokes"| node_authservice
node_authservice -->|"verifies credentials"| node_security
node_authservice -->|"reads and writes"| node_repos
node_authservice -->|"schedules OTP mail"| node_email
node_registration -->|"creates accounts"| node_repos
node_registration -->|"schedules notices"| node_email
node_email -.->|"sends messages"| node_smtp
node_server -->|"dispatches"| node_appointments
node_server -->|"dispatches"| node_records
node_server -->|"dispatches"| node_labs
node_server -->|"dispatches"| node_prescriptions
node_server -->|"dispatches"| node_pharmacy
node_server -->|"dispatches"| node_documents
node_server -->|"dispatches"| node_mlroutes
node_server -->|"dispatches"| node_diagnosisroute
node_server -->|"dispatches"| node_alerts
node_server -->|"dispatches"| node_analytics
node_mlroutes -->|"uses models"| node_models
node_diagnosisroute -->|"uses models"| node_models
node_appointments -->|"persists workflow"| node_repos
node_records -->|"reads and writes"| node_repos
node_labs -->|"reads and writes"| node_repos
node_prescriptions -->|"reads and writes"| node_repos
node_pharmacy -->|"reads and writes"| node_repos
node_documents -->|"stores metadata"| node_repos
node_repos -->|"uses sessions"| node_dbsession
node_dbsession -->|"queries and updates"| node_database

click node_webapp "https://github.com/timsina-suraj/medishield/blob/main/frontend/src/App.jsx"
click node_authui "https://github.com/timsina-suraj/medishield/blob/main/frontend/src/auth/AuthContext.jsx"
click node_apiclient "https://github.com/timsina-suraj/medishield/blob/main/frontend/src/api/client.js"
click node_server "https://github.com/timsina-suraj/medishield/blob/main/backend/app/main.py"
click node_authroutes "https://github.com/timsina-suraj/medishield/blob/main/backend/app/routers/auth.py"
click node_authservice "https://github.com/timsina-suraj/medishield/blob/main/backend/app/services/auth_service.py"
click node_registration "https://github.com/timsina-suraj/medishield/blob/main/backend/app/services/registration_service.py"
click node_security "https://github.com/timsina-suraj/medishield/tree/main/backend/app/security"
click node_appointments "https://github.com/timsina-suraj/medishield/blob/main/backend/app/routers/appointments.py"
click node_records "https://github.com/timsina-suraj/medishield/blob/main/backend/app/routers/medical_records.py"
click node_labs "https://github.com/timsina-suraj/medishield/blob/main/backend/app/routers/lab.py"
click node_prescriptions "https://github.com/timsina-suraj/medishield/blob/main/backend/app/routers/prescriptions.py"
click node_pharmacy "https://github.com/timsina-suraj/medishield/blob/main/backend/app/routers/pharmacy.py"
click node_documents "https://github.com/timsina-suraj/medishield/blob/main/backend/app/routers/documents.py"
click node_mlroutes "https://github.com/timsina-suraj/medishield/blob/main/backend/app/routers/ml_dengue.py"
click node_diagnosisroute "https://github.com/timsina-suraj/medishield/blob/main/backend/app/routers/ml_diagnosis.py"
click node_models "https://github.com/timsina-suraj/medishield/tree/main/backend/app/ml"
click node_alerts "https://github.com/timsina-suraj/medishield/blob/main/backend/app/routers/alerts.py"
click node_analytics "https://github.com/timsina-suraj/medishield/blob/main/backend/app/routers/analytics.py"
click node_email "https://github.com/timsina-suraj/medishield/blob/main/backend/app/services/email_service.py"
click node_repos "https://github.com/timsina-suraj/medishield/tree/main/backend/app/repositories"
click node_dbsession "https://github.com/timsina-suraj/medishield/blob/main/backend/app/database.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_webapp,node_authui,node_apiclient,node_users toneBlue
class node_server,node_authroutes,node_authservice,node_registration,node_security,node_email toneAmber
class node_appointments,node_records,node_labs,node_prescriptions,node_pharmacy,node_documents toneMint
class node_mlroutes,node_diagnosisroute,node_models,node_alerts,node_analytics toneRose
class node_repos,node_dbsession,node_database,node_smtp toneIndigo
```

## Components

### Frontend

- [Role-based interface](https://github.com/timsina-suraj/medishield/blob/main/frontend/src/App.jsx): `frontend/src/App.jsx`
- [Login and session](https://github.com/timsina-suraj/medishield/blob/main/frontend/src/auth/AuthContext.jsx): `frontend/src/auth/AuthContext.jsx`
- [API client](https://github.com/timsina-suraj/medishield/blob/main/frontend/src/api/client.js): `frontend/src/api/client.js`

### API and security

- [FastAPI application](https://github.com/timsina-suraj/medishield/blob/main/backend/app/main.py): `backend/app/main.py`
- [Authentication routes](https://github.com/timsina-suraj/medishield/blob/main/backend/app/routers/auth.py): `backend/app/routers/auth.py`
- [Authentication service](https://github.com/timsina-suraj/medishield/blob/main/backend/app/services/auth_service.py): `backend/app/services/auth_service.py`
- [Registration service](https://github.com/timsina-suraj/medishield/blob/main/backend/app/services/registration_service.py): `backend/app/services/registration_service.py`
- [Auth and access control](https://github.com/timsina-suraj/medishield/tree/main/backend/app/security): `backend/app/security`
- [Email notifications](https://github.com/timsina-suraj/medishield/blob/main/backend/app/services/email_service.py): `backend/app/services/email_service.py`

### Clinical operations

- [Appointments](https://github.com/timsina-suraj/medishield/blob/main/backend/app/routers/appointments.py): `backend/app/routers/appointments.py`
- [Records and history](https://github.com/timsina-suraj/medishield/blob/main/backend/app/routers/medical_records.py): `backend/app/routers/medical_records.py`
- [Lab workflow](https://github.com/timsina-suraj/medishield/blob/main/backend/app/routers/lab.py): `backend/app/routers/lab.py`
- [Prescriptions](https://github.com/timsina-suraj/medishield/blob/main/backend/app/routers/prescriptions.py): `backend/app/routers/prescriptions.py`
- [Pharmacy inventory](https://github.com/timsina-suraj/medishield/blob/main/backend/app/routers/pharmacy.py): `backend/app/routers/pharmacy.py`
- [Documents and exports](https://github.com/timsina-suraj/medishield/blob/main/backend/app/routers/documents.py): `backend/app/routers/documents.py`

### AI and oversight

- [Prediction endpoints](https://github.com/timsina-suraj/medishield/blob/main/backend/app/routers/ml_dengue.py): `backend/app/routers/ml_dengue.py`
- [Diagnosis prediction](https://github.com/timsina-suraj/medishield/blob/main/backend/app/routers/ml_diagnosis.py): `backend/app/routers/ml_diagnosis.py`
- [ML models and metrics](https://github.com/timsina-suraj/medishield/tree/main/backend/app/ml): `backend/app/ml`
- [Alerts](https://github.com/timsina-suraj/medishield/blob/main/backend/app/routers/alerts.py): `backend/app/routers/alerts.py`
- [Analytics dashboard API](https://github.com/timsina-suraj/medishield/blob/main/backend/app/routers/analytics.py): `backend/app/routers/analytics.py`

### Persistence

- [Repositories](https://github.com/timsina-suraj/medishield/tree/main/backend/app/repositories): `backend/app/repositories`
- [Async database setup](https://github.com/timsina-suraj/medishield/blob/main/backend/app/database.py): `backend/app/database.py`
- **Hospital database**

### Other components

- **Hospital users**
- **SMTP service**

## Connections

- Hospital users → Role-based interface: use workflows
- Role-based interface → Login and session: renders routes
- Login and session → API client: requests API
- Role-based interface → API client: calls API
- API client → FastAPI application: HTTP requests
- FastAPI application → Authentication routes: dispatches auth
- Authentication routes → Authentication service: invokes
- Authentication service → Auth and access control: verifies credentials
- Authentication service → Repositories: reads and writes
- Authentication service → Email notifications: schedules OTP mail
- Registration service → Repositories: creates accounts
- Registration service → Email notifications: schedules notices
- Email notifications → SMTP service: sends messages
- FastAPI application → Appointments: dispatches
- FastAPI application → Records and history: dispatches
- FastAPI application → Lab workflow: dispatches
- FastAPI application → Prescriptions: dispatches
- FastAPI application → Pharmacy inventory: dispatches
- FastAPI application → Documents and exports: dispatches
- FastAPI application → Prediction endpoints: dispatches
- FastAPI application → Diagnosis prediction: dispatches
- FastAPI application → Alerts: dispatches
- FastAPI application → Analytics dashboard API: dispatches
- Prediction endpoints → ML models and metrics: uses models
- Diagnosis prediction → ML models and metrics: uses models
- Appointments → Repositories: persists workflow
- Records and history → Repositories: reads and writes
- Lab workflow → Repositories: reads and writes
- Prescriptions → Repositories: reads and writes
- Pharmacy inventory → Repositories: reads and writes
- Documents and exports → Repositories: stores metadata
- Repositories → Async database setup: uses sessions
- Async database setup → Hospital database: queries and updates
