Airpath: Building an Air Quality-Aware Commute Router with OpenStreetMap and AWS Open Source
Discover how Airpath combines realtime Open-Meteo atmospheric data, OpenStreetMap routing, and AWS open-source tools like LocalStack, S3, and DynamoDB to help cyclists and pedestrians cut toxic particulate inhalation by up to 40%.
Urban navigation has a dangerous blind spot: every navigation app exclusively optimizes for speed. To motorists occupying climate-controlled cabins it makes sense to save 2 minutes. But for the active commuter it means an additional dose of exhaust particulate along high-capacity ring roads and truck corridors.
Physical exertion causes the active commuter to inhale 3-4x more air per minute, allowing particulate matter, nitrogen dioxide, and ozone to penetrate deeper into the lung tissue.
To solve this I built Airpath, an open-source multi-objective commute routing application that factors in both travel time and real-time air pollution to guide commuters through low-pollution urban corridors.
How Airpath Works
Unlike route planners that only return the fastest route, Airpath returns 3 unique options:
The Lowest AQI Route (Cleanest Air): Prioritizes tree-canopy parkways, waterfronts, and un-trafficked residential streets to cut fine particulate matter inhalation by up to 40% for an average detour of just 2-4 minutes.
The Balanced Route: Balances distance, street hierarchy, and ambient pollution.
The Fastest Route
Each route is scored an AirScore (0-100) based on live atmospheric particulate readings and exertion multipliers (Walk: 1.0x / Cycle: 1.4x / Run: 1.9x).
In addition, the BreathBudget feature tracks cumulative daily pollutant inhalation against WHO limits (15 micrograms per cubic meter).
The Architecture & Tech Stack
A minimalist, 100% open source stack that does not require any paid proprietary mapping API:
Frontend: React 18 + TypeScript + Vite with a custom glassmorphic CSS design system.
Mapping: Leaflet + OpenStreetMap / CyclOSM (cycling infrastructure) / Humanitarian (HOT) tiles.
Routing: Project OSRM (Open Source Routing Machine) bike and foot profiles.
Atmosphere: Open-Meteo Air Quality API with no keys required for live US AQI, PM2.5, PM10, NO2, and Ozone.
Places Search: Komoot Photon (Elasticsearch powered OSM autocomplete) + OSM Nominatim + 120 km proximity-ranking filter.
How AWS and AWS Open Source Powers Airpath
To deliver enterprise-grade capabilities without incurring hosting bills and for users to configure IAM credentials I leveraged the AWS Open Source stack using LocalStack:
Amazon S3 (airpath-routes-bucket): Stores detailed route payloads, waypoints, and GeoJSON tracklogs as immutable objects.
Amazon DynamoDB (AirpathCommuteLogs): Single-table design uses userId as Partition Key and ISO timestamp as Sort Key for efficient personal exposure querying.
Amazon SNS (airpath-aqi-alerts): Automated notifications are triggered when atmospheric sensors detect hazardous regional air quality (AQI > 200).
Amazon CloudWatch: Metrics gathering to calculate aggregate community pollution savings and exposure doses.
AWS LocalStack: Dockerized container configuration (docker-compose.yml) and shell orchestration (init-localstack.sh) that emulate AWS services with no cloud costs.
What Fought Back: The Engineering Battles
Building a real-time environmental router had 3 major hurdles:
A. OSRM Arterial Bias Standard OSRM queries often return identical paths that diverge on the same arterial road by only 1 block. To solve this we built a vector diversion algorithm that calculates perpendicular geographic waypoints towards secondary streets and park corridors, requests distinct routes across these vectors, and filters redundant paths before scoring.
B. The Forced City Suffix Autocomplete Glitch Early prototypes appended the selected city name to search queries, which broke when commuters searched landmarks in neighboring metropolitan areas (DLF Cyber City in Gurgaon, Noida Sector 62, regional airports). We solved this by switching to Komoot Photon with coordinate proximity biasing and unconstrained boundaries. Results within 120 km rank first, but national and international landmarks remain fully searchable.
C. Nominatim Rate Limiting OpenStreetMap Nominatim has a 1 request/second rate limit and rapid keystrokes often resulted in 429 HTTP errors. We solved this with a 3-layer fallback: primary queries hit Komoot Photon (built for autocomplete throughput), secondary queries use debounced Nominatim, and all resolved places are cached in a client-side Map cache.
Summary & What's Next
By combining open environmental data with OpenStreetMap and the broader AWS open-source ecosystem, Airpath demonstrates that navigation apps do not have to sacrifice commuter health for speed.
Next on the roadmap:
Edge-based AWS Lambda ingestion of IoT hyperlocal air sensor data (PurpleAir feeds).
Turn-by-turn audio navigation with rerouting when dynamic traffic pollution spikes are detected ahead.
GitHub Repository: https://github.com/Bhaumik-99/Airpath
Enjoyed reading this content? Let the author know!
Your likes, comments, shares, and saves help creators reach more builders.
Loading recommendations
Loading article