# aswind-s-varman/booking-api architecture

> Architecture diagram of the GitHub repository aswind-s-varman/booking-api, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-15). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/aswind-s-varman/booking-api
- Repository: https://github.com/aswind-s-varman/booking-api

## Overview

booking-api provides authenticated resource scheduling through both a JSON API and a server-rendered interface. Users register or log in, discover resources and slots, then create, list, or cancel bookings; administrators manage resources. Booking conflicts are resolved atomically by a partial unique database index, while cancellation preserves booking history. The graph separates API routes, browser UI, identity, and persistence. Relationships are limited to the supplied excerpts and README; unsampled migration and template details are not inferred.

Main entry points: [`src/booking_api/database.py`](https://github.com/aswind-s-varman/booking-api/blob/main/src/booking_api/database.py) (Session and engine), [`src/booking_api/routers/bookings.py`](https://github.com/aswind-s-varman/booking-api/blob/main/src/booking_api/routers/bookings.py) (Booking routes), [`src/booking_api/web.py`](https://github.com/aswind-s-varman/booking-api/blob/main/src/booking_api/web.py) (UI routes), [`src/booking_api/main.py`](https://github.com/aswind-s-varman/booking-api/blob/main/src/booking_api/main.py) (FastAPI app)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["Application entry"]
  node_app["FastAPI app<br/>[main.py]"]
end

subgraph group_api["JSON API"]
  node_auth_routes["Authentication routes<br/>[auth.py]"]
  node_resource_routes["Resource routes<br/>[resources.py]"]
  node_booking_routes["Booking routes<br/>[bookings.py]"]
  node_schemas["Request and response schemas<br/>[schemas.py]"]
end

subgraph group_web["Browser interface"]
  node_web_routes["UI routes<br/>[web.py]"]
  node_slots["Slot generation<br/>[availability.py]"]
  node_templates["Jinja templates"]
end

subgraph group_identity["Identity and access"]
  node_security["Password and tokens<br/>[security.py]"]
  node_access["User and admin access<br/>[dependencies.py]"]
end

subgraph group_data["Persistence"]
  node_models["User resource bookings<br/>[models.py]"]
  node_database["Session and engine<br/>[database.py]"]
  node_config["Runtime settings<br/>[config.py]"]
  node_store[("SQL database")]
end

node_client(("API client"))
node_browser(("Browser user"))

node_client -->|"sends requests"| node_app
node_browser -->|"opens UI"| node_app
node_app -->|"registers"| node_auth_routes
node_app -->|"registers"| node_resource_routes
node_app -->|"registers"| node_booking_routes
node_app -->|"registers"| node_web_routes
node_auth_routes -->|"validates and returns"| node_schemas
node_resource_routes -->|"validates and returns"| node_schemas
node_booking_routes -->|"validates and returns"| node_schemas
node_auth_routes -->|"hashes and issues tokens"| node_security
node_auth_routes -->|"gets session"| node_database
node_auth_routes -->|"queries users"| node_models
node_resource_routes -->|"requires admin or user"| node_access
node_resource_routes -->|"gets session"| node_database
node_resource_routes -->|"reads and changes resources"| node_models
node_booking_routes -->|"requires user"| node_access
node_booking_routes -->|"gets session"| node_database
node_booking_routes -->|"reads and changes bookings"| node_models
node_web_routes -->|"generates slots"| node_slots
node_web_routes -->|"renders pages"| node_templates
node_web_routes -->|"checks cookie tokens"| node_security
node_web_routes -->|"gets session"| node_database
node_web_routes -->|"reads and changes records"| node_models
node_access -->|"decodes tokens"| node_security
node_access -->|"gets session"| node_database
node_access -->|"loads user"| node_models
node_database -->|"reads settings"| node_config
node_models -->|"uses declarative base"| node_database
node_database -.->|"queries and commits"| node_store
node_security -->|"reads token settings"| node_config
node_booking_routes -->|"relies on unique slot constraint"| node_store

click node_app "https://github.com/aswind-s-varman/booking-api/blob/main/src/booking_api/main.py"
click node_auth_routes "https://github.com/aswind-s-varman/booking-api/blob/main/src/booking_api/routers/auth.py"
click node_resource_routes "https://github.com/aswind-s-varman/booking-api/blob/main/src/booking_api/routers/resources.py"
click node_booking_routes "https://github.com/aswind-s-varman/booking-api/blob/main/src/booking_api/routers/bookings.py"
click node_schemas "https://github.com/aswind-s-varman/booking-api/blob/main/src/booking_api/schemas.py"
click node_web_routes "https://github.com/aswind-s-varman/booking-api/blob/main/src/booking_api/web.py"
click node_slots "https://github.com/aswind-s-varman/booking-api/blob/main/src/booking_api/availability.py"
click node_templates "https://github.com/aswind-s-varman/booking-api/tree/main/src/booking_api/templates"
click node_security "https://github.com/aswind-s-varman/booking-api/blob/main/src/booking_api/security.py"
click node_access "https://github.com/aswind-s-varman/booking-api/blob/main/src/booking_api/dependencies.py"
click node_models "https://github.com/aswind-s-varman/booking-api/blob/main/src/booking_api/models.py"
click node_database "https://github.com/aswind-s-varman/booking-api/blob/main/src/booking_api/database.py"
click node_config "https://github.com/aswind-s-varman/booking-api/blob/main/src/booking_api/config.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_client,node_browser toneBlue
class node_auth_routes,node_resource_routes,node_booking_routes,node_schemas toneAmber
class node_web_routes,node_slots,node_templates toneMint
class node_security,node_access toneRose
class node_models,node_database,node_config,node_store toneIndigo
```

## Components

### Application entry

- [FastAPI app](https://github.com/aswind-s-varman/booking-api/blob/main/src/booking_api/main.py): `src/booking_api/main.py`

### JSON API

- [Authentication routes](https://github.com/aswind-s-varman/booking-api/blob/main/src/booking_api/routers/auth.py): `src/booking_api/routers/auth.py`
- [Resource routes](https://github.com/aswind-s-varman/booking-api/blob/main/src/booking_api/routers/resources.py): `src/booking_api/routers/resources.py`
- [Booking routes](https://github.com/aswind-s-varman/booking-api/blob/main/src/booking_api/routers/bookings.py): `src/booking_api/routers/bookings.py`
- [Request and response schemas](https://github.com/aswind-s-varman/booking-api/blob/main/src/booking_api/schemas.py): `src/booking_api/schemas.py`

### Browser interface

- [UI routes](https://github.com/aswind-s-varman/booking-api/blob/main/src/booking_api/web.py): `src/booking_api/web.py`
- [Slot generation](https://github.com/aswind-s-varman/booking-api/blob/main/src/booking_api/availability.py): `src/booking_api/availability.py`
- [Jinja templates](https://github.com/aswind-s-varman/booking-api/tree/main/src/booking_api/templates): `src/booking_api/templates`

### Identity and access

- [Password and tokens](https://github.com/aswind-s-varman/booking-api/blob/main/src/booking_api/security.py): `src/booking_api/security.py`
- [User and admin access](https://github.com/aswind-s-varman/booking-api/blob/main/src/booking_api/dependencies.py): `src/booking_api/dependencies.py`

### Persistence

- [User resource bookings](https://github.com/aswind-s-varman/booking-api/blob/main/src/booking_api/models.py): `src/booking_api/models.py`
- [Session and engine](https://github.com/aswind-s-varman/booking-api/blob/main/src/booking_api/database.py): `src/booking_api/database.py`
- [Runtime settings](https://github.com/aswind-s-varman/booking-api/blob/main/src/booking_api/config.py): `src/booking_api/config.py`
- **SQL database**

### Other components

- **API client**
- **Browser user**

## Connections

- API client → FastAPI app: sends requests (evidence: `src/booking_api/main.py`)
- Browser user → FastAPI app: opens UI (evidence: `src/booking_api/main.py`)
- FastAPI app → Authentication routes: registers (evidence: `src/booking_api/main.py`)
- FastAPI app → Resource routes: registers (evidence: `src/booking_api/main.py`)
- FastAPI app → Booking routes: registers (evidence: `src/booking_api/main.py`)
- FastAPI app → UI routes: registers (evidence: `src/booking_api/main.py`)
- Authentication routes → Request and response schemas: validates and returns (evidence: `src/booking_api/routers/auth.py`)
- Resource routes → Request and response schemas: validates and returns (evidence: `src/booking_api/routers/resources.py`)
- Booking routes → Request and response schemas: validates and returns (evidence: `src/booking_api/routers/bookings.py`)
- Authentication routes → Password and tokens: hashes and issues tokens (evidence: `src/booking_api/routers/auth.py`)
- Authentication routes → Session and engine: gets session (evidence: `src/booking_api/routers/auth.py`)
- Authentication routes → User resource bookings: queries users (evidence: `src/booking_api/routers/auth.py`)
- Resource routes → User and admin access: requires admin or user (evidence: `src/booking_api/routers/resources.py`)
- Resource routes → Session and engine: gets session (evidence: `src/booking_api/routers/resources.py`)
- Resource routes → User resource bookings: reads and changes resources (evidence: `src/booking_api/routers/resources.py`)
- Booking routes → User and admin access: requires user (evidence: `src/booking_api/routers/bookings.py`)
- Booking routes → Session and engine: gets session (evidence: `src/booking_api/routers/bookings.py`)
- Booking routes → User resource bookings: reads and changes bookings (evidence: `src/booking_api/routers/bookings.py`)
- UI routes → Slot generation: generates slots (evidence: `src/booking_api/web.py`)
- UI routes → Jinja templates: renders pages (evidence: `src/booking_api/web.py`)
- UI routes → Password and tokens: checks cookie tokens (evidence: `src/booking_api/web.py`)
- UI routes → Session and engine: gets session (evidence: `src/booking_api/web.py`)
- UI routes → User resource bookings: reads and changes records (evidence: `src/booking_api/web.py`)
- User and admin access → Password and tokens: decodes tokens (evidence: `src/booking_api/dependencies.py`)
- User and admin access → Session and engine: gets session (evidence: `src/booking_api/dependencies.py`)
- User and admin access → User resource bookings: loads user (evidence: `src/booking_api/dependencies.py`)
- Session and engine → Runtime settings: reads settings (evidence: `src/booking_api/database.py`)
- User resource bookings → Session and engine: uses declarative base (evidence: `src/booking_api/models.py`)
- Session and engine → SQL database: queries and commits
- Password and tokens → Runtime settings: reads token settings (evidence: `src/booking_api/security.py`)
- Booking routes → SQL database: relies on unique slot constraint (evidence: `README.md`)
