# sandeep-square2706/hospital-management-system architecture

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

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

## Overview

Hospital Management System is a Django application for role-based doctor availability and patient appointment booking, with PostgreSQL persistence and Google Calendar and email integrations. Its main workflow runs from doctor availability creation through patient booking to doctor review, acceptance or rejection, and appointment completion. The README documents additional capabilities; sampled views and calendar services support the specific links shown. OAuth view wiring and some browse/list behavior are documented but their implementation was not sampled.

Main entry points: [`accounts/views.py`](https://github.com/sandeep-square2706/hospital-management-system/blob/main/accounts/views.py) (Accounts and dashboards), [`bookings/views.py`](https://github.com/sandeep-square2706/hospital-management-system/blob/main/bookings/views.py) (Booking operations), [`doctors/views.py`](https://github.com/sandeep-square2706/hospital-management-system/blob/main/doctors/views.py) (Availability management), [`patients/views.py`](https://github.com/sandeep-square2706/hospital-management-system/blob/main/patients/views.py) (Patient experience)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_identity["Accounts and Roles"]
  node_accounts_views["Accounts and dashboards<br/>[views.py]"]
  node_user_model["User accounts<br/>[models.py]"]
end

subgraph group_availability["Doctor Availability"]
  node_doctor_views["Availability management<br/>[views.py]"]
  node_doctor_model["Doctor profiles and slots<br/>[models.py]"]
end

subgraph group_appointments["Appointment Management"]
  node_patient_views["Patient experience<br/>[views.py]"]
  node_patient_model["Patient profiles<br/>[models.py]"]
  node_booking_views["Booking operations<br/>[views.py]"]
  node_booking_model["Bookings<br/>[models.py]"]
end

subgraph group_integrations["External Integrations"]
  node_calendar_views["Calendar authorization<br/>[views.py]"]
  node_calendar_services["Calendar services<br/>[services.py]"]
  node_email_handler["Email handler<br/>[handler.py]"]
end

node_doctor(("Doctor"))
node_patient(("Patient"))
node_postgres[("PostgreSQL")]
node_google_calendar["Google Calendar API"]
node_smtp["Gmail SMTP"]

node_doctor -->|"signs in"| node_accounts_views
node_patient -->|"signs in"| node_accounts_views
node_accounts_views -->|"creates and authenticates"| node_user_model
node_accounts_views -->|"creates doctor profile"| node_doctor_model
node_accounts_views -->|"creates patient profile"| node_patient_model
node_accounts_views -->|"routes doctor"| node_doctor_views
node_accounts_views -->|"routes patient"| node_patient_views
node_doctor -->|"manages availability"| node_doctor_views
node_doctor_views -->|"creates and updates slots"| node_doctor_model
node_patient -->|"views doctors and slots"| node_patient_views
node_patient_views -->|"reads availability"| node_doctor_model
node_patient -->|"books a slot"| node_booking_views
node_booking_views -->|"loads patient profile"| node_patient_model
node_booking_views -->|"locks and updates slot"| node_doctor_model
node_booking_views -->|"creates and updates booking"| node_booking_model
node_doctor -->|"reviews booking"| node_booking_views
node_booking_views -->|"reads booking history"| node_booking_model
node_booking_views -->|"creates accepted events"| node_calendar_services
node_calendar_views -.->|"uses OAuth services"| node_calendar_services
node_calendar_services -->|"creates events"| node_google_calendar
node_accounts_views -->|"posts welcome email"| node_email_handler
node_booking_views -->|"posts booking updates"| node_email_handler
node_email_handler -->|"sends email"| node_smtp
node_accounts_views -->|"persists accounts and profiles"| node_postgres
node_doctor_views -->|"persists availability"| node_postgres
node_patient_views -->|"reads patient profile"| node_postgres
node_booking_views -->|"persists bookings and slots"| node_postgres

click node_accounts_views "https://github.com/sandeep-square2706/hospital-management-system/blob/main/accounts/views.py"
click node_user_model "https://github.com/sandeep-square2706/hospital-management-system/blob/main/accounts/models.py"
click node_doctor_views "https://github.com/sandeep-square2706/hospital-management-system/blob/main/doctors/views.py"
click node_doctor_model "https://github.com/sandeep-square2706/hospital-management-system/blob/main/doctors/models.py"
click node_patient_views "https://github.com/sandeep-square2706/hospital-management-system/blob/main/patients/views.py"
click node_patient_model "https://github.com/sandeep-square2706/hospital-management-system/blob/main/patients/models.py"
click node_booking_views "https://github.com/sandeep-square2706/hospital-management-system/blob/main/bookings/views.py"
click node_booking_model "https://github.com/sandeep-square2706/hospital-management-system/blob/main/bookings/models.py"
click node_calendar_views "https://github.com/sandeep-square2706/hospital-management-system/blob/main/calendar_app/views.py"
click node_calendar_services "https://github.com/sandeep-square2706/hospital-management-system/blob/main/calendar_app/services.py"
click node_email_handler "https://github.com/sandeep-square2706/hospital-management-system/blob/main/email-service/handler.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_accounts_views,node_user_model toneBlue
class node_doctor_views,node_doctor_model,node_postgres toneAmber
class node_patient_views,node_patient_model,node_booking_views,node_booking_model,node_google_calendar toneMint
class node_calendar_views,node_calendar_services,node_email_handler toneRose
class node_doctor,node_patient,node_smtp toneIndigo
```

## Components

### Accounts and Roles

- [Accounts and dashboards](https://github.com/sandeep-square2706/hospital-management-system/blob/main/accounts/views.py): `accounts/views.py`
- [User accounts](https://github.com/sandeep-square2706/hospital-management-system/blob/main/accounts/models.py): `accounts/models.py`

### Doctor Availability

- [Availability management](https://github.com/sandeep-square2706/hospital-management-system/blob/main/doctors/views.py): `doctors/views.py`
- [Doctor profiles and slots](https://github.com/sandeep-square2706/hospital-management-system/blob/main/doctors/models.py): `doctors/models.py`

### Appointment Management

- [Patient experience](https://github.com/sandeep-square2706/hospital-management-system/blob/main/patients/views.py): `patients/views.py`
- [Patient profiles](https://github.com/sandeep-square2706/hospital-management-system/blob/main/patients/models.py): `patients/models.py`
- [Booking operations](https://github.com/sandeep-square2706/hospital-management-system/blob/main/bookings/views.py): `bookings/views.py`
- [Bookings](https://github.com/sandeep-square2706/hospital-management-system/blob/main/bookings/models.py): `bookings/models.py`

### External Integrations

- [Calendar authorization](https://github.com/sandeep-square2706/hospital-management-system/blob/main/calendar_app/views.py): `calendar_app/views.py`
- [Calendar services](https://github.com/sandeep-square2706/hospital-management-system/blob/main/calendar_app/services.py): `calendar_app/services.py`
- [Email handler](https://github.com/sandeep-square2706/hospital-management-system/blob/main/email-service/handler.py): `email-service/handler.py`

### Other components

- **Doctor**
- **Patient**
- **PostgreSQL**
- **Google Calendar API**
- **Gmail SMTP**

## Connections

- Doctor → Accounts and dashboards: signs in
- Patient → Accounts and dashboards: signs in
- Accounts and dashboards → User accounts: creates and authenticates
- Accounts and dashboards → Doctor profiles and slots: creates doctor profile
- Accounts and dashboards → Patient profiles: creates patient profile
- Accounts and dashboards → Availability management: routes doctor
- Accounts and dashboards → Patient experience: routes patient
- Doctor → Availability management: manages availability
- Availability management → Doctor profiles and slots: creates and updates slots
- Patient → Patient experience: views doctors and slots
- Patient experience → Doctor profiles and slots: reads availability
- Patient → Booking operations: books a slot
- Booking operations → Patient profiles: loads patient profile
- Booking operations → Doctor profiles and slots: locks and updates slot
- Booking operations → Bookings: creates and updates booking
- Doctor → Booking operations: reviews booking
- Booking operations → Bookings: reads booking history
- Booking operations → Calendar services: creates accepted events
- Calendar authorization → Calendar services: uses OAuth services
- Calendar services → Google Calendar API: creates events
- Accounts and dashboards → Email handler: posts welcome email
- Booking operations → Email handler: posts booking updates
- Email handler → Gmail SMTP: sends email
- Accounts and dashboards → PostgreSQL: persists accounts and profiles
- Availability management → PostgreSQL: persists availability
- Patient experience → PostgreSQL: reads patient profile
- Booking operations → PostgreSQL: persists bookings and slots
