# chandu2307/python_fast_api architecture

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

- Interactive diagram: https://gitdiagram.com/chandu2307/python_fast_api
- Repository: https://github.com/chandu2307/python_fast_api

## Overview

##### Project type and purpose
- This is a Python-based full-stack web application implementing a Hospital Management System (HMS) API using FastAPI.
- Its primary purpose is to provide RESTful endpoints for user authentication (JWT), patient management, appointments, medical records, billing, inventory, room/bed management, staff management, and reporting.

##### File structure
- Top-level directories:
- hospital_management/backend – contains the FastAPI app
- hospital_management/frontend – static HTML/CSS/JS assets
- Core backend files and directories:
- hospital_app.py – entry point mounting routers and middleware
- auth.py – JWT authentication logic (login, signup, logout, token handling)
- database.py – database connection and ORM engine setup
- models.py – ORM model definitions (User, Patient, Doctor, Appointment, etc.)
- schemas.py – Pydantic schemas for request and response validation
- routes/ – grouped route modules (e.g., admin.py for admin-only APIs)
- utils.py – shared helper functions (e.g., password hashing, token creation)
- Frontend:
- home.html – static landing page or minimal UI
- media/ – static assets (images, CSS, JS)
- Other files:
- requirement.txt – lists Python dependencies (FastAPI, Pydantic, SQLAlchemy, JWT library)

##### README for additional insights
- The README enumerates all API modules and endpoints the HMS plans to support.
- Confirms use of JWT-based login/signup and role-based operations (doctor, nurse, admin, patient).

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Frontend Layer
    subgraph "Frontend Layer"
        Client["Browser/API Consumer"]:::external
        StaticServer["Static Server"]:::frontend
        Home["home.html"]:::frontend
        Media["media/"]:::frontend
    end

    %% Backend Layer
    subgraph "Backend Layer"
        API["FastAPI App"]:::backend
        subgraph "Core Modules"
            Entry["hospital_app.py"]:::backend
            Auth["auth.py"]:::service
            DBConn["database.py"]:::service
            Models["models.py"]:::backend
            Schemas["schemas.py"]:::backend
            Utils["utils.py"]:::service
        end
        subgraph "Routes"
            AllRoutes["routes/"]:::backend
            AdminRoutes["admin.py"]:::backend
        end
    end

    %% Database and External Services
    DB[(Database)]:::db
    Ext["Email/SMS Service"]:::external

    %% Connections
    Client -->|"HTTP Request"| StaticServer
    StaticServer -->|"Serves"| Home
    StaticServer -->|"Serves"| Media
    Client -->|"API Request"| API
    API -->|"mounts routers & middleware"| Entry
    Entry -->|"calls authentication"| Auth
    Entry -->|"uses DB connection"| DBConn
    Entry -->|"registers routes"| AllRoutes
    AllRoutes -->|"includes admin routes"| AdminRoutes
    Entry -->|"imports models"| Models
    Entry -->|"imports schemas"| Schemas
    Entry -->|"uses utilities"| Utils
    Auth -->|"verifies tokens & auth logic"| Models
    Auth -->|"uses schema validation"| Schemas
    Auth -->|"utilizes helpers"| Utils
    AllRoutes -->|"CRUD operations"| Models
    AllRoutes -->|"data validation"| Schemas
    AllRoutes -->|"business logic"| Utils
    DBConn -->|"connects to"| DB
    Models -->|"ORM mapping"| DB
    Utils -->|"send notifications"| Ext

    %% Click Events
    click Entry "https://github.com/chandu2307/python_fast_api/blob/main/hospital_management/backend/hospital_app.py"
    click Auth "https://github.com/chandu2307/python_fast_api/blob/main/hospital_management/backend/auth.py"
    click DBConn "https://github.com/chandu2307/python_fast_api/blob/main/hospital_management/backend/database.py"
    click Models "https://github.com/chandu2307/python_fast_api/blob/main/hospital_management/backend/models.py"
    click Schemas "https://github.com/chandu2307/python_fast_api/blob/main/hospital_management/backend/schemas.py"
    click AllRoutes "https://github.com/chandu2307/python_fast_api/tree/main/hospital_management/backend/routes/"
    click AdminRoutes "https://github.com/chandu2307/python_fast_api/blob/main/hospital_management/backend/routes/admin.py"
    click Utils "https://github.com/chandu2307/python_fast_api/blob/main/hospital_management/backend/utils.py"
    click Home "https://github.com/chandu2307/python_fast_api/blob/main/hospital_management/frontend/home.html"
    click Media "https://github.com/chandu2307/python_fast_api/tree/main/hospital_management/frontend/media/"
    click Requirement "https://github.com/chandu2307/python_fast_api/blob/main/requirement.txt"
    click Readme "https://github.com/chandu2307/python_fast_api/blob/main/README.md"
    click License "https://github.com/chandu2307/python_fast_api/tree/main/LICENSE"

    %% Styles
    classDef frontend fill:#AEDFF7,stroke:#0366d6,color:#0366d6;
    classDef backend fill:#FBE8A6,stroke:#D58936,color:#D58936;
    classDef service fill:#D3F8E2,stroke:#34A853,color:#34A853;
    classDef db fill:#F3D1F4,stroke:#A333C8,color:#A333C8;
    classDef external fill:#E2E2E2,stroke:#7A7A7A,color:#7A7A7A;
```
