How code-sans/hospital-management-system works
Project Type and Purpose
• This is a full-stack, server-rendered web application built with Python and Flask, serving as a Hospital Management System.
• It supports three user roles—Admin, Doctor, Patient—and provides functionality for registration, authentication, appointment management, and user-specific dashboards.
File Structure Analysis
• Entry point: app.py
• Application package (app/):
• __init__.py — initializes Flask app and extensions
• auth.py — login, logout, register routes
• admin.py — admin routes for managing doctors, patients, appointments
• doctor.py — doctor-specific routes (availability, appointments, patient history)
• patient.py — patient-specific routes (search, book appointments, history)
• database.py — ORM initialization (SQLAlchemy) and session setup
• models.py — data models (User, Doctor, Patient, Appointment, etc.)
• Configuration: config.py
• Templates: templates/ organized by role (admin, doctor, patient) plus shared base.html, login.html, register.html
• Requirements: requirements.txt lists Flask, SQLAlchemy, and other dependencies
a. Clients
• Web Browser (Patient, Doctor, Admin)
b. Web Server / Application Layer
• Flask Application (app.py + app package)
• Blueprint Modules (auth, admin, doctor, patient)
• Templating Engine (Jinja2)
c. Data Layer
• Relational Database (e.g., PostgreSQL, SQLite)
• ORM (SQLAlchemy)
d. Configuration
• config.py (environment, database URI, secret key)
e. External Services (optional)
• Email/SMS gateway for notifications (if implemented later)
Relationships and Data Flow
1) Browser sends HTTP(S) request to Flask server.
2) app.py routes request to appropriate Blueprint (auth, admin, doctor, patient).
3) Controller accesses models via SQLAlchemy (database.py + models.py).
4) Data fetched/updated in the database.
5) Controller renders templates (templates/**) or returns JSON (if APIs exist).
6) Jinja2 template renders HTML, response sent back to browser.
Architectural Patterns and Design Principles
• MVC-style separation:
• Models: app/models.py
• Views: Jinja2 templates in templates/
• Controllers: Blueprints in app/*.py
• Modularization by user role via Flask Blueprints.
• Configuration abstraction (config.py).
• Single codebase but clear role-based routing.