# lakshaykarad/rapidlink-backend architecture

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

- Interactive diagram: https://gitdiagram.com/lakshaykarad/rapidlink-backend
- Repository: https://github.com/lakshaykarad/rapidlink-backend

## Overview

RapidLink Backend combines account authentication with a device-based traffic dashboard and ETA scoring. The dashboard submits and displays device observations; the API persists them, summarizes speeds by road, and uses those summaries to estimate ETAs or rank caller-supplied candidate routes. Authentication is a separate API branch backed by SQL user/profile records. Although the README describes an OSRM routing engine, the sampled backend code does not call OSRM or generate routes; route ranking operates on routes supplied to its endpoint.

Main entry points: [`main.py`](https://github.com/lakshaykarad/rapidlink-backend/blob/main/main.py) (FastAPI entry), [`routers/auth.py`](https://github.com/lakshaykarad/rapidlink-backend/blob/main/routers/auth.py) (Auth routes), [`dependencies.py`](https://github.com/lakshaykarad/rapidlink-backend/blob/main/dependencies.py) (Active-user dependency), [`static/script.js`](https://github.com/lakshaykarad/rapidlink-backend/blob/main/static/script.js) (Map dashboard)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_api["Traffic API"]
  node_api["FastAPI entry<br/>[main.py]"]
  node_devices["Device registry<br/>[main.py]"]
  node_summary["Traffic summary<br/>[main.py]"]
  node_eta["ETA estimate<br/>[main.py]"]
  node_route_rank["Route ranking<br/>[main.py]"]
end

subgraph group_auth["Authentication"]
  node_auth_routes["Auth routes<br/>[auth.py]"]
  node_auth_dependencies["Active-user dependency<br/>[dependencies.py]"]
  node_auth_security["Token and password security<br/>[security.py]"]
  node_auth_schemas["Auth schemas<br/>[schemas.py]"]
end

subgraph group_storage["Persistence"]
  node_db_session["SQL session setup<br/>[database.py]"]
  node_user_models["User models<br/>[models.py]"]
  node_sql_db[("SQL database")]
  node_device_files["Device JSON and CSV<br/>[main.py]"]
end

subgraph group_dashboard["Map Dashboard"]
  node_dashboard["Map dashboard<br/>[script.js]"]
end

node_dashboard_user(("Dashboard user"))
node_map_tiles["OpenStreetMap tiles"]

node_api -->|"registers routes"| node_auth_routes
node_api -->|"creates tables"| node_user_models
node_api -->|"guards device add"| node_auth_dependencies
node_api -->|"creates tables from"| node_db_session
node_api -->|"serves device endpoints"| node_devices
node_api -->|"serves summary endpoint"| node_summary
node_api -->|"serves ETA endpoint"| node_eta
node_api -->|"serves ranking endpoint"| node_route_rank
node_devices -->|"reads and writes"| node_device_files
node_devices -->|"supplies observations"| node_summary
node_eta -->|"uses road speeds"| node_summary
node_route_rank -->|"uses road speeds"| node_summary
node_auth_routes -->|"protects profile routes"| node_auth_dependencies
node_auth_routes -->|"checks and issues tokens"| node_auth_security
node_auth_routes -->|"validates signup data"| node_auth_schemas
node_auth_routes -->|"queries and commits"| node_db_session
node_auth_routes -->|"reads and writes users"| node_user_models
node_auth_dependencies -->|"verifies access token"| node_auth_security
node_auth_dependencies -->|"loads session"| node_db_session
node_auth_dependencies -->|"loads active user"| node_user_models
node_db_session -->|"opens sessions"| node_sql_db
node_dashboard_user -->|"uses"| node_dashboard
node_dashboard -->|"requests device and traffic APIs"| node_api
node_dashboard -->|"loads map tiles"| node_map_tiles
node_api -->|"serves home page"| node_dashboard

click node_api "https://github.com/lakshaykarad/rapidlink-backend/blob/main/main.py"
click node_devices "https://github.com/lakshaykarad/rapidlink-backend/blob/main/main.py"
click node_summary "https://github.com/lakshaykarad/rapidlink-backend/blob/main/main.py"
click node_eta "https://github.com/lakshaykarad/rapidlink-backend/blob/main/main.py"
click node_route_rank "https://github.com/lakshaykarad/rapidlink-backend/blob/main/main.py"
click node_auth_routes "https://github.com/lakshaykarad/rapidlink-backend/blob/main/routers/auth.py"
click node_auth_dependencies "https://github.com/lakshaykarad/rapidlink-backend/blob/main/dependencies.py"
click node_auth_security "https://github.com/lakshaykarad/rapidlink-backend/blob/main/security.py"
click node_auth_schemas "https://github.com/lakshaykarad/rapidlink-backend/blob/main/schemas.py"
click node_db_session "https://github.com/lakshaykarad/rapidlink-backend/blob/main/database.py"
click node_user_models "https://github.com/lakshaykarad/rapidlink-backend/blob/main/models.py"
click node_device_files "https://github.com/lakshaykarad/rapidlink-backend/blob/main/main.py"
click node_dashboard "https://github.com/lakshaykarad/rapidlink-backend/blob/main/static/script.js"

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,node_devices,node_summary,node_eta,node_route_rank,node_dashboard_user toneBlue
class node_auth_routes,node_auth_dependencies,node_auth_security,node_auth_schemas toneAmber
class node_db_session,node_user_models,node_sql_db,node_device_files toneMint
class node_dashboard toneRose
class node_map_tiles toneIndigo
```

## Components

### Traffic API

- [FastAPI entry](https://github.com/lakshaykarad/rapidlink-backend/blob/main/main.py): `main.py`
- [Device registry](https://github.com/lakshaykarad/rapidlink-backend/blob/main/main.py): `main.py`
- [Traffic summary](https://github.com/lakshaykarad/rapidlink-backend/blob/main/main.py): `main.py`
- [ETA estimate](https://github.com/lakshaykarad/rapidlink-backend/blob/main/main.py): `main.py`
- [Route ranking](https://github.com/lakshaykarad/rapidlink-backend/blob/main/main.py): `main.py`

### Authentication

- [Auth routes](https://github.com/lakshaykarad/rapidlink-backend/blob/main/routers/auth.py): `routers/auth.py`
- [Active-user dependency](https://github.com/lakshaykarad/rapidlink-backend/blob/main/dependencies.py): `dependencies.py`
- [Token and password security](https://github.com/lakshaykarad/rapidlink-backend/blob/main/security.py): `security.py`
- [Auth schemas](https://github.com/lakshaykarad/rapidlink-backend/blob/main/schemas.py): `schemas.py`

### Persistence

- [SQL session setup](https://github.com/lakshaykarad/rapidlink-backend/blob/main/database.py): `database.py`
- [User models](https://github.com/lakshaykarad/rapidlink-backend/blob/main/models.py): `models.py`
- **SQL database**
- [Device JSON and CSV](https://github.com/lakshaykarad/rapidlink-backend/blob/main/main.py): `main.py`

### Map Dashboard

- [Map dashboard](https://github.com/lakshaykarad/rapidlink-backend/blob/main/static/script.js): `static/script.js`

### Other components

- **Dashboard user**
- **OpenStreetMap tiles**

## Connections

- FastAPI entry → Auth routes: registers routes (evidence: `main.py`)
- FastAPI entry → User models: creates tables (evidence: `main.py`)
- FastAPI entry → Active-user dependency: guards device add (evidence: `main.py`)
- FastAPI entry → SQL session setup: creates tables from (evidence: `main.py`)
- FastAPI entry → Device registry: serves device endpoints (evidence: `main.py`)
- FastAPI entry → Traffic summary: serves summary endpoint (evidence: `main.py`)
- FastAPI entry → ETA estimate: serves ETA endpoint (evidence: `main.py`)
- FastAPI entry → Route ranking: serves ranking endpoint (evidence: `main.py`)
- Device registry → Device JSON and CSV: reads and writes (evidence: `main.py`)
- Device registry → Traffic summary: supplies observations (evidence: `main.py`)
- ETA estimate → Traffic summary: uses road speeds (evidence: `main.py`)
- Route ranking → Traffic summary: uses road speeds (evidence: `main.py`)
- Auth routes → Active-user dependency: protects profile routes (evidence: `routers/auth.py`)
- Auth routes → Token and password security: checks and issues tokens (evidence: `routers/auth.py`)
- Auth routes → Auth schemas: validates signup data (evidence: `routers/auth.py`)
- Auth routes → SQL session setup: queries and commits (evidence: `routers/auth.py`)
- Auth routes → User models: reads and writes users (evidence: `routers/auth.py`)
- Active-user dependency → Token and password security: verifies access token (evidence: `dependencies.py`)
- Active-user dependency → SQL session setup: loads session (evidence: `dependencies.py`)
- Active-user dependency → User models: loads active user (evidence: `dependencies.py`)
- SQL session setup → SQL database: opens sessions (evidence: `database.py`)
- Dashboard user → Map dashboard: uses (evidence: `static/script.js`)
- Map dashboard → FastAPI entry: requests device and traffic APIs (evidence: `static/script.js`)
- Map dashboard → OpenStreetMap tiles: loads map tiles (evidence: `static/script.js`)
- FastAPI entry → Map dashboard: serves home page (evidence: `main.py`)
