# dasshiva/coolroute architecture

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

- Interactive diagram: https://gitdiagram.com/dasshiva/coolroute
- Repository: https://github.com/dasshiva/coolroute

## Overview

CoolRoute Delhi is a web app for comparing walking routes by estimated shade. Users choose an origin and destination on the map; the browser requests a route comparison, and the backend returns a fastest route and a shade-oriented alternative (or the direct route if no qualifying detour is found). The backend loads a shade grid, calls a routing service, scores candidate routes, and enforces a daily call quota. The excerpts show the frontend request and backend orchestration, but not the page markup, grid-generation implementation, or deployment wiring.

Main entry points: [`backend/app.py`](https://github.com/dasshiva/coolroute/blob/master/backend/app.py) (Request handler), [`frontend/app.js`](https://github.com/dasshiva/coolroute/blob/master/frontend/app.js) (Map and selection), [`backend/quota.py`](https://github.com/dasshiva/coolroute/blob/master/backend/quota.py) (Daily quota), [`backend/shade.py`](https://github.com/dasshiva/coolroute/blob/master/backend/shade.py) (Shade scoring)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Web client"]
  node_map_ui["Map and selection<br/>[app.js]"]
  node_route_results["Route results<br/>[app.js]"]
end

subgraph group_routing["Route service"]
  node_api_handler["Request handler<br/>[app.py]"]
  node_route_calc["Route calculation<br/>[app.py]"]
end

subgraph group_shade["Shade analysis"]
  node_shade_scoring["Shade scoring<br/>[shade.py]"]
  node_detour_candidates["Detour candidates<br/>[shade.py]"]
end

subgraph group_state["Data and quota"]
  node_grid_cache["Grid loading<br/>[app.py]"]
  node_shade_grid["Shade grid<br/>[shade_grid.json]"]
  node_quota_guard["Daily quota<br/>[quota.py]"]
end

node_user(("Route planner"))
node_quota_store[("Quota table")]
node_location_service["Routing service"]
node_object_store["Object storage"]
node_basemap["Map tiles"]

node_user -->|"selects points"| node_map_ui
node_map_ui -->|"posts route request"| node_api_handler
node_api_handler -->|"loads grid"| node_grid_cache
node_grid_cache -->|"reads grid object"| node_object_store
node_grid_cache -->|"caches grid data"| node_shade_grid
node_api_handler -->|"reserves calls"| node_quota_guard
node_quota_guard -->|"updates count"| node_quota_store
node_api_handler -->|"calculates routes"| node_route_calc
node_route_calc -->|"requests walking route"| node_location_service
node_api_handler -->|"scores routes"| node_shade_scoring
node_api_handler -->|"requests waypoints"| node_detour_candidates
node_api_handler -->|"returns comparison"| node_route_results
node_map_ui -.->|"loads map tiles"| node_basemap

click node_map_ui "https://github.com/dasshiva/coolroute/blob/master/frontend/app.js"
click node_route_results "https://github.com/dasshiva/coolroute/blob/master/frontend/app.js"
click node_api_handler "https://github.com/dasshiva/coolroute/blob/master/backend/app.py"
click node_route_calc "https://github.com/dasshiva/coolroute/blob/master/backend/app.py"
click node_shade_scoring "https://github.com/dasshiva/coolroute/blob/master/backend/shade.py"
click node_detour_candidates "https://github.com/dasshiva/coolroute/blob/master/backend/shade.py"
click node_grid_cache "https://github.com/dasshiva/coolroute/blob/master/backend/app.py"
click node_shade_grid "https://github.com/dasshiva/coolroute/blob/master/data/shade_grid.json"
click node_quota_guard "https://github.com/dasshiva/coolroute/blob/master/backend/quota.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_map_ui,node_route_results toneBlue
class node_api_handler,node_route_calc,node_quota_store,node_object_store toneAmber
class node_shade_scoring,node_detour_candidates,node_user toneMint
class node_grid_cache,node_shade_grid,node_quota_guard toneRose
class node_location_service,node_basemap toneIndigo
```

## Components

### Web client

- [Map and selection](https://github.com/dasshiva/coolroute/blob/master/frontend/app.js): `frontend/app.js`
- [Route results](https://github.com/dasshiva/coolroute/blob/master/frontend/app.js): `frontend/app.js`

### Route service

- [Request handler](https://github.com/dasshiva/coolroute/blob/master/backend/app.py): `backend/app.py`
- [Route calculation](https://github.com/dasshiva/coolroute/blob/master/backend/app.py): `backend/app.py`

### Shade analysis

- [Shade scoring](https://github.com/dasshiva/coolroute/blob/master/backend/shade.py): `backend/shade.py`
- [Detour candidates](https://github.com/dasshiva/coolroute/blob/master/backend/shade.py): `backend/shade.py`

### Data and quota

- [Grid loading](https://github.com/dasshiva/coolroute/blob/master/backend/app.py): `backend/app.py`
- [Shade grid](https://github.com/dasshiva/coolroute/blob/master/data/shade_grid.json): `data/shade_grid.json`
- [Daily quota](https://github.com/dasshiva/coolroute/blob/master/backend/quota.py): `backend/quota.py`

### Other components

- **Route planner**
- **Quota table**
- **Routing service**
- **Object storage**
- **Map tiles**

## Connections

- Route planner → Map and selection: selects points (evidence: `frontend/app.js`)
- Map and selection → Request handler: posts route request (evidence: `frontend/app.js`)
- Request handler → Grid loading: loads grid (evidence: `backend/app.py`)
- Grid loading → Object storage: reads grid object (evidence: `backend/app.py`)
- Grid loading → Shade grid: caches grid data (evidence: `backend/app.py`)
- Request handler → Daily quota: reserves calls (evidence: `backend/app.py`)
- Daily quota → Quota table: updates count (evidence: `backend/quota.py`)
- Request handler → Route calculation: calculates routes (evidence: `backend/app.py`)
- Route calculation → Routing service: requests walking route (evidence: `backend/app.py`)
- Request handler → Shade scoring: scores routes (evidence: `backend/app.py`)
- Request handler → Detour candidates: requests waypoints (evidence: `backend/app.py`)
- Request handler → Route results: returns comparison (evidence: `frontend/app.js`)
- Map and selection → Map tiles: loads map tiles (evidence: `frontend/app.js`)
