# nirban-a/hospital-management-system-v2 architecture

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

- Interactive diagram: https://gitdiagram.com/nirban-a/hospital-management-system-v2
- Repository: https://github.com/nirban-a/hospital-management-system-v2

## Overview

HMS is a role-based hospital web application. Patients discover doctors, check availability, book and manage appointments, and view or export medical records; doctors manage schedules, consult patients, and review histories; administrators manage departments, users, appointments, and dashboards. The Vue client routes by role and calls a Flask API, which persists hospital data and supports background exports and reminders. The README confirms the product and Celery use; several backend capabilities are represented by documented routes, but unsampled handler internals are not assumed.

Main entry points: [`frontend/src/utils/api.js`](https://github.com/nirban-a/hospital-management-system-v2/blob/main/frontend/src/utils/api.js) (API client), [`frontend/src/router/index.js`](https://github.com/nirban-a/hospital-management-system-v2/blob/main/frontend/src/router/index.js) (Role routes), [`backend/application/crud_api.py`](https://github.com/nirban-a/hospital-management-system-v2/blob/main/backend/application/crud_api.py) (Hospital API), [`backend/app.py`](https://github.com/nirban-a/hospital-management-system-v2/blob/main/backend/app.py) (Flask app and routes)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Web client"]
  node_frontend["Vue application<br/>[main.js]"]
  node_router["Role routes<br/>[index.js]"]
  node_api["API client<br/>[api.js]"]
  node_adminui["Admin workspace"]
  node_doctorui["Doctor workspace"]
  node_patientui["Patient workspace"]
  node_booking["Appointment booking<br/>[PatientBooking.vue]"]
  node_profile["Profile management<br/>[CommonProfile.vue]"]
end

subgraph group_identity["Identity"]
  node_authstore["Auth state<br/>[auth.js]"]
  node_login["Login and registration<br/>[Login.vue]"]
  node_authapi["Authentication API<br/>[auth_api.py]"]
  node_datastore["User datastore<br/>[user_datastore.py]"]
end

subgraph group_hospital["Hospital operations"]
  node_crud["Hospital API<br/>[crud_api.py]"]
  node_backend["Flask app and routes<br/>[app.py]"]
end

subgraph group_records["Records and jobs"]
  node_db[("SQL database<br/>[database.py]")]
  node_models["Hospital data models<br/>[models.py]"]
  node_cache[("Redis cache<br/>[cache.py]")]
  node_tasks["Background jobs<br/>[tasks.py]"]
end

node_user(("User"))

node_user -->|"uses"| node_frontend
node_frontend -->|"mounts routes"| node_router
node_router -->|"checks roles"| node_authstore
node_router -->|"routes admins"| node_adminui
node_router -->|"routes doctors"| node_doctorui
node_router -->|"routes patients"| node_patientui
node_login -->|"sets session"| node_authstore
node_authstore -->|"supplies token"| node_api
node_adminui -->|"requests data"| node_api
node_doctorui -->|"requests data"| node_api
node_patientui -->|"requests data"| node_api
node_booking -->|"books appointments"| node_api
node_profile -->|"updates profile"| node_api
node_api -->|"HTTP requests"| node_backend
node_backend -->|"registers resources"| node_authapi
node_backend -->|"registers resources"| node_crud
node_backend -->|"initializes roles"| node_datastore
node_authapi -->|"finds users"| node_datastore
node_authapi -->|"invalidates cache"| node_cache
node_crud -->|"queries and commits"| node_db
node_crud -->|"uses entities"| node_models
node_crud -->|"dispatches jobs"| node_tasks
node_models -->|"defines tables"| node_db
node_tasks -->|"queries records"| node_models

click node_frontend "https://github.com/nirban-a/hospital-management-system-v2/blob/main/frontend/src/main.js"
click node_router "https://github.com/nirban-a/hospital-management-system-v2/blob/main/frontend/src/router/index.js"
click node_authstore "https://github.com/nirban-a/hospital-management-system-v2/blob/main/frontend/src/stores/auth.js"
click node_api "https://github.com/nirban-a/hospital-management-system-v2/blob/main/frontend/src/utils/api.js"
click node_login "https://github.com/nirban-a/hospital-management-system-v2/blob/main/frontend/src/views/Login.vue"
click node_authapi "https://github.com/nirban-a/hospital-management-system-v2/blob/main/backend/application/auth_api.py"
click node_datastore "https://github.com/nirban-a/hospital-management-system-v2/blob/main/backend/application/user_datastore.py"
click node_adminui "https://github.com/nirban-a/hospital-management-system-v2/tree/main/frontend/src/views/admin"
click node_doctorui "https://github.com/nirban-a/hospital-management-system-v2/tree/main/frontend/src/views/doctor"
click node_patientui "https://github.com/nirban-a/hospital-management-system-v2/tree/main/frontend/src/views/patient"
click node_booking "https://github.com/nirban-a/hospital-management-system-v2/blob/main/frontend/src/views/patient/PatientBooking.vue"
click node_profile "https://github.com/nirban-a/hospital-management-system-v2/blob/main/frontend/src/views/CommonProfile.vue"
click node_crud "https://github.com/nirban-a/hospital-management-system-v2/blob/main/backend/application/crud_api.py"
click node_backend "https://github.com/nirban-a/hospital-management-system-v2/blob/main/backend/app.py"
click node_db "https://github.com/nirban-a/hospital-management-system-v2/blob/main/backend/application/database.py"
click node_models "https://github.com/nirban-a/hospital-management-system-v2/blob/main/backend/application/models.py"
click node_cache "https://github.com/nirban-a/hospital-management-system-v2/blob/main/backend/application/cache.py"
click node_tasks "https://github.com/nirban-a/hospital-management-system-v2/blob/main/backend/application/tasks.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_frontend,node_router,node_api,node_adminui,node_doctorui,node_patientui,node_booking,node_profile,node_user toneBlue
class node_authstore,node_login,node_authapi,node_datastore toneAmber
class node_crud,node_backend toneMint
class node_db,node_models,node_cache,node_tasks toneRose
```

## Components

### Web client

- [Vue application](https://github.com/nirban-a/hospital-management-system-v2/blob/main/frontend/src/main.js): `frontend/src/main.js`
- [Role routes](https://github.com/nirban-a/hospital-management-system-v2/blob/main/frontend/src/router/index.js): `frontend/src/router/index.js`
- [API client](https://github.com/nirban-a/hospital-management-system-v2/blob/main/frontend/src/utils/api.js): `frontend/src/utils/api.js`
- [Admin workspace](https://github.com/nirban-a/hospital-management-system-v2/tree/main/frontend/src/views/admin): `frontend/src/views/admin`
- [Doctor workspace](https://github.com/nirban-a/hospital-management-system-v2/tree/main/frontend/src/views/doctor): `frontend/src/views/doctor`
- [Patient workspace](https://github.com/nirban-a/hospital-management-system-v2/tree/main/frontend/src/views/patient): `frontend/src/views/patient`
- [Appointment booking](https://github.com/nirban-a/hospital-management-system-v2/blob/main/frontend/src/views/patient/PatientBooking.vue): `frontend/src/views/patient/PatientBooking.vue`
- [Profile management](https://github.com/nirban-a/hospital-management-system-v2/blob/main/frontend/src/views/CommonProfile.vue): `frontend/src/views/CommonProfile.vue`

### Identity

- [Auth state](https://github.com/nirban-a/hospital-management-system-v2/blob/main/frontend/src/stores/auth.js): `frontend/src/stores/auth.js`
- [Login and registration](https://github.com/nirban-a/hospital-management-system-v2/blob/main/frontend/src/views/Login.vue): `frontend/src/views/Login.vue`
- [Authentication API](https://github.com/nirban-a/hospital-management-system-v2/blob/main/backend/application/auth_api.py): `backend/application/auth_api.py`
- [User datastore](https://github.com/nirban-a/hospital-management-system-v2/blob/main/backend/application/user_datastore.py): `backend/application/user_datastore.py`

### Hospital operations

- [Hospital API](https://github.com/nirban-a/hospital-management-system-v2/blob/main/backend/application/crud_api.py): `backend/application/crud_api.py`
- [Flask app and routes](https://github.com/nirban-a/hospital-management-system-v2/blob/main/backend/app.py): `backend/app.py`

### Records and jobs

- [SQL database](https://github.com/nirban-a/hospital-management-system-v2/blob/main/backend/application/database.py): `backend/application/database.py`
- [Hospital data models](https://github.com/nirban-a/hospital-management-system-v2/blob/main/backend/application/models.py): `backend/application/models.py`
- [Redis cache](https://github.com/nirban-a/hospital-management-system-v2/blob/main/backend/application/cache.py): `backend/application/cache.py`
- [Background jobs](https://github.com/nirban-a/hospital-management-system-v2/blob/main/backend/application/tasks.py): `backend/application/tasks.py`

### Other components

- **User**

## Connections

- User → Vue application: uses (evidence: `frontend/src/main.js`)
- Vue application → Role routes: mounts routes (evidence: `frontend/src/main.js`)
- Role routes → Auth state: checks roles (evidence: `frontend/src/router/index.js`)
- Role routes → Admin workspace: routes admins (evidence: `frontend/src/router/index.js`)
- Role routes → Doctor workspace: routes doctors (evidence: `frontend/src/router/index.js`)
- Role routes → Patient workspace: routes patients (evidence: `frontend/src/router/index.js`)
- Login and registration → Auth state: sets session (evidence: `frontend/src/views/Login.vue`)
- Auth state → API client: supplies token (evidence: `frontend/src/utils/api.js`)
- Admin workspace → API client: requests data (evidence: `frontend/src/views/admin/AdminDepartments.vue`)
- Doctor workspace → API client: requests data (evidence: `frontend/src/views/doctor/DoctorSchedule.vue`)
- Patient workspace → API client: requests data (evidence: `frontend/src/views/patient/PatientRecords.vue`)
- Appointment booking → API client: books appointments (evidence: `frontend/src/views/patient/PatientBooking.vue`)
- Profile management → API client: updates profile (evidence: `frontend/src/views/CommonProfile.vue`)
- API client → Flask app and routes: HTTP requests (evidence: `frontend/src/utils/api.js`)
- Flask app and routes → Authentication API: registers resources (evidence: `backend/app.py`)
- Flask app and routes → Hospital API: registers resources (evidence: `backend/app.py`)
- Flask app and routes → User datastore: initializes roles (evidence: `backend/app.py`)
- Authentication API → User datastore: finds users (evidence: `backend/application/auth_api.py`)
- Authentication API → Redis cache: invalidates cache (evidence: `backend/application/auth_api.py`)
- Hospital API → SQL database: queries and commits (evidence: `backend/application/crud_api.py`)
- Hospital API → Hospital data models: uses entities (evidence: `backend/application/crud_api.py`)
- Hospital API → Background jobs: dispatches jobs (evidence: `backend/application/crud_api.py`)
- Hospital data models → SQL database: defines tables (evidence: `backend/application/models.py`)
- Background jobs → Hospital data models: queries records (evidence: `backend/application/tasks.py`)
