How ashok43kumar/hospital-management-system works
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: App.jsx UI shell · views.py REST API · AuthContext.jsx Auth state · models.py Hospital app
Components 19
Backend
Django/DRF API, domain model, and auth boundary
- Django project · Project settings and root URL wiring
hospital_management_system/settings.py - Root URLs · Project-level request routing
hospital_management_system/urls.py - Hospital app · Core hospital domain boundaries
hospital/models.py - Auth layer · Supabase/JWT request authentication and user plumbing
authentication/backends.py - REST API · Serializers, views, and app routes for hospital resources
hospital/views.py - Manage · Django administrative entrypoint for server and migrations
manage.py
Frontend
React/Vite client and UI state
- Browser · User-facing client runtime
- App entry · Vite/React startup and root render
frontend/src/main.jsx - UI shell · Top-level app composition and routing flow
frontend/src/App.jsx - Landing · Public entry point before role-specific login
frontend/src/pages/LandingPage.jsx - Patient login · Patient sign-in surface
frontend/src/pages/PatientLogin.jsx - Patient dashboard · Patient-facing authenticated workspace
frontend/src/pages/PatientDashboard.jsx - Admin login · Admin sign-in surface
frontend/src/pages/AdminLogin.jsx - Admin dashboard · Admin-facing authenticated workspace
frontend/src/pages/AdminDashboard.jsx - Auth state · Shared client-side session and role state
frontend/src/context/AuthContext.jsx - API client · Central Axios configuration for Django calls
frontend/src/api/axiosConfig.js - Supabase client · Browser connection to Supabase Auth
frontend/src/api/supabaseClient.js
Data/Auth
Persistent store and external identity provider
- MySQL · Persistent hospital data store
- Supabase Auth · JWT-backed identity provider
Connections 20
- 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