# sunkara-saivardhan/hospital-patient-management-system architecture

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

- Interactive diagram: https://gitdiagram.com/sunkara-saivardhan/hospital-patient-management-system
- Repository: https://github.com/sunkara-saivardhan/hospital-patient-management-system

## Overview

The system lets hospital staff manage patients, doctors, and appointments through a Streamlit dashboard backed by a FastAPI CRUD API and PostgreSQL. The dashboard also summarizes record totals and today’s appointments. Appointment creation checks patient and doctor records, past dates, and doctor time-slot conflicts before saving. The map reflects the supplied README and sampled source; API route groups share one implementation file, and no unsampled modules are inferred.

Main entry points: [`backend/main.py`](https://github.com/sunkara-saivardhan/hospital-patient-management-system/blob/main/backend/main.py) (Patient API), [`backend/database.py`](https://github.com/sunkara-saivardhan/hospital-patient-management-system/blob/main/backend/database.py) (Database sessions), [`frontend/app.py`](https://github.com/sunkara-saivardhan/hospital-patient-management-system/blob/main/frontend/app.py) (Dashboard), [`backend/models.py`](https://github.com/sunkara-saivardhan/hospital-patient-management-system/blob/main/backend/models.py) (ORM models)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_frontend["Streamlit frontend"]
  node_ui["Management UI<br/>[app.py]"]
  node_dashboard["Dashboard<br/>[app.py]"]
  node_crud["CRUD interface<br/>[app.py]"]
end

subgraph group_api["API and domain"]
  node_patients_api["Patient API<br/>[main.py]"]
  node_doctors_api["Doctor API<br/>[main.py]"]
  node_appointments_api["Appointment API<br/>[main.py]"]
  node_schemas["Request and response schemas<br/>[schemas.py]"]
end

subgraph group_persistence["Persistence"]
  node_models["ORM models<br/>[models.py]"]
  node_database["Database sessions<br/>[database.py]"]
  node_postgres[("PostgreSQL")]
end

node_staff(("Hospital staff"))

node_staff -->|"uses"| node_ui
node_ui -->|"selects"| node_dashboard
node_ui -->|"selects"| node_crud
node_dashboard -->|"fetches totals"| node_patients_api
node_dashboard -->|"fetches totals"| node_doctors_api
node_dashboard -->|"fetches records"| node_appointments_api
node_crud -->|"manages records"| node_patients_api
node_crud -->|"manages records"| node_doctors_api
node_crud -->|"manages records"| node_appointments_api
node_patients_api -->|"validates and shapes"| node_schemas
node_doctors_api -->|"validates and shapes"| node_schemas
node_appointments_api -->|"validates and shapes"| node_schemas
node_patients_api -->|"queries and writes"| node_models
node_doctors_api -->|"queries and writes"| node_models
node_appointments_api -->|"checks and writes"| node_models
node_patients_api -->|"uses session"| node_database
node_doctors_api -->|"uses session"| node_database
node_appointments_api -->|"uses session"| node_database
node_models -->|"uses Base"| node_database
node_database -->|"connects"| node_postgres

click node_ui "https://github.com/sunkara-saivardhan/hospital-patient-management-system/blob/main/frontend/app.py"
click node_dashboard "https://github.com/sunkara-saivardhan/hospital-patient-management-system/blob/main/frontend/app.py"
click node_crud "https://github.com/sunkara-saivardhan/hospital-patient-management-system/blob/main/frontend/app.py"
click node_patients_api "https://github.com/sunkara-saivardhan/hospital-patient-management-system/blob/main/backend/main.py"
click node_doctors_api "https://github.com/sunkara-saivardhan/hospital-patient-management-system/blob/main/backend/main.py"
click node_appointments_api "https://github.com/sunkara-saivardhan/hospital-patient-management-system/blob/main/backend/main.py"
click node_schemas "https://github.com/sunkara-saivardhan/hospital-patient-management-system/blob/main/backend/schemas.py"
click node_models "https://github.com/sunkara-saivardhan/hospital-patient-management-system/blob/main/backend/models.py"
click node_database "https://github.com/sunkara-saivardhan/hospital-patient-management-system/blob/main/backend/database.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_ui,node_dashboard,node_crud toneBlue
class node_patients_api,node_doctors_api,node_appointments_api,node_schemas toneAmber
class node_models,node_database,node_postgres toneMint
class node_staff toneIndigo
```

## Components

### Streamlit frontend

- [Management UI](https://github.com/sunkara-saivardhan/hospital-patient-management-system/blob/main/frontend/app.py): `frontend/app.py`
- [Dashboard](https://github.com/sunkara-saivardhan/hospital-patient-management-system/blob/main/frontend/app.py): `frontend/app.py`
- [CRUD interface](https://github.com/sunkara-saivardhan/hospital-patient-management-system/blob/main/frontend/app.py): `frontend/app.py`

### API and domain

- [Patient API](https://github.com/sunkara-saivardhan/hospital-patient-management-system/blob/main/backend/main.py): `backend/main.py`
- [Doctor API](https://github.com/sunkara-saivardhan/hospital-patient-management-system/blob/main/backend/main.py): `backend/main.py`
- [Appointment API](https://github.com/sunkara-saivardhan/hospital-patient-management-system/blob/main/backend/main.py): `backend/main.py`
- [Request and response schemas](https://github.com/sunkara-saivardhan/hospital-patient-management-system/blob/main/backend/schemas.py): `backend/schemas.py`

### Persistence

- [ORM models](https://github.com/sunkara-saivardhan/hospital-patient-management-system/blob/main/backend/models.py): `backend/models.py`
- [Database sessions](https://github.com/sunkara-saivardhan/hospital-patient-management-system/blob/main/backend/database.py): `backend/database.py`
- **PostgreSQL**

### Other components

- **Hospital staff**

## Connections

- Hospital staff → Management UI: uses
- Management UI → Dashboard: selects
- Management UI → CRUD interface: selects
- Dashboard → Patient API: fetches totals
- Dashboard → Doctor API: fetches totals
- Dashboard → Appointment API: fetches records
- CRUD interface → Patient API: manages records
- CRUD interface → Doctor API: manages records
- CRUD interface → Appointment API: manages records
- Patient API → Request and response schemas: validates and shapes
- Doctor API → Request and response schemas: validates and shapes
- Appointment API → Request and response schemas: validates and shapes
- Patient API → ORM models: queries and writes
- Doctor API → ORM models: queries and writes
- Appointment API → ORM models: checks and writes
- Patient API → Database sessions: uses session
- Doctor API → Database sessions: uses session
- Appointment API → Database sessions: uses session
- ORM models → Database sessions: uses Base
- Database sessions → PostgreSQL: connects
