# ashok43kumar/hospital-management-system architecture

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

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

## Overview

1. **System shape**
   - This is a two-tier hospital management system: a **Django/DRF backend** serving a **React/Vite frontend**.
   - The runtime boundary is clear: frontend runs in the browser, backend exposes REST endpoints, and MySQL persists the hospital data.

2. **Backend project layout**
   - `hospital_management_system/` is the Django project shell: `settings.py`, root `urls.py`, `asgi.py`, and `wsgi.py`.
   - `hospital/` is the main domain app and contains the core data model, serializers, views, URL routes, and migrations.

3. **Domain and persistence layer**
   - The data model lives in `hospital/models.py` and is evolved through migrations `0001`–`0003`.
   - Based on the README and file names, the schema centers on hospital entities such as patients, doctors, rooms/wards, consultations, and bills, with MySQL as the backing store.

4. **REST API layer**
   - `hospital/serializers.py`, `hospital/views.py`, and `hospital/urls.py` indicate a standard DRF pipeline: model data is serialized, exposed through API views/viewsets, and routed under the Django URL config.
   - The README lists endpoints such as patient, doctor, consultation, bill, and room APIs, which are likely the primary integration surface for the frontend.

5. **Authentication boundary**
   - Authentication is not handled by Django sessions; it is integrated with **Supabase Auth / JWT**.
   - The `authentication/` app contains `backends.py`, `middleware.py`, and `utils.py`, suggesting custom request authentication, token validation, and user-context plumbing on the backend.
   - This app is the security boundary between Supabase-issued identity and Django-protected resources.

6. **Frontend application structure**
   - The frontend is a Vite React app in `frontend/`, with `src/main.jsx` bootstrapping the app and `App.jsx` defining the top-level UI flow.
   - Styling is handled with Tailwind CSS, with `App.css` and `index.css` providing local styling support.

7. **Frontend state and API access**
   - `frontend/src/context/AuthContext.jsx` is the central client-side auth state manager.
   - `frontend/src/api/supabaseClient.js` connects the browser app to Supabase, while `frontend/src/api/axiosConfig.js` centralizes HTTP calls to the Django API, likely attaching auth headers and base URL configuration from environment variables.

8. **Role-based UI partitioning**
   - The frontend separates user journeys into **patient** and **admin** paths.
   - Patient-facing pages include `PatientLogin.jsx` and `PatientDashboard.jsx`.
   - Admin-facing pages include `AdminLogin.jsx` and `AdminDashboard.jsx`.
   - `LandingPage.jsx` appears to be the public entry point before role-specific authentication.

9. **End-to-end data flow**
   - A user logs in through the React frontend using Supabase.
   - The frontend stores auth/session state in `AuthContext`.
   - Authenticated requests go through Axios to Django.
   - Django validates the Supabase JWT via the custom authentication layer.
   - DRF views read/write hospital records in MySQL and return JSON to the UI.

10. **Operational configuration**
   - Environment variables are split by tier: `frontend/.env` carries the frontend API base URL and Supabase keys, while the backend `.env` carries Supabase verification values and MySQL credentials.
   - This keeps browser-facing configuration separate from server secrets.

11. **Runtime and deployment boundaries**
   - The frontend is designed to run on the Vite dev server, and the backend on Django’s development server.
   - Django’s `manage.py` drives migrations, server startup, and administrative tasks.
   - `requirements.txt` and `frontend/package.json` define the two independent dependency stacks.

12. **Non-core artifacts**
   - Root-level HTML files like `admin-dashboard.html`, `patient-login.html`, and `41fd.html` look like static snapshots or prototype artifacts rather than part of the main runtime path.
   - Utility scripts such as `convert.py` and `fix_jsx.py` also appear to be support tooling, not application subsystems.

Main entry points: [`frontend/src/App.jsx`](https://github.com/ashok43kumar/hospital-management-system/blob/main/frontend/src/App.jsx) (UI shell), [`hospital/views.py`](https://github.com/ashok43kumar/hospital-management-system/blob/main/hospital/views.py) (REST API), [`frontend/src/context/AuthContext.jsx`](https://github.com/ashok43kumar/hospital-management-system/blob/main/frontend/src/context/AuthContext.jsx) (Auth state), [`hospital/models.py`](https://github.com/ashok43kumar/hospital-management-system/blob/main/hospital/models.py) (Hospital app)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_backend["Backend"]
  node_django_project["Django project<br/>[settings.py]"]
  node_root_urls["Root URLs<br/>url conf<br/>[urls.py]"]
  node_hospital_app["Hospital app<br/>domain app<br/>[models.py]"]
  node_auth_app["Auth layer<br/>custom auth<br/>[backends.py]"]
  node_rest_api["REST API<br/>drf api<br/>[views.py]"]
  node_manage["Manage<br/>cli<br/>[manage.py]"]
end

subgraph group_frontend["Frontend"]
  node_browser(("Browser<br/>runtime"))
  node_vite_entry["App entry<br/>react bootstrap<br/>[main.jsx]"]
  node_app_shell["UI shell<br/>react shell<br/>[App.jsx]"]
  node_landing_page["Landing<br/>public page<br/>[LandingPage.jsx]"]
  node_patient_login["Patient login<br/>patient page<br/>[PatientLogin.jsx]"]
  node_patient_dash["Patient dashboard<br/>patient page"]
  node_admin_login["Admin login<br/>admin page<br/>[AdminLogin.jsx]"]
  node_admin_dash["Admin dashboard<br/>admin page<br/>[AdminDashboard.jsx]"]
  node_auth_context["Auth state<br/>client auth<br/>[AuthContext.jsx]"]
  node_api_client["API client<br/>http client<br/>[axiosConfig.js]"]
  node_supabase_client["Supabase client<br/>identity client<br/>[supabaseClient.js]"]
end

subgraph group_data["Data/Auth"]
  node_mysql[("MySQL<br/>database")]
  node_supabase_auth(("Supabase Auth<br/>external identity"))
end

node_browser -->|"loads"| node_vite_entry
node_vite_entry -->|"mounts"| node_app_shell
node_app_shell -->|"shows"| node_landing_page
node_app_shell -->|"routes"| node_patient_login
node_app_shell -->|"routes"| node_patient_dash
node_app_shell -->|"routes"| node_admin_login
node_app_shell -->|"routes"| node_admin_dash
node_app_shell -->|"uses"| node_auth_context
node_auth_context -->|"authenticates"| node_supabase_client
node_auth_context -->|"guards"| node_api_client
node_api_client -->|"calls"| node_rest_api
node_supabase_client -->|"verifies"| node_supabase_auth
node_django_project -->|"wires"| node_root_urls
node_root_urls -->|"includes"| node_rest_api
node_rest_api -->|"reads/writes"| node_hospital_app
node_hospital_app -->|"persists"| node_mysql
node_auth_app -->|"validates"| node_supabase_auth
node_rest_api -->|"protects"| node_auth_app
node_manage -->|"runs"| node_django_project
node_manage -->|"migrates"| node_hospital_app

click node_vite_entry "https://github.com/ashok43kumar/hospital-management-system/blob/main/frontend/src/main.jsx"
click node_app_shell "https://github.com/ashok43kumar/hospital-management-system/blob/main/frontend/src/App.jsx"
click node_landing_page "https://github.com/ashok43kumar/hospital-management-system/blob/main/frontend/src/pages/LandingPage.jsx"
click node_patient_login "https://github.com/ashok43kumar/hospital-management-system/blob/main/frontend/src/pages/PatientLogin.jsx"
click node_patient_dash "https://github.com/ashok43kumar/hospital-management-system/blob/main/frontend/src/pages/PatientDashboard.jsx"
click node_admin_login "https://github.com/ashok43kumar/hospital-management-system/blob/main/frontend/src/pages/AdminLogin.jsx"
click node_admin_dash "https://github.com/ashok43kumar/hospital-management-system/blob/main/frontend/src/pages/AdminDashboard.jsx"
click node_auth_context "https://github.com/ashok43kumar/hospital-management-system/blob/main/frontend/src/context/AuthContext.jsx"
click node_api_client "https://github.com/ashok43kumar/hospital-management-system/blob/main/frontend/src/api/axiosConfig.js"
click node_supabase_client "https://github.com/ashok43kumar/hospital-management-system/blob/main/frontend/src/api/supabaseClient.js"
click node_django_project "https://github.com/ashok43kumar/hospital-management-system/blob/main/hospital_management_system/settings.py"
click node_root_urls "https://github.com/ashok43kumar/hospital-management-system/blob/main/hospital_management_system/urls.py"
click node_hospital_app "https://github.com/ashok43kumar/hospital-management-system/blob/main/hospital/models.py"
click node_auth_app "https://github.com/ashok43kumar/hospital-management-system/blob/main/authentication/backends.py"
click node_rest_api "https://github.com/ashok43kumar/hospital-management-system/blob/main/hospital/views.py"
click node_manage "https://github.com/ashok43kumar/hospital-management-system/blob/main/manage.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_django_project,node_root_urls,node_hospital_app,node_auth_app,node_rest_api,node_manage toneBlue
class node_browser,node_vite_entry,node_app_shell,node_landing_page,node_patient_login,node_patient_dash,node_admin_login,node_admin_dash,node_auth_context,node_api_client,node_supabase_client toneAmber
class node_mysql,node_supabase_auth toneMint
```

## Components

### Backend

Django/DRF API, domain model, and auth boundary

- [Django project](https://github.com/ashok43kumar/hospital-management-system/blob/main/hospital_management_system/settings.py): django project · Project settings and root URL wiring · `hospital_management_system/settings.py`
- [Root URLs](https://github.com/ashok43kumar/hospital-management-system/blob/main/hospital_management_system/urls.py): url conf · Project-level request routing · `hospital_management_system/urls.py`
- [Hospital app](https://github.com/ashok43kumar/hospital-management-system/blob/main/hospital/models.py): domain app · Core hospital domain boundaries · `hospital/models.py`
- [Auth layer](https://github.com/ashok43kumar/hospital-management-system/blob/main/authentication/backends.py): custom auth · Supabase/JWT request authentication and user plumbing · `authentication/backends.py`
- [REST API](https://github.com/ashok43kumar/hospital-management-system/blob/main/hospital/views.py): drf api · Serializers, views, and app routes for hospital resources · `hospital/views.py`
- [Manage](https://github.com/ashok43kumar/hospital-management-system/blob/main/manage.py): cli · Django administrative entrypoint for server and migrations · `manage.py`

### Frontend

React/Vite client and UI state

- **Browser**: runtime · User-facing client runtime
- [App entry](https://github.com/ashok43kumar/hospital-management-system/blob/main/frontend/src/main.jsx): react bootstrap · Vite/React startup and root render · `frontend/src/main.jsx`
- [UI shell](https://github.com/ashok43kumar/hospital-management-system/blob/main/frontend/src/App.jsx): react shell · Top-level app composition and routing flow · `frontend/src/App.jsx`
- [Landing](https://github.com/ashok43kumar/hospital-management-system/blob/main/frontend/src/pages/LandingPage.jsx): public page · Public entry point before role-specific login · `frontend/src/pages/LandingPage.jsx`
- [Patient login](https://github.com/ashok43kumar/hospital-management-system/blob/main/frontend/src/pages/PatientLogin.jsx): patient page · Patient sign-in surface · `frontend/src/pages/PatientLogin.jsx`
- [Patient dashboard](https://github.com/ashok43kumar/hospital-management-system/blob/main/frontend/src/pages/PatientDashboard.jsx): patient page · Patient-facing authenticated workspace · `frontend/src/pages/PatientDashboard.jsx`
- [Admin login](https://github.com/ashok43kumar/hospital-management-system/blob/main/frontend/src/pages/AdminLogin.jsx): admin page · Admin sign-in surface · `frontend/src/pages/AdminLogin.jsx`
- [Admin dashboard](https://github.com/ashok43kumar/hospital-management-system/blob/main/frontend/src/pages/AdminDashboard.jsx): admin page · Admin-facing authenticated workspace · `frontend/src/pages/AdminDashboard.jsx`
- [Auth state](https://github.com/ashok43kumar/hospital-management-system/blob/main/frontend/src/context/AuthContext.jsx): client auth · Shared client-side session and role state · `frontend/src/context/AuthContext.jsx`
- [API client](https://github.com/ashok43kumar/hospital-management-system/blob/main/frontend/src/api/axiosConfig.js): http client · Central Axios configuration for Django calls · `frontend/src/api/axiosConfig.js`
- [Supabase client](https://github.com/ashok43kumar/hospital-management-system/blob/main/frontend/src/api/supabaseClient.js): identity client · Browser connection to Supabase Auth · `frontend/src/api/supabaseClient.js`

### Data/Auth

Persistent store and external identity provider

- **MySQL**: database · Persistent hospital data store
- **Supabase Auth**: external identity · JWT-backed identity provider

## Connections

- Browser → App entry: loads · Browser loads the Vite app
- App entry → UI shell: mounts · React boots the top-level application shell
- UI shell → Landing: shows · Public entry point is rendered first
- UI shell → Patient login: routes · Patient journey enters the patient login flow
- UI shell → Patient dashboard: routes · Authenticated patient workspace
- UI shell → Admin login: routes · Admin journey enters the admin login flow
- UI shell → Admin dashboard: routes · Authenticated admin workspace
- UI shell → Auth state: uses · App-wide auth state is shared through context
- Auth state → Supabase client: authenticates · Client session and login flow use Supabase
- Auth state → API client: guards · Auth state informs API request handling
- API client → REST API: calls · HTTP requests go to the Django REST layer
- Supabase client → Supabase Auth: verifies · Browser authentication is delegated to Supabase
- Django project → Root URLs: wires · Project shell exposes root request routing
- Root URLs → REST API: includes · Project URLs delegate to the hospital API routes
- REST API → Hospital app: reads/writes · API endpoints operate on hospital domain data
- Hospital app → MySQL: persists · Model data is stored in MySQL
- Auth layer → Supabase Auth: validates · Backend auth layer checks Supabase-issued identity
- REST API → Auth layer: protects · DRF endpoints are guarded by custom authentication
- Manage → Django project: runs · Management commands start and migrate the Django app
- Manage → Hospital app: migrates · Django migrations evolve the hospital schema
