# sumitkumar1503/hospitalmanagement architecture

> Architecture diagram of the GitHub repository sumitkumar1503/hospitalmanagement, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-05-06). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/sumitkumar1503/hospitalmanagement
- Repository: https://github.com/sumitkumar1503/hospitalmanagement

## Overview

##### Project type and purpose
- This is a monolithic, full-stack web application built with Django (Python) for Hospital Management.
- It supports three user roles (Admin, Doctor, Patient) and handles authentication, CRUD operations on doctors/patients/appointments, PDF invoice generation, and email contact.

##### File structure
- Top-level:
- manage.py – Django CLI entry point
- hospitalmanagement/ – Django project (settings.py, urls.py, wsgi/asgi)
- hospital/ – single Django app (models.py, views.py, forms.py, admin.py, migrations/)
- templates/hospital/ – server-rendered HTML templates by role & feature
- static/ – CSS, images, screenshots
- requirement.txt – dependencies (Django 3.0.5, xhtml2pdf, widget-tweaks)
- Architectural pattern: classical MVC (Model layer in hospital/models.py; Views in hospital/views.py; Controller logic in forms/views; Templates as the View in Django’s MTV).
- External integrations: SMTP (Gmail) for contact page; xhtml2pdf for PDF invoice generation.

##### Key insights from README
- Technology stack: Python 3.7.6, Django 3.0.5, Django-widget-tweaks, xhtml2pdf.
- Features: user signup/login flows with conditional approval for doctors/patients, appointment workflows, invoice download, contact form email.
- Deployment: local Django dev server, SQLite (default) or configured RDBMS.

##### Main components and interactions
a. Client tier
- Web browser (Admin UI, Doctor UI, Patient UI)
- Static assets (CSS, images) served via Django’s staticfiles or CDN
b. Application tier (Django server)
- URL router (hospitalmanagement/urls.py → hospital/views.py)
- Views & Forms (authentication, dashboard, CRUD, PDF generation endpoints)
- Business logic (approval workflows, invoice calc.)
- PDF generator module (xhtml2pdf integration)
- Email module (SMTP via Django’s EmailBackend)
c. Data tier
- Relational database (SQLite/PostgreSQL/MySQL) storing Users, Doctors, Patients, Appointments, DischargeRecords, Invoices, etc.
d. External services
- SMTP server (Gmail) for contact emails
e. Optional deployment layer (Gunicorn/UWGI, Nginx as reverse proxy/static server)

Data flows:
1. Browser → HTTP request → Django URL router → View → (Model ↔ DB) → Template → HTTP response
2. PDF invoice request → View → xhtml2pdf → generated PDF → HTTP response or file download
3. Contact form submit → View → SMTP → external mail delivery

##### Architectural patterns & principles
- Model-Template-View (MTV) – Django’s variation of MVC.
- Role-based access control: Admin vs Doctor vs Patient URL namespaces and templates.
- Layered architecture: Presentation (templates/static), Application (views/forms), Data (models/DB).
- Single app monolith—no microservices, but clearly separated responsibilities by module/file.

##### Detail without over-splitting
- Related views (e.g., Appointment Views) under one component.
- You capture all essential architectural elements: roles, MVC/MTV separation, database, PDF/email services.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Presentation Layer
    subgraph "Presentation Layer"
        direction TB
        Browser["Web Browser\n(Admin, Doctor, Patient UIs)"]:::presentation
        Templates["Django Templates\n(server-rendered HTML)"]:::presentation
        StaticAssets["Static Assets\n(CSS, Images)"]:::presentation
    end

    %% Application Layer
    subgraph "Application Layer"
        direction TB
        Manage["Django CLI Entry\nmanage.py"]:::application
        Settings["Settings & Email Config\n(hospitalmanagement/settings.py)"]:::application
        URLRouter["URL Router\n(hospitalmanagement/urls.py)"]:::application
        WSGIASGI["WSGI / ASGI Entry\n(hospitalmanagement/wsgi.py, asgi.py)"]:::application
        Forms["Forms & Validation\n(hospital/forms.py)"]:::application
        Views["Views & Business Logic\n(hospital/views.py)"]:::application
        AdminReg["Admin Interface\n(hospital/admin.py)"]:::application
        PDFGen["Invoice PDF Generator\n(xhtml2pdf)"]:::application
        Requirements["Requirements\n(requirement.txt)"]:::application
    end

    %% Data Layer
    subgraph "Data Layer"
        direction TB
        Models["Models\n(hospital/models.py)"]:::data
        Migrations["Database Migrations\n(hospital/migrations/)"]:::data
        Database[(Relational Database)]:::data
    end

    %% External Services
    subgraph "External Services"
        direction TB
        SMTP["SMTP Server\n(Gmail)"]:::external
    end

    %% Connections
    Browser -->|"HTTP GET/POST"| URLRouter
    Browser --> StaticAssets
    URLRouter --> Settings
    URLRouter --> WSGIASGI
    URLRouter --> Views
    Views --> Forms
    Views --> Models
    Models --> Database
    Database --> Migrations
    Views --> Templates
    Templates --> Browser
    Views -->|"generate PDF"| PDFGen
    Views -->|"send email"| SMTP
    Manage --> Settings

    %% Click Events
    click URLRouter "https://github.com/sumitkumar1503/hospitalmanagement/blob/master/hospitalmanagement/urls.py"
    click WSGIASGI "https://github.com/sumitkumar1503/hospitalmanagement/blob/master/hospitalmanagement/wsgi.py"
    click WSGIASGI "https://github.com/sumitkumar1503/hospitalmanagement/blob/master/hospitalmanagement/asgi.py"
    click Settings "https://github.com/sumitkumar1503/hospitalmanagement/blob/master/hospitalmanagement/settings.py"
    click Manage "https://github.com/sumitkumar1503/hospitalmanagement/blob/master/manage.py"
    click Models "https://github.com/sumitkumar1503/hospitalmanagement/blob/master/hospital/models.py"
    click Migrations "https://github.com/sumitkumar1503/hospitalmanagement/tree/master/hospital/migrations/"
    click AdminReg "https://github.com/sumitkumar1503/hospitalmanagement/blob/master/hospital/admin.py"
    click Forms "https://github.com/sumitkumar1503/hospitalmanagement/blob/master/hospital/forms.py"
    click Views "https://github.com/sumitkumar1503/hospitalmanagement/blob/master/hospital/views.py"
    click Templates "https://github.com/sumitkumar1503/hospitalmanagement/tree/master/templates/hospital/"
    click StaticAssets "https://github.com/sumitkumar1503/hospitalmanagement/tree/master/static/"
    click PDFGen "https://github.com/sumitkumar1503/hospitalmanagement/blob/master/hospital/views.py"
    click Requirements "https://github.com/sumitkumar1503/hospitalmanagement/blob/master/requirement.txt"

    %% Styles
    classDef presentation fill:#D0E8FF,stroke:#004080,stroke-width:1px
    classDef application fill:#D0FFD8,stroke:#007F00,stroke-width:1px
    classDef data fill:#FFE2B3,stroke:#B36B00,stroke-width:1px
    classDef external fill:#E0E0E0,stroke:#666666,stroke-width:1px
```
