Imported repository documentation. Claims and project status reflect the source. Read the source on GitHub ↗
Namma Parking
Real-time parking score visualizer for Bangalore roads - built on Cloudflare Workers + Pages + D1.
Architecture
┌─────────────────────────┐ ┌──────────────────────────────────────┐
│ Cloudflare Pages │ │ Cloudflare Worker │
│ React + MapLibre GL │──/api──▶ TypeScript │
│ (frontend/) │ │ • Parking scoring engine (inline) │
└─────────────────────────┘ │ • Nominatim geocode proxy │
│ • D1 spatial bbox queries │
│ (worker/) │
└──────────────┬───────────────────────┘
│
┌──────▼──────┐
│ Cloudflare │
│ D1 (SQLite) │
│ road_segments│
│ pois │
└─────────────┘
No Docker. No PostgreSQL. No PostGIS. No Python runtime.
The AI scoring service has been ported to pure TypeScript and runs inline inside the Worker.
Spatial queries use indexed center_lat/center_lng columns instead of PostGIS geometry.
Quick Start
1. Install dependencies
npm run setup
2. Create the D1 database (once)
npm run db:create
# Copy the database_id printed by wrangler into worker/wrangler.toml
3. Apply schema
npm run db:migrate
4. Seed with OpenStreetMap data
# Generate SQL from Overpass API (central Bangalore by default)
npm run db:generate-seed
# Load into local D1
npm run db:seed
To seed a different area, run directly:
cd database/seeds
python3 seed_for_d1.py --bbox 12.900,77.500,13.050,77.700
5. Run locally
In two terminals:
npm run dev:worker # Worker on http://localhost:8787
npm run dev:frontend # Frontend on http://localhost:5173
Deployment
Worker
npm run deploy:worker
Note the worker URL (e.g. https://namma-parking-worker.YOUR_SUBDOMAIN.workers.dev)
Frontend (Pages)
Set VITE_API_BASE_URL in frontend/.env.production or as a Pages environment variable:
VITE_API_BASE_URL=https://namma-parking-worker.YOUR_SUBDOMAIN.workers.dev
Then:
cd frontend
npm run build
npm run deploy
Or connect your GitHub repo to Cloudflare Pages with build command npm run build and output dir dist.
Remote database seed
npm run db:migrate:remote
npm run db:seed:remote
Project Structure
NammaParking/
├── worker/ # Cloudflare Worker (TypeScript)
│ ├── src/
│ │ ├── index.ts # Request router + D1 queries
│ │ └── scoring.ts # Parking scoring engine (ported from Python)
│ └── wrangler.toml
├── frontend/ # Cloudflare Pages (React + Vite + MapLibre)
│ ├── src/
│ └── wrangler.toml
├── database/
│ ├── migrations/
│ │ └── d1_schema.sql # SQLite schema for D1
│ └── seeds/
│ └── seed_for_d1.py # Fetches OSM data → outputs seed_data.sql
└── Makefile
Scoring Factors
| Factor | Weight | Description |
|---|---|---|
| Road Type | 27% | residential > collector > lane > arterial > highway |
| Road Width | 13% | 5-12m optimal; very narrow/wide penalized |
| Intersection Distance | 13% | No parking within 15m (Indian traffic law) |
| Lane Count | 11% | 1-2 lanes tolerated; 3+ penalized |
| Traffic Congestion | 10% | Live traffic data - heavy traffic reduces parking availability |
| Bus Stop Proximity | 9% | No parking within 15m |
| Restricted Zone | 9% | Hospitals and schools |
| Market Proximity | 5% | High demand near markets |
| One-Way Street | 3% | Slight bonus (one side free) |
Score >= 65 = Green | 35-64 = Yellow | < 35 = Red
Features
- Greater Bangalore Coverage: Service area includes Airport, Attibele, Jigani, KR Puram, Tavarekere, Nelamangala, Nagenahalli
- Satellite View: Toggle between street map and satellite imagery
- Location Preview: Road detail panel shows satellite imagery of the location
- Live Traffic Integration: Real-time traffic congestion affects parking scores
- Dark Mode: Full dark theme support
- Real OSM Data: All road data sourced from OpenStreetMap
Traffic API Setup (Optional)
To enable live traffic data:
[vars]
TOMTOM_API_KEY = "your_api_key_here"
Without API key, traffic factor uses neutral default (50% congestion).