India Air Advisor: an AI that tells you whether it's safe to go out, built serverless on AWS.
I got tired of apps that give you one AQI number for a whole city and leave you to guess whether it’s safe to go out. So I built one where you can pick any spot in India, see each pollutant, and just ask. Here’s how it works and what I learned building it on AWS.
The problem
On a bad-air day in India, the question is never "what is the AQI?" It is "should I go for my run, send my kid to the ground, or open the window?" Most apps show one number for one city and leave the rest to you. I wanted something where you pick any place in India, see every pollutant on the official CPCB AQI scale, and simply ask a question in plain language.
What it does
- Chat-first advisor. Ask "Should I go out today?", "Best time to run in Kolkata?" or "Compare Delhi and Mumbai." Answers use only numbers fetched by tools, never invented ones.
- Map and dashboard. 412 Indian cities, coloured by AQI or by a single pollutant (PM2.5, PM10, NO2, SO2, O3, CO, dust, UV). Tap anywhere in India for every pollutant, the CPCB 24-hour average, and a past-48h / next-48h chart.
- Heatmap mode. A smooth colour field over India, drawn in the browser.
- Email alerts. Get an email when AQI goes above or below a value you choose, or when a clean-air window opens.
- Phone-friendly glass UI. Full-screen translucent dashboard over the map on mobile, hamburger menu, light and dark themes.
Architecture

Everything is serverless, so it costs almost nothing when idle.
Piece | AWS service | Job |
|---|---|---|
Scheduler | Amazon EventBridge | Every 3 hours, triggers the ingest |
Ingest | AWS Lambda | Fetches model data for all cities, scores it to CPCB AQI, writes results |
Storage | Amazon DynamoDB (TTL) + Amazon S3 | One item per grid cell; an S3 snapshot feeds the map |
API | Amazon API Gateway (HTTP API) + Lambda | /stations, /lookup, /series, /chat, /alert, and the website itself |
AI | Strands Agents SDK | Agent with five tools; falls back to a rules engine if the model is unreachable |
Alerts | Amazon SNS | Per-recipient filter policy, so each person only gets their own emails |
Secrets | AWS Systems Manager Parameter Store | The LLM key, stored as a SecureString |
Safety | Amazon CloudWatch | Five alarms (below) |
The whole stack is one SAM template:
sam build && sam deploy .How the numbers are computed
The AQI follows CPCB: each of PM2.5, PM10, NO2, SO2, O3 and CO gets a sub-index from the CPCB breakpoints, and the AQI is the highest sub-index. Two details matter:
- 24-hour basis. CPCB uses 24-hour means (8-hour for O3 and CO). The dashboard shows both the latest-hour AQI and the 24-hour figure, which is the one to compare with official sources.
- Dust guard. If PM10 is very high but PM2.5 is not (PM10 at least 150 and more than 4x PM2.5), it is almost certainly a dust artefact in the model. PM10 is left out of the AQI and the card says so.
Each reading is also checked for freshness (under 3 hours old) and plausibility before it is scored.
The AI advisor
The advisor is a Strands agent with five tools: current air, forecast, best time windows, compare places, and create alert. It is told to use only tool output, to say the values are model estimates, and to give general guidance for sensitive groups without diagnosing anything. It talks to an OpenAI-compatible model (I used
openai/gpt-oss-120b on Groq, key kept in Parameter Store). If the model fails, a deterministic rules engine answers from the same data, so the chat never goes dark.Guards keep it cheap and safe: at most 5 model calls per question, an 18-second deadline, a daily cap on chat messages, and a strict input size limit.
Running it responsibly: cost and health alarms
Five CloudWatch alarms notify an ops email through SNS:
- API errors at 3 or more in 5 minutes.
- Ingest errors.
- Ingest stopped, meaning no run in 6 hours.
- Traffic spike above a set number of API calls per hour.
- Bill alarm if estimated charges pass a limit (default $5).
On top of that, the code enforces daily caps on live lookups and chat, and API Gateway throttles requests.
What I learned
- Caching by grid cell makes lookups cheap: two taps in the same cell cost one fetch.
- The AI should only say what the data says. The advisor works through tools: current air, forecast, best time windows, compare places, and set an alertAlarms are part of the product.
- One SAM template runs the whole stack. The functions, API, table, bucket, topics, alarms and permissions are all in a single
template.yaml.
Cost
Running it for the hackathon cost almost nothing. Most services sit in the free tier at this traffic.
What's next
- Blend in measured CPCB station readings where a station is close, and use the model only to fill gaps.
- Hindi and regional-language answers.
- Push notifications in addition to email.
Data and credits
Air-quality data: Open-Meteo (CC BY 4.0), based on Copernicus CAMS. City list: GeoNames (CC BY 4.0). Map: OpenStreetMap. Night lights: NASA GIBS. General information, not medical advice.
Enjoyed reading this content? Let the author know!
Your likes, comments, shares, and saves help creators reach more builders.
Loading recommendations
Loading article