# keval2609/hospital-apointment-api architecture

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

- Interactive diagram: https://gitdiagram.com/keval2609/hospital-apointment-api
- Repository: https://github.com/keval2609/hospital-apointment-api

## Overview

Hospital Appointment API is a FastAPI service for JWT authentication and role-controlled user, doctor, and patient profile management; the README does not describe appointment-booking endpoints. Requests enter the versioned API, pass through route handlers and business services, then access PostgreSQL through repositories and SQLAlchemy. Authentication also uses password/JWT security utilities and a token blacklist. The README documents pagination, filtering, validation, structured errors, and request logging. Service and route source was not sampled, so detailed per-operation wiring is intentionally omitted.

Main entry points: [`app/api/v1/router.py`](https://github.com/keval2609/hospital-apointment-api/blob/master/app/api/v1/router.py) (v1 router), [`app/repositories/user_repository.py`](https://github.com/keval2609/hospital-apointment-api/blob/master/app/repositories/user_repository.py) (User repository), [`app/main.py`](https://github.com/keval2609/hospital-apointment-api/blob/master/app/main.py) (FastAPI app), [`app/schemas`](https://github.com/keval2609/hospital-apointment-api/tree/master/app/schemas) (Request and response schemas)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["Application runtime"]
  node_app["FastAPI app<br/>[main.py]"]
  node_middleware["Request middleware<br/>[middleware.py]"]
  node_handlers["Exception handlers"]
  node_dependencies["Dependency wiring<br/>[dependencies.py]"]
end

subgraph group_api["HTTP API"]
  node_v1router["v1 router<br/>[router.py]"]
  node_authroutes["Auth routes<br/>[auth.py]"]
  node_useroutes["User routes<br/>[users.py]"]
  node_doctorroutes["Doctor routes<br/>[doctors.py]"]
  node_patientroutes["Patient routes<br/>[patients.py]"]
  node_schemas["Request and response schemas"]
end

subgraph group_logic["Business services"]
  node_authservice["Authentication service<br/>[auth_service.py]"]
  node_userservice["User service<br/>[user_service.py]"]
  node_doctorservice["Doctor service<br/>[doctor_service.py]"]
  node_patientservice["Patient service<br/>[patient_service.py]"]
end

subgraph group_persistence["Persistence"]
  node_userrepo["User repository<br/>[user_repository.py]"]
  node_doctorrepo["Doctor repository"]
  node_patientrepo["Patient repository"]
  node_blacklistrepo["Token blacklist repository"]
  node_models["ORM models"]
  node_database["Async database sessions<br/>[database.py]"]
end

subgraph group_crosscut["Security and responses"]
  node_security["JWT and password security<br/>[security.py]"]
end

node_client(("API client"))
node_postgres[("PostgreSQL")]

node_client -->|"sends requests"| node_app
node_app -->|"registers"| node_middleware
node_app -->|"registers"| node_handlers
node_app -->|"includes"| node_v1router
node_v1router -->|"dispatches"| node_authroutes
node_v1router -->|"dispatches"| node_useroutes
node_v1router -->|"dispatches"| node_doctorroutes
node_v1router -->|"dispatches"| node_patientroutes
node_authroutes -->|"validates with"| node_schemas
node_useroutes -->|"validates with"| node_schemas
node_doctorroutes -->|"validates with"| node_schemas
node_patientroutes -->|"validates with"| node_schemas
node_authservice -->|"uses"| node_userrepo
node_authservice -->|"uses"| node_blacklistrepo
node_authservice -->|"creates and verifies tokens"| node_security
node_doctorservice -->|"uses"| node_doctorrepo
node_doctorservice -->|"checks users"| node_userrepo
node_patientservice -->|"uses"| node_patientrepo
node_patientservice -->|"checks users"| node_userrepo
node_userservice -->|"uses"| node_userrepo
node_userrepo -->|"queries"| node_models
node_doctorrepo -->|"queries"| node_models
node_patientrepo -->|"queries"| node_models
node_blacklistrepo -->|"queries"| node_models
node_database -->|"opens sessions"| node_postgres

click node_app "https://github.com/keval2609/hospital-apointment-api/blob/master/app/main.py"
click node_middleware "https://github.com/keval2609/hospital-apointment-api/blob/master/app/middleware.py"
click node_handlers "https://github.com/keval2609/hospital-apointment-api/blob/master/app/exception_handlers.py"
click node_v1router "https://github.com/keval2609/hospital-apointment-api/blob/master/app/api/v1/router.py"
click node_authroutes "https://github.com/keval2609/hospital-apointment-api/blob/master/app/api/v1/auth.py"
click node_useroutes "https://github.com/keval2609/hospital-apointment-api/blob/master/app/api/v1/users.py"
click node_doctorroutes "https://github.com/keval2609/hospital-apointment-api/blob/master/app/api/v1/doctors.py"
click node_patientroutes "https://github.com/keval2609/hospital-apointment-api/blob/master/app/api/v1/patients.py"
click node_dependencies "https://github.com/keval2609/hospital-apointment-api/blob/master/app/dependencies.py"
click node_authservice "https://github.com/keval2609/hospital-apointment-api/blob/master/app/services/auth_service.py"
click node_userservice "https://github.com/keval2609/hospital-apointment-api/blob/master/app/services/user_service.py"
click node_doctorservice "https://github.com/keval2609/hospital-apointment-api/blob/master/app/services/doctor_service.py"
click node_patientservice "https://github.com/keval2609/hospital-apointment-api/blob/master/app/services/patient_service.py"
click node_schemas "https://github.com/keval2609/hospital-apointment-api/tree/master/app/schemas"
click node_security "https://github.com/keval2609/hospital-apointment-api/blob/master/app/core/security.py"
click node_userrepo "https://github.com/keval2609/hospital-apointment-api/blob/master/app/repositories/user_repository.py"
click node_doctorrepo "https://github.com/keval2609/hospital-apointment-api/blob/master/app/repositories/doctor_repository.py"
click node_patientrepo "https://github.com/keval2609/hospital-apointment-api/blob/master/app/repositories/patient_repository.py"
click node_blacklistrepo "https://github.com/keval2609/hospital-apointment-api/blob/master/app/repositories/token_blacklist_repository.py"
click node_models "https://github.com/keval2609/hospital-apointment-api/tree/master/app/models"
click node_database "https://github.com/keval2609/hospital-apointment-api/blob/master/app/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_app,node_middleware,node_handlers,node_dependencies,node_client toneBlue
class node_v1router,node_authroutes,node_useroutes,node_doctorroutes,node_patientroutes,node_schemas,node_postgres toneAmber
class node_authservice,node_userservice,node_doctorservice,node_patientservice toneMint
class node_userrepo,node_doctorrepo,node_patientrepo,node_blacklistrepo,node_models,node_database toneRose
class node_security toneIndigo
```

## Components

### Application runtime

- [FastAPI app](https://github.com/keval2609/hospital-apointment-api/blob/master/app/main.py): `app/main.py`
- [Request middleware](https://github.com/keval2609/hospital-apointment-api/blob/master/app/middleware.py): `app/middleware.py`
- [Exception handlers](https://github.com/keval2609/hospital-apointment-api/blob/master/app/exception_handlers.py): `app/exception_handlers.py`
- [Dependency wiring](https://github.com/keval2609/hospital-apointment-api/blob/master/app/dependencies.py): `app/dependencies.py`

### HTTP API

- [v1 router](https://github.com/keval2609/hospital-apointment-api/blob/master/app/api/v1/router.py): `app/api/v1/router.py`
- [Auth routes](https://github.com/keval2609/hospital-apointment-api/blob/master/app/api/v1/auth.py): `app/api/v1/auth.py`
- [User routes](https://github.com/keval2609/hospital-apointment-api/blob/master/app/api/v1/users.py): `app/api/v1/users.py`
- [Doctor routes](https://github.com/keval2609/hospital-apointment-api/blob/master/app/api/v1/doctors.py): `app/api/v1/doctors.py`
- [Patient routes](https://github.com/keval2609/hospital-apointment-api/blob/master/app/api/v1/patients.py): `app/api/v1/patients.py`
- [Request and response schemas](https://github.com/keval2609/hospital-apointment-api/tree/master/app/schemas): `app/schemas`

### Business services

- [Authentication service](https://github.com/keval2609/hospital-apointment-api/blob/master/app/services/auth_service.py): `app/services/auth_service.py`
- [User service](https://github.com/keval2609/hospital-apointment-api/blob/master/app/services/user_service.py): `app/services/user_service.py`
- [Doctor service](https://github.com/keval2609/hospital-apointment-api/blob/master/app/services/doctor_service.py): `app/services/doctor_service.py`
- [Patient service](https://github.com/keval2609/hospital-apointment-api/blob/master/app/services/patient_service.py): `app/services/patient_service.py`

### Persistence

- [User repository](https://github.com/keval2609/hospital-apointment-api/blob/master/app/repositories/user_repository.py): `app/repositories/user_repository.py`
- [Doctor repository](https://github.com/keval2609/hospital-apointment-api/blob/master/app/repositories/doctor_repository.py): `app/repositories/doctor_repository.py`
- [Patient repository](https://github.com/keval2609/hospital-apointment-api/blob/master/app/repositories/patient_repository.py): `app/repositories/patient_repository.py`
- [Token blacklist repository](https://github.com/keval2609/hospital-apointment-api/blob/master/app/repositories/token_blacklist_repository.py): `app/repositories/token_blacklist_repository.py`
- [ORM models](https://github.com/keval2609/hospital-apointment-api/tree/master/app/models): `app/models`
- [Async database sessions](https://github.com/keval2609/hospital-apointment-api/blob/master/app/database.py): `app/database.py`

### Security and responses

- [JWT and password security](https://github.com/keval2609/hospital-apointment-api/blob/master/app/core/security.py): `app/core/security.py`

### Other components

- **API client**
- **PostgreSQL**

## Connections

- API client → FastAPI app: sends requests
- FastAPI app → Request middleware: registers
- FastAPI app → Exception handlers: registers
- FastAPI app → v1 router: includes
- v1 router → Auth routes: dispatches
- v1 router → User routes: dispatches
- v1 router → Doctor routes: dispatches
- v1 router → Patient routes: dispatches
- Auth routes → Request and response schemas: validates with
- User routes → Request and response schemas: validates with
- Doctor routes → Request and response schemas: validates with
- Patient routes → Request and response schemas: validates with
- Authentication service → User repository: uses
- Authentication service → Token blacklist repository: uses
- Authentication service → JWT and password security: creates and verifies tokens
- Doctor service → Doctor repository: uses
- Doctor service → User repository: checks users
- Patient service → Patient repository: uses
- Patient service → User repository: checks users
- User service → User repository: uses
- User repository → ORM models: queries
- Doctor repository → ORM models: queries
- Patient repository → ORM models: queries
- Token blacklist repository → ORM models: queries
- Async database sessions → PostgreSQL: opens sessions
