# hvarun4262-dev/ride-booking-dbms architecture

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

- Interactive diagram: https://gitdiagram.com/hvarun4262-dev/ride-booking-dbms
- Repository: https://github.com/hvarun4262-dev/ride-booking-dbms

## Overview

This is a FastAPI ride-booking DBMS demo. Its main workflow accepts ride requests and handles acceptance, start, completion, and ratings through transactional endpoints; a separate endpoint provides a surge heatmap. The app obtains PostgreSQL sessions through a shared database layer. The README also highlights SQL triggers, window functions, and state transitions; those database capabilities are represented, but their SQL files were not sampled, so their internal relationships to API operations are not asserted.

Main entry points: [`app/main.py`](https://github.com/hvarun4262-dev/ride-booking-dbms/blob/main/app/main.py) (FastAPI entry), [`app/routes/rides.py`](https://github.com/hvarun4262-dev/ride-booking-dbms/blob/main/app/routes/rides.py) (Ride transactions), [`app/routes/analytics.py`](https://github.com/hvarun4262-dev/ride-booking-dbms/blob/main/app/routes/analytics.py) (Ride analytics), [`app/db.py`](https://github.com/hvarun4262-dev/ride-booking-dbms/blob/main/app/db.py) (DB sessions)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_api["API"]
  node_api_entry["FastAPI entry<br/>[main.py]"]
  node_ride_routes["Ride transactions<br/>[rides.py]"]
  node_analytics_routes["Ride analytics<br/>[analytics.py]"]
end

subgraph group_runtime["Database access"]
  node_db_sessions["DB sessions<br/>[db.py]"]
  node_ride_store[("Ride database<br/>[01_schema.sql]")]
end

subgraph group_sql["SQL capabilities"]
  node_indexes["Query indexes<br/>[02_indexes.sql]"]
  node_triggers["State triggers<br/>[03_triggers.sql]"]
  node_seed_data["Seed data<br/>[04_seed_data.sql]"]
  node_complex_queries["Window queries"]
end

node_client(("API client"))

node_client -->|"sends requests"| node_api_entry
node_api_entry -->|"registers routes"| node_ride_routes
node_api_entry -->|"registers routes"| node_analytics_routes
node_ride_routes -->|"requests sessions"| node_db_sessions
node_analytics_routes -->|"requests sessions"| node_db_sessions
node_db_sessions -->|"opens sessions"| node_ride_store
node_ride_routes -->|"writes ride data"| node_ride_store
node_analytics_routes -->|"queries rides"| node_ride_store

click node_api_entry "https://github.com/hvarun4262-dev/ride-booking-dbms/blob/main/app/main.py"
click node_ride_routes "https://github.com/hvarun4262-dev/ride-booking-dbms/blob/main/app/routes/rides.py"
click node_analytics_routes "https://github.com/hvarun4262-dev/ride-booking-dbms/blob/main/app/routes/analytics.py"
click node_db_sessions "https://github.com/hvarun4262-dev/ride-booking-dbms/blob/main/app/db.py"
click node_ride_store "https://github.com/hvarun4262-dev/ride-booking-dbms/blob/main/database/01_schema.sql"
click node_indexes "https://github.com/hvarun4262-dev/ride-booking-dbms/blob/main/database/02_indexes.sql"
click node_triggers "https://github.com/hvarun4262-dev/ride-booking-dbms/blob/main/database/03_triggers.sql"
click node_seed_data "https://github.com/hvarun4262-dev/ride-booking-dbms/blob/main/database/04_seed_data.sql"
click node_complex_queries "https://github.com/hvarun4262-dev/ride-booking-dbms/blob/main/database/05_complex_queries.sql"

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_api_entry,node_ride_routes,node_analytics_routes,node_client toneBlue
class node_db_sessions,node_ride_store toneAmber
class node_indexes,node_triggers,node_seed_data,node_complex_queries toneMint
```

## Components

### API

- [FastAPI entry](https://github.com/hvarun4262-dev/ride-booking-dbms/blob/main/app/main.py): `app/main.py`
- [Ride transactions](https://github.com/hvarun4262-dev/ride-booking-dbms/blob/main/app/routes/rides.py): `app/routes/rides.py`
- [Ride analytics](https://github.com/hvarun4262-dev/ride-booking-dbms/blob/main/app/routes/analytics.py): `app/routes/analytics.py`

### Database access

- [DB sessions](https://github.com/hvarun4262-dev/ride-booking-dbms/blob/main/app/db.py): `app/db.py`
- [Ride database](https://github.com/hvarun4262-dev/ride-booking-dbms/blob/main/database/01_schema.sql): `database/01_schema.sql`

### SQL capabilities

- [Query indexes](https://github.com/hvarun4262-dev/ride-booking-dbms/blob/main/database/02_indexes.sql): `database/02_indexes.sql`
- [State triggers](https://github.com/hvarun4262-dev/ride-booking-dbms/blob/main/database/03_triggers.sql): `database/03_triggers.sql`
- [Seed data](https://github.com/hvarun4262-dev/ride-booking-dbms/blob/main/database/04_seed_data.sql): `database/04_seed_data.sql`
- [Window queries](https://github.com/hvarun4262-dev/ride-booking-dbms/blob/main/database/05_complex_queries.sql): `database/05_complex_queries.sql`

### Other components

- **API client**

## Connections

- API client → FastAPI entry: sends requests (evidence: `README.md`)
- FastAPI entry → Ride transactions: registers routes (evidence: `app/main.py`)
- FastAPI entry → Ride analytics: registers routes (evidence: `app/main.py`)
- Ride transactions → DB sessions: requests sessions (evidence: `app/routes/rides.py`)
- Ride analytics → DB sessions: requests sessions (evidence: `app/routes/analytics.py`)
- DB sessions → Ride database: opens sessions (evidence: `app/db.py`)
- Ride transactions → Ride database: writes ride data (evidence: `app/routes/rides.py`)
- Ride analytics → Ride database: queries rides (evidence: `app/routes/analytics.py`)
