# abhiveeramallu/routefusion architecture

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

- Interactive diagram: https://gitdiagram.com/abhiveeramallu/routefusion
- Repository: https://github.com/abhiveeramallu/routefusion

## Overview

RouteFusion is a ride-and-parcel dispatch product: riders and senders submit requests, while captains receive an explainable recommendation to accept a ride, parcel, both, or neither. The React app routes role-specific pages through shared client state to a FastAPI JSON API. The captain workflow combines per-driver matching, route optimization, and an atomic acceptance decision; separate fleet-wide assignment analytics feed the dashboard. Authentication, demo seeding, concurrency protection, maps, and optional persistent storage are supporting capabilities. Some route and service implementations were not sampled, so those links are included only where the README or source index documents them.

Main entry points: [`frontend/src/lib/api.ts`](https://github.com/abhiveeramallu/routefusion/blob/main/frontend/src/lib/api.ts) (REST client), [`backend/app/routes/captain.py`](https://github.com/abhiveeramallu/routefusion/blob/main/backend/app/routes/captain.py) (Captain recommendations), [`backend/app/models.py`](https://github.com/abhiveeramallu/routefusion/blob/main/backend/app/models.py) (Domain records), [`frontend/src/App.tsx`](https://github.com/abhiveeramallu/routefusion/blob/main/frontend/src/App.tsx) (Page routing)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["React client"]
  node_app["Page routing<br/>[App.tsx]"]
  node_booking["Ride and parcel booking<br/>[BookingHubPage.tsx]"]
  node_captain_ui["Captain decisions"]
  node_dashboard_ui["Dashboard view<br/>[DashboardPage.tsx]"]
  node_map_ui["Live map<br/>[LiveMapCanvas.tsx]"]
  node_client_state["Shared app state"]
  node_api_client["REST client<br/>[api.ts]"]
end

subgraph group_api["API workflows"]
  node_auth_routes["Authentication routes<br/>[auth.py]"]
  node_request_routes["Ride and parcel routes<br/>[ride.py]"]
  node_captain_routes["Captain recommendations<br/>[captain.py]"]
  node_dashboard_routes["Dashboard analytics<br/>[dashboard.py]"]
  node_demo_routes["Demo controls<br/>[demo.py]"]
end

subgraph group_matching["Dispatch engine"]
  node_assignment["Assignment engine"]
  node_optimizer["Route optimizer<br/>[route_optimizer.py]"]
  node_concurrency["Acceptance guard<br/>[concurrency.py]"]
end

subgraph group_platform["Identity and state"]
  node_auth["JWT and identity<br/>[auth.py]"]
  node_models["Domain records<br/>[models.py]"]
  node_database[("SQLAlchemy store<br/>[database.py]")]
  node_demo_seed["Demo data<br/>[demo_seed.py]"]
end

subgraph group_insights["Maps and analytics"]
  node_map_scenario["Map scenarios<br/>[mapScenario.ts]"]
  node_fleet_analytics["Fleet assignment metrics"]
  node_maps_service["Google Maps integration<br/>[googleMaps.ts]"]
end

node_user(("Rider or captain"))

node_user -->|"uses"| node_app
node_app -->|"routes to"| node_booking
node_app -->|"routes to"| node_captain_ui
node_app -->|"routes to"| node_dashboard_ui
node_booking -->|"reads and updates"| node_client_state
node_captain_ui -.->|"reads and updates"| node_client_state
node_dashboard_ui -->|"reads"| node_client_state
node_map_ui -->|"uses"| node_maps_service
node_map_ui -->|"uses"| node_map_scenario
node_client_state -->|"calls"| node_api_client
node_api_client -.->|"sends REST requests"| node_auth_routes
node_api_client -.->|"sends REST requests"| node_request_routes
node_api_client -.->|"sends REST requests"| node_captain_routes
node_api_client -.->|"sends REST requests"| node_dashboard_routes
node_api_client -.->|"sends REST requests"| node_demo_routes
node_auth_routes -->|"authenticates"| node_auth
node_auth_routes -->|"seeds demo"| node_demo_seed
node_captain_routes -->|"matches driver"| node_assignment
node_captain_routes -->|"scores route"| node_optimizer
node_captain_routes -->|"guards acceptance"| node_concurrency
node_dashboard_routes -->|"computes fleet metrics"| node_assignment
node_demo_routes -->|"manages demo data"| node_demo_seed
node_assignment -->|"queries records"| node_models
node_assignment -->|"evaluates routes"| node_optimizer
node_concurrency -->|"records conflicts"| node_models
node_auth -->|"reads and writes identity"| node_models
node_demo_seed -->|"creates demo records"| node_models
node_models -->|"maps to"| node_database
node_dashboard_routes -.->|"reuses logic"| node_captain_routes

click node_app "https://github.com/abhiveeramallu/routefusion/blob/main/frontend/src/App.tsx"
click node_booking "https://github.com/abhiveeramallu/routefusion/blob/main/frontend/src/pages/BookingHubPage.tsx"
click node_captain_ui "https://github.com/abhiveeramallu/routefusion/blob/main/frontend/src/pages/CaptainCornerPage.tsx"
click node_dashboard_ui "https://github.com/abhiveeramallu/routefusion/blob/main/frontend/src/pages/DashboardPage.tsx"
click node_map_ui "https://github.com/abhiveeramallu/routefusion/blob/main/frontend/src/components/LiveMapCanvas.tsx"
click node_client_state "https://github.com/abhiveeramallu/routefusion/blob/main/frontend/src/context/RouteFusionContext.tsx"
click node_api_client "https://github.com/abhiveeramallu/routefusion/blob/main/frontend/src/lib/api.ts"
click node_auth_routes "https://github.com/abhiveeramallu/routefusion/blob/main/backend/app/routes/auth.py"
click node_request_routes "https://github.com/abhiveeramallu/routefusion/blob/main/backend/app/routes/ride.py"
click node_captain_routes "https://github.com/abhiveeramallu/routefusion/blob/main/backend/app/routes/captain.py"
click node_dashboard_routes "https://github.com/abhiveeramallu/routefusion/blob/main/backend/app/routes/dashboard.py"
click node_demo_routes "https://github.com/abhiveeramallu/routefusion/blob/main/backend/app/routes/demo.py"
click node_assignment "https://github.com/abhiveeramallu/routefusion/blob/main/backend/app/services/assignment_engine.py"
click node_optimizer "https://github.com/abhiveeramallu/routefusion/blob/main/backend/app/services/route_optimizer.py"
click node_concurrency "https://github.com/abhiveeramallu/routefusion/blob/main/backend/app/services/concurrency.py"
click node_auth "https://github.com/abhiveeramallu/routefusion/blob/main/backend/app/auth.py"
click node_models "https://github.com/abhiveeramallu/routefusion/blob/main/backend/app/models.py"
click node_database "https://github.com/abhiveeramallu/routefusion/blob/main/backend/app/database.py"
click node_demo_seed "https://github.com/abhiveeramallu/routefusion/blob/main/backend/app/services/demo_seed.py"
click node_map_scenario "https://github.com/abhiveeramallu/routefusion/blob/main/frontend/src/lib/mapScenario.ts"
click node_fleet_analytics "https://github.com/abhiveeramallu/routefusion/blob/main/backend/app/services/assignment_engine.py"
click node_maps_service "https://github.com/abhiveeramallu/routefusion/blob/main/frontend/src/lib/googleMaps.ts"

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_booking,node_captain_ui,node_dashboard_ui,node_map_ui,node_client_state,node_api_client toneBlue
class node_auth_routes,node_request_routes,node_captain_routes,node_dashboard_routes,node_demo_routes toneAmber
class node_assignment,node_optimizer,node_concurrency toneMint
class node_auth,node_models,node_database,node_demo_seed toneRose
class node_map_scenario,node_fleet_analytics,node_maps_service,node_user toneIndigo
```

## Components

### React client

- [Page routing](https://github.com/abhiveeramallu/routefusion/blob/main/frontend/src/App.tsx): `frontend/src/App.tsx`
- [Ride and parcel booking](https://github.com/abhiveeramallu/routefusion/blob/main/frontend/src/pages/BookingHubPage.tsx): `frontend/src/pages/BookingHubPage.tsx`
- [Captain decisions](https://github.com/abhiveeramallu/routefusion/blob/main/frontend/src/pages/CaptainCornerPage.tsx): `frontend/src/pages/CaptainCornerPage.tsx`
- [Dashboard view](https://github.com/abhiveeramallu/routefusion/blob/main/frontend/src/pages/DashboardPage.tsx): `frontend/src/pages/DashboardPage.tsx`
- [Live map](https://github.com/abhiveeramallu/routefusion/blob/main/frontend/src/components/LiveMapCanvas.tsx): `frontend/src/components/LiveMapCanvas.tsx`
- [Shared app state](https://github.com/abhiveeramallu/routefusion/blob/main/frontend/src/context/RouteFusionContext.tsx): `frontend/src/context/RouteFusionContext.tsx`
- [REST client](https://github.com/abhiveeramallu/routefusion/blob/main/frontend/src/lib/api.ts): `frontend/src/lib/api.ts`

### API workflows

- [Authentication routes](https://github.com/abhiveeramallu/routefusion/blob/main/backend/app/routes/auth.py): `backend/app/routes/auth.py`
- [Ride and parcel routes](https://github.com/abhiveeramallu/routefusion/blob/main/backend/app/routes/ride.py): `backend/app/routes/ride.py`
- [Captain recommendations](https://github.com/abhiveeramallu/routefusion/blob/main/backend/app/routes/captain.py): `backend/app/routes/captain.py`
- [Dashboard analytics](https://github.com/abhiveeramallu/routefusion/blob/main/backend/app/routes/dashboard.py): `backend/app/routes/dashboard.py`
- [Demo controls](https://github.com/abhiveeramallu/routefusion/blob/main/backend/app/routes/demo.py): `backend/app/routes/demo.py`

### Dispatch engine

- [Assignment engine](https://github.com/abhiveeramallu/routefusion/blob/main/backend/app/services/assignment_engine.py): `backend/app/services/assignment_engine.py`
- [Route optimizer](https://github.com/abhiveeramallu/routefusion/blob/main/backend/app/services/route_optimizer.py): `backend/app/services/route_optimizer.py`
- [Acceptance guard](https://github.com/abhiveeramallu/routefusion/blob/main/backend/app/services/concurrency.py): `backend/app/services/concurrency.py`

### Identity and state

- [JWT and identity](https://github.com/abhiveeramallu/routefusion/blob/main/backend/app/auth.py): `backend/app/auth.py`
- [Domain records](https://github.com/abhiveeramallu/routefusion/blob/main/backend/app/models.py): `backend/app/models.py`
- [SQLAlchemy store](https://github.com/abhiveeramallu/routefusion/blob/main/backend/app/database.py): `backend/app/database.py`
- [Demo data](https://github.com/abhiveeramallu/routefusion/blob/main/backend/app/services/demo_seed.py): `backend/app/services/demo_seed.py`

### Maps and analytics

- [Map scenarios](https://github.com/abhiveeramallu/routefusion/blob/main/frontend/src/lib/mapScenario.ts): `frontend/src/lib/mapScenario.ts`
- [Fleet assignment metrics](https://github.com/abhiveeramallu/routefusion/blob/main/backend/app/services/assignment_engine.py): `backend/app/services/assignment_engine.py`
- [Google Maps integration](https://github.com/abhiveeramallu/routefusion/blob/main/frontend/src/lib/googleMaps.ts): `frontend/src/lib/googleMaps.ts`

### Other components

- **Rider or captain**

## Connections

- Rider or captain → Page routing: uses (evidence: `frontend/src/App.tsx`)
- Page routing → Ride and parcel booking: routes to (evidence: `frontend/src/App.tsx`)
- Page routing → Captain decisions: routes to (evidence: `frontend/src/App.tsx`)
- Page routing → Dashboard view: routes to (evidence: `frontend/src/App.tsx`)
- Ride and parcel booking → Shared app state: reads and updates (evidence: `frontend/src/pages/BookingHubPage.tsx`)
- Captain decisions → Shared app state: reads and updates
- Dashboard view → Shared app state: reads (evidence: `frontend/src/pages/DashboardPage.tsx`)
- Live map → Google Maps integration: uses (evidence: `frontend/src/components/LiveMapCanvas.tsx`)
- Live map → Map scenarios: uses (evidence: `frontend/src/components/LiveMapCanvas.tsx`)
- Shared app state → REST client: calls (evidence: `frontend/src/context/RouteFusionContext.tsx`)
- REST client → Authentication routes: sends REST requests
- REST client → Ride and parcel routes: sends REST requests
- REST client → Captain recommendations: sends REST requests
- REST client → Dashboard analytics: sends REST requests
- REST client → Demo controls: sends REST requests
- Authentication routes → JWT and identity: authenticates (evidence: `backend/app/routes/auth.py`)
- Authentication routes → Demo data: seeds demo (evidence: `backend/app/routes/auth.py`)
- Captain recommendations → Assignment engine: matches driver (evidence: `backend/app/routes/captain.py`)
- Captain recommendations → Route optimizer: scores route (evidence: `backend/app/routes/captain.py`)
- Captain recommendations → Acceptance guard: guards acceptance (evidence: `backend/app/routes/captain.py`)
- Dashboard analytics → Assignment engine: computes fleet metrics (evidence: `backend/app/routes/dashboard.py`)
- Demo controls → Demo data: manages demo data (evidence: `backend/app/routes/demo.py`)
- Assignment engine → Domain records: queries records (evidence: `backend/app/services/assignment_engine.py`)
- Assignment engine → Route optimizer: evaluates routes (evidence: `backend/app/services/assignment_engine.py`)
- Acceptance guard → Domain records: records conflicts (evidence: `backend/app/services/concurrency.py`)
- JWT and identity → Domain records: reads and writes identity (evidence: `backend/app/auth.py`)
- Demo data → Domain records: creates demo records (evidence: `backend/app/services/demo_seed.py`)
- Domain records → SQLAlchemy store: maps to (evidence: `backend/app/models.py`)
- Dashboard analytics → Captain recommendations: reuses logic (evidence: `backend/app/routes/dashboard.py`)
