# aswin-ar5055/hospital-management-system architecture

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

- Interactive diagram: https://gitdiagram.com/aswin-ar5055/hospital-management-system
- Repository: https://github.com/aswin-ar5055/hospital-management-system

## Overview

This is a role-based hospital workflow system: reception registers a patient and assigns a doctor, creating a visit token; doctors review visits, record consultation findings, and prescribe medicines. The React role-specific screens call a Django REST API, whose domain apps serialize and persist users, patients, visits, and prescriptions. The README also documents JWT authentication and WhatsApp notifications; the latter is visible in the visit service. Backend view excerpts are unavailable, so view-to-model links rely on the SOURCE INDEX references.

Main entry points: [`frontend/src/api/axios.js`](https://github.com/aswin-ar5055/hospital-management-system/blob/master/frontend/src/api/axios.js) (Authenticated API client), [`frontend/src/App.jsx`](https://github.com/aswin-ar5055/hospital-management-system/blob/master/frontend/src/App.jsx) (Route application), [`backend/hospital/hospital/urls.py`](https://github.com/aswin-ar5055/hospital-management-system/blob/master/backend/hospital/hospital/urls.py) (Django API routing), [`frontend/src/pages/PatientRegister.jsx`](https://github.com/aswin-ar5055/hospital-management-system/blob/master/frontend/src/pages/PatientRegister.jsx) (Patient intake)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_frontend["React application"]
  node_app["Route application<br/>[App.jsx]"]
  node_guard["Role guard<br/>[ProtectedRoute.jsx]"]
  node_login["Login and registration<br/>[Login.jsx]"]
  node_receptionui["Reception dashboard"]
  node_patientreg["Patient intake"]
  node_doctorui["Doctor dashboard"]
  node_consult["Consultation entry<br/>[Consultation.jsx]"]
  node_history["Patient history<br/>[PatientHistory.jsx]"]
  node_http["Authenticated API client<br/>[axios.js]"]
end

subgraph group_api["Django API"]
  node_django["Django API routing<br/>[urls.py]"]
end

subgraph group_domain["Hospital records"]
  node_users[("User and roles<br/>[models.py]")]
  node_patients[("Patient records<br/>[models.py]")]
  node_visits[("Visit and token<br/>[models.py]")]
  node_prescriptions[("Prescriptions<br/>[models.py]")]
end

subgraph group_integrations["External services"]
  node_whatsapp["Visit notifications"]
  node_twilio["Twilio WhatsApp"]
end

node_reception(("Reception staff"))
node_doctor(("Doctor"))

node_reception -->|"registers patient"| node_patientreg
node_doctor -->|"reviews visits"| node_doctorui
node_app -->|"protects routes"| node_guard
node_guard -->|"redirects unauthenticated"| node_login
node_app -->|"routes to"| node_login
node_app -->|"routes to"| node_patientreg
node_app -->|"routes to"| node_consult
node_app -->|"routes to"| node_doctorui
node_app -->|"routes to"| node_history
node_login -->|"sends requests"| node_http
node_patientreg -->|"sends requests"| node_http
node_doctorui -->|"sends requests"| node_http
node_consult -->|"sends requests"| node_http
node_history -->|"sends requests"| node_http
node_http -->|"calls API"| node_django
node_django -->|"routes user requests"| node_users
node_django -->|"routes patient requests"| node_patients
node_django -->|"routes visit requests"| node_visits
node_django -->|"routes prescription requests"| node_prescriptions
node_patientreg -->|"loads doctors"| node_http
node_patientreg -->|"creates patient and visit"| node_http
node_consult -->|"updates visit"| node_http
node_consult -->|"submits prescriptions"| node_http
node_whatsapp -->|"sends notifications"| node_twilio
node_visits -->|"references patient"| node_patients
node_visits -->|"references doctor"| node_users
node_prescriptions -->|"references visit"| node_visits
node_django -.->|"notification dispatch"| node_whatsapp

click node_app "https://github.com/aswin-ar5055/hospital-management-system/blob/master/frontend/src/App.jsx"
click node_guard "https://github.com/aswin-ar5055/hospital-management-system/blob/master/frontend/src/components/ProtectedRoute.jsx"
click node_login "https://github.com/aswin-ar5055/hospital-management-system/blob/master/frontend/src/pages/Login.jsx"
click node_receptionui "https://github.com/aswin-ar5055/hospital-management-system/blob/master/frontend/src/pages/ReceptionDashboard.jsx"
click node_patientreg "https://github.com/aswin-ar5055/hospital-management-system/blob/master/frontend/src/pages/PatientRegister.jsx"
click node_doctorui "https://github.com/aswin-ar5055/hospital-management-system/blob/master/frontend/src/pages/DoctorDashboard.jsx"
click node_consult "https://github.com/aswin-ar5055/hospital-management-system/blob/master/frontend/src/pages/Consultation.jsx"
click node_history "https://github.com/aswin-ar5055/hospital-management-system/blob/master/frontend/src/pages/PatientHistory.jsx"
click node_http "https://github.com/aswin-ar5055/hospital-management-system/blob/master/frontend/src/api/axios.js"
click node_django "https://github.com/aswin-ar5055/hospital-management-system/blob/master/backend/hospital/hospital/urls.py"
click node_users "https://github.com/aswin-ar5055/hospital-management-system/blob/master/backend/hospital/users/models.py"
click node_patients "https://github.com/aswin-ar5055/hospital-management-system/blob/master/backend/hospital/patients/models.py"
click node_visits "https://github.com/aswin-ar5055/hospital-management-system/blob/master/backend/hospital/visits/models.py"
click node_prescriptions "https://github.com/aswin-ar5055/hospital-management-system/blob/master/backend/hospital/prescriptions/models.py"
click node_whatsapp "https://github.com/aswin-ar5055/hospital-management-system/blob/master/backend/hospital/visits/whatsapp_service.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_app,node_guard,node_login,node_receptionui,node_patientreg,node_doctorui,node_consult,node_history,node_http toneBlue
class node_django toneAmber
class node_users,node_patients,node_visits,node_prescriptions toneMint
class node_whatsapp,node_twilio toneRose
class node_reception,node_doctor toneIndigo
```

## Components

### React application

- [Route application](https://github.com/aswin-ar5055/hospital-management-system/blob/master/frontend/src/App.jsx): `frontend/src/App.jsx`
- [Role guard](https://github.com/aswin-ar5055/hospital-management-system/blob/master/frontend/src/components/ProtectedRoute.jsx): `frontend/src/components/ProtectedRoute.jsx`
- [Login and registration](https://github.com/aswin-ar5055/hospital-management-system/blob/master/frontend/src/pages/Login.jsx): `frontend/src/pages/Login.jsx`
- [Reception dashboard](https://github.com/aswin-ar5055/hospital-management-system/blob/master/frontend/src/pages/ReceptionDashboard.jsx): `frontend/src/pages/ReceptionDashboard.jsx`
- [Patient intake](https://github.com/aswin-ar5055/hospital-management-system/blob/master/frontend/src/pages/PatientRegister.jsx): `frontend/src/pages/PatientRegister.jsx`
- [Doctor dashboard](https://github.com/aswin-ar5055/hospital-management-system/blob/master/frontend/src/pages/DoctorDashboard.jsx): `frontend/src/pages/DoctorDashboard.jsx`
- [Consultation entry](https://github.com/aswin-ar5055/hospital-management-system/blob/master/frontend/src/pages/Consultation.jsx): `frontend/src/pages/Consultation.jsx`
- [Patient history](https://github.com/aswin-ar5055/hospital-management-system/blob/master/frontend/src/pages/PatientHistory.jsx): `frontend/src/pages/PatientHistory.jsx`
- [Authenticated API client](https://github.com/aswin-ar5055/hospital-management-system/blob/master/frontend/src/api/axios.js): `frontend/src/api/axios.js`

### Django API

- [Django API routing](https://github.com/aswin-ar5055/hospital-management-system/blob/master/backend/hospital/hospital/urls.py): `backend/hospital/hospital/urls.py`

### Hospital records

- [User and roles](https://github.com/aswin-ar5055/hospital-management-system/blob/master/backend/hospital/users/models.py): `backend/hospital/users/models.py`
- [Patient records](https://github.com/aswin-ar5055/hospital-management-system/blob/master/backend/hospital/patients/models.py): `backend/hospital/patients/models.py`
- [Visit and token](https://github.com/aswin-ar5055/hospital-management-system/blob/master/backend/hospital/visits/models.py): `backend/hospital/visits/models.py`
- [Prescriptions](https://github.com/aswin-ar5055/hospital-management-system/blob/master/backend/hospital/prescriptions/models.py): `backend/hospital/prescriptions/models.py`

### External services

- [Visit notifications](https://github.com/aswin-ar5055/hospital-management-system/blob/master/backend/hospital/visits/whatsapp_service.py): `backend/hospital/visits/whatsapp_service.py`
- **Twilio WhatsApp**

### Other components

- **Reception staff**
- **Doctor**

## Connections

- Reception staff → Patient intake: registers patient
- Doctor → Doctor dashboard: reviews visits
- Route application → Role guard: protects routes (evidence: `frontend/src/App.jsx`)
- Role guard → Login and registration: redirects unauthenticated (evidence: `frontend/src/components/ProtectedRoute.jsx`)
- Route application → Login and registration: routes to (evidence: `frontend/src/App.jsx`)
- Route application → Patient intake: routes to (evidence: `frontend/src/App.jsx`)
- Route application → Consultation entry: routes to (evidence: `frontend/src/App.jsx`)
- Route application → Doctor dashboard: routes to (evidence: `frontend/src/App.jsx`)
- Route application → Patient history: routes to (evidence: `frontend/src/App.jsx`)
- Login and registration → Authenticated API client: sends requests (evidence: `frontend/src/pages/Login.jsx`)
- Patient intake → Authenticated API client: sends requests (evidence: `frontend/src/pages/PatientRegister.jsx`)
- Doctor dashboard → Authenticated API client: sends requests (evidence: `frontend/src/pages/DoctorDashboard.jsx`)
- Consultation entry → Authenticated API client: sends requests (evidence: `frontend/src/pages/Consultation.jsx`)
- Patient history → Authenticated API client: sends requests (evidence: `frontend/src/pages/PatientHistory.jsx`)
- Authenticated API client → Django API routing: calls API
- Django API routing → User and roles: routes user requests (evidence: `backend/hospital/hospital/urls.py`)
- Django API routing → Patient records: routes patient requests (evidence: `backend/hospital/hospital/urls.py`)
- Django API routing → Visit and token: routes visit requests (evidence: `backend/hospital/hospital/urls.py`)
- Django API routing → Prescriptions: routes prescription requests (evidence: `backend/hospital/hospital/urls.py`)
- Patient intake → Authenticated API client: loads doctors (evidence: `frontend/src/pages/PatientRegister.jsx`)
- Patient intake → Authenticated API client: creates patient and visit (evidence: `frontend/src/pages/PatientRegister.jsx`)
- Consultation entry → Authenticated API client: updates visit (evidence: `frontend/src/pages/Consultation.jsx`)
- Consultation entry → Authenticated API client: submits prescriptions (evidence: `frontend/src/pages/Consultation.jsx`)
- Visit notifications → Twilio WhatsApp: sends notifications (evidence: `backend/hospital/visits/whatsapp_service.py`)
- Visit and token → Patient records: references patient (evidence: `backend/hospital/visits/models.py`)
- Visit and token → User and roles: references doctor (evidence: `backend/hospital/visits/models.py`)
- Prescriptions → Visit and token: references visit (evidence: `backend/hospital/prescriptions/models.py`)
- Django API routing → Visit notifications: notification dispatch
