AWS Builder Center
Seeing the Air We Inhale

Seeing the Air We Inhale

Why We Built Ecolens Around Restraint, Not Fear

On November 3rd, 2023, during peak post-monsoon stubble burning in Northern India, the official government monitoring station at Anand Vihar recorded an Air Quality Index of 468 deep in the "Severe+" category. Yet three kilometers away, a university student checking a generic navigation app was shown an AQI of 78, because the app’s weather widget pulled from a regional sensor 20 kilometers upwind.
Trusting that cheerful green number, the student strapped on a backpack and cycled their usual commute along the inner ring road. They pedaled through a dense, concrete street canyon trapped between diesel freight lanes and flyover walls. By evening, they were in an emergency clinic with acute bronchospasm, clutching a nebulizer.
The easy reaction is to ask: Which sensor was right?
That is the wrong question, and it is the exact question we deliberately built Ecolens not to answer.
Nobody necessarily did anything wrong here. Air quality is not a flat, static layer painted across a metropolis. Particulate matter (PM 2.5) and nitrogen dioxide (NO2) stratify vertically; diurnal thermal inversions trap exhaust within narrow corridors while leaving adjacent tree-lined residential streets clean; and wind shear carries stubble-burning plumes across highway bypasses in narrow, moving ribbons.
The problem isn't that the air varied across the city. The problem is that navigation software has a fatal blind spot: it treats the atmosphere as empty, invisible space and optimizes exclusively for speed. Five commuters taking five different routes through the same city receive the exact same aggregate weather card, while their lungs absorb radically different toxic payloads.
That is the actual thing we set out to build: not an alarmist panic button, not a generic heat map that splashes red over an entire zip code, and not a tool that tells you whether you're allowed to leave your house. A system that shows the physical reality of exposure itself this street segment carries this pollution concentration, at this time of day, this route cuts your inhalation dose by this exact volume, and here is how the smoke plume is moving downwind and leaves the decision to the person breathing it.

The Feature We Refused to Rush

Everything else in Ecolens multi-agent travel itineraries, audio tour generation, calendar syncing, and satellite radar feeds exists to support one central output: an honest, mathematically grounded, street-level exposure differential between where a commuter is asked to go and where they could choose to walk or ride.
We treated that output as the one thing that had to be physically sound before anything else mattered, because it is the only thing standing between a sensitive commuter and an emergency room visit. Getting it right meant being disciplined about two things we could easily have gotten wrong.
First: Never present air quality as a flat aggregate or an arbitrary fear score. It would have been easy to calculate an average city AQI, paint the entire UI red, and send users frantic push notifications telling them "The air is toxic, stay inside." That is an assertion about panic, and it helps no one who has a job to work or an exam to take.
Air pollution is a physical mass-transfer problem
plaintext
Inhalation Dose = ∫₀ᵀ C(x(t), t) × V_E × dt
It depends on localized concentration along a specific path  C(x, t) , human minute ventilation rate  V_E , and the duration of exposure  T . A route that is three minutes longer through an urban park can reduce total respiratory deposition of ultra-fine particulates by over 35% compared to sitting in gridlock behind exhaust pipes.
So the output never presents a vague "danger rating." It displays the physical segment concentrations, the estimated inhalation mass, and the clean alternative side-by-side, and stops there.
Second: Never let pure transit velocity decide which route segments belong together. This was the subtlest challenge, and it consumed most of our early architecture discussions. If you let a standard routing algorithm ( Dijkstra or A* ) evaluate cost purely by edge travel time, it will invariably funnel cyclists and pedestrians into wide arterial avenues because they have higher theoretical speed limits. But arterial avenues are precisely where heavy diesel freight concentrates.
To break this without producing irrational, winding detours, our routing cost function couples transit duration with Gaussian Process Regression (GPR) spatial interpolation across dynamic segment centroids:
Python
kernel = RBF(length_scale=0.1, length_scale_bounds=(0.01, 1.0)) + WhiteKernel(noise_level=1.0)
def _fit_gpr(rows):
X = np.array([[r.lat, r.lon] for r in rows])
y = np.array([r.value for r in rows])
gpr = GaussianProcessRegressor(kernel=kernel, n_restarts_optimizer=2, normalize_y=True)
gpr.fit(X, y)
return gpr
# Recompute segment ecological penalty based on interpolated physics
seg.ecoscore = max(0, min(100, int(
100
- (0.35 * seg.pm25)
- (8.0 * float(seg.co2_per_min or 0))
- (0.9 * float(seg.noise_db or 0))
+ (12.0 * float(seg.ndvi or 0))
)))

Neither of these is an aesthetic design choice. Both are restraint choices deciding ahead of time what the software is not allowed to oversimplify, and building the spatial graph so it is structurally incapable of sacrificing human lung tissue for ninety seconds of transit time.

What the Output Actually Looks Like

The output of Ecolens is not a red-alert banner. It is a side by side physical comparison:
plaintext
[Fastest Route] → 18 mins → Avg PM2.5: 142 µg/m³ → Estimated Inhaled Dose: 28.4 µg
[Ecolens Clean] → 21 mins → Avg PM2.5: 58 µg/m³ → Estimated Inhaled Dose: 16.2 µg (−43%)

No claim that the commuter is "forbidden" to take the highway. No sensationalized skull-and-crossbones icons. Just the sequence, the micro-climate data, the trade-off in minutes, and the exact respiratory exposure, so the commuter can decide for themselves in five seconds which trade-off makes sense today.
When pediatric vulnerabilities or school zones are involved, that restraint is formalized using AWS Cedar not by letting an LLM guess what is safe, but by evaluating strict, deterministic policies:
YAML
// app/policies/pediatric_safety.cedar: Verifiable health policy specification
permit(
principal in Group::"Students",
action in [Action::"OutdoorPlay", Action::"StandardRecess"],
resource == Facility::"SchoolPlayground"
)
when {
context.outdoor_aqi <= 100 || !context.has_respiratory_vulnerability
};
forbid(
principal in Group::"SensitiveStudents",
action == Action::"ActiveWalkCommute",
resource == Route::"SchoolCommute"
)
when {
context.outdoor_aqi > 100 && !context.wearing_n95_mask
};

An administrator or parent does not have to trust a black-box model. The rule is declarative, auditable, and mathematically evaluated.

Why This Mattered More Than Adding Features

We had a longer feature backlog in the planning stages: automated social media shaming of high-emission corridors, crowd-sourced "smell reports," and an AI chatbot that diagnosed respiratory symptoms.
We cut all three.
We cut them not because they were difficult to code, but because each one shifts the tool from "here is what the atmospheric measurements show" to "here is an unverified opinion." An unverified medical diagnosis is dangerous. A crowd-sourced smell score implies data consistency it cannot possess.
What we kept instead were the core tools that solve the physical problem:
  1. Hyperlocal Environmental Routing: Inhalation-aware pathfinding using GPR spatial interpolation.
  1. Wildfire & Stubble Smoke Radar: Ingesting live NASA EONET satellite hotspots and running wind-vector plume projections.
  1. Diurnal Ventilation Windows: Modeling EPA/ASHRAE indoor infiltration to show the exact two-hour window when opening a window introduces the least particulate mass.
  1. The Explore Hub: Multi-agent travel planning and narrated audio guides for low-carbon travel.

The Architecture, and Why It's Shaped the Way It Is

Ecolens’ pipeline runs across seven interconnected layers. The shape of the architecture follows directly from the founding principle: never let cloud dependencies or ungrounded generative models make claims the underlying environmental physics cannot verify.
plaintext
[ Frontend: MapLibre GL + TanStack Router ]
│ (REST / GeoJSON)
[ Backend Gateway: FastAPI + Adapter Pattern ]
├── [ GPR Spatial Engine & Segment Router ]
├── [ AWS OpenSearch: 600km Satellite Geo-Indexing ]
├── [ AWS Cedar: Deterministic Pediatric Policy Engine ]
├── [ AWS SAM / Lambda: Serverless Plume Dispersion ]
├── [ Amazon Bedrock / Agno: Multi-Agent Travel & Audio ]
└── [ LocalStack / AWS S3: Audio & .ics Storage ]

  1. Frontend: Exploration and route lineage, not a verdict dashboard The user interface (built with React, TypeScript, TanStack Start/Router, and MapLibre GL) does not present a single static score. It renders dynamic vector layers: live wind trajectories, satellite thermal anomalies, road segments colored by micro-exposure, and step-by-step route comparisons. Users do not wonder why a route was suggested; they can see the plume vector blowing away from the green line on their screen.
  1. FastAPI Ingestion & Environmental Mesh Telemetry arrives from OpenAQ ground stations, WAQI feeds, and Open-Meteo meteorological endpoints. The backend maintains an asynchronous scheduler that updates live readings, fits Gaussian Process regression models every 30 minutes, and re-scores street network segments.
  1. Geospatial Indexing on AWS OpenSearch Tracking agricultural burning and wildfires requires scanning hundreds of active thermal hotspots from NASA EONET, MODIS, and VIIRS across massive territories. We index these coordinates in AWS OpenSearch using native geo_point spatial mappings. This enables sub-millisecond proximity queries across a 600-kilometer radius to detect whether an upwind source is threatening a commuter's city. If OpenSearch is not running locally, our adapter automatically falls back to native Haversine spatial math without interrupting the user.
  1. Deterministic Authorization on AWS Cedar Rather than prompting an LLM to decide whether recess should be canceled or whether an asthmatic child should walk unmasked, we use the AWS Cedar Policy Engine. Policies compile into an Abstract Syntax Tree (AST), ensuring safety decisions are deterministic, auditable, and impossible for an LLM prompt hallucination to bypass.
  1. Multi-Agent Orchestration on Amazon Bedrock For our Explore Hub, planning an eco-friendly trip requires specialized division of labor. Built using the Agno framework and integrated with Amazon Bedrock (utilizing Anthropic Claude 3.5 Sonnet and Amazon Nova), tasks are split into isolated roles:
Environmental Agent: Analyzes the green transit footprint. Historical & Cultural Agents: Research verified local landmarks. Planner Agent: Synthesizes the itinerary into a structured schema and produces standard .ics calendar files. 6. Serverless Compute on AWS SAM CLI Complex atmospheric dispersion calculations modeling how a satellite-detected smoke plume expands downwind over six hours are decoupled into a dedicated serverless Lambda microservice (PlumeDispersionFunction), defined and tested locally using the AWS SAM CLI.
  1. Object Storage & Audio Pipeline on Amazon S3 & LocalStack Our audio tour engine synthesizes localized guides into .mp3 files via text-to-speech. These audio files and calendar attachments are uploaded to an S3 bucket backed locally by LocalStack, enabling full cloud-native emulation without cloud bills or external network dependencies.
  1. Containerization on AWS Finch & Amazon Corretto To ensure hackathon judges and external contributors can run the entire system offline, the microservices are containerized via AWS Finch (finch compose) and run on Amazon Corretto 21, maintaining complete parity between local development and cloud production.
In Simple Words Ecolens doesn't tell you to stay home, and it doesn't give you a simplistic, aggregate number that conceals the polluted reality of your street. It models what the air is actually doing, shows you how your route changes what you breathe, and gives you the agency to protect your own lungs.
Any opinions in this article are those of the individual author and may not reflect the opinions of AWS.
Enjoyed reading this content? Let the author know!

Your likes, comments, shares, and saves help creators reach more builders.

Loading recommendations

Loading article