Building better_AQI: Hyper-Local Pollution Intelligence with AWS Strands Agents, SAM CLI, and LocalStack
How we built a serverless environmental decision platform that turns abstract air quality numbers into life-saving commute, school, and indoor action protocols.
Building better_AQI: Hyper-Local Pollution Intelligence with AWS Strands Agents, SAM CLI, and LocalStack
Every winter, millions of citizens across Indian metropolitan hubs like Delhi NCR wake up under a dense, toxic smog blanket. While standard weather apps report a single, abstract Air Quality Index (AQI) number recorded at a distant monitoring tower kilometers away, that number fails to answer critical everyday questions:
- Which commute route exposes my lungs to the least toxic particulate matter?
- Is it safe for 800 school students to conduct outdoor morning assembly today?
- When will seasonal stubble smoke plumes reach our neighborhood?
- How many minutes must we run our classroom HEPA purifier to reach medical-grade safe air?
To bridge this gap between raw environmental sensors, satellite telemetry, and human safety, we built better_AQI for Track 01 (Air) of the WeMakeDevs & AWS Environmental Hacks 2026.
In this post, we'll dive into the architecture of better_AQI, how we leveraged the AWS Strands Agents SDK powered by Amazon Bedrock, and how we used the AWS SAM CLI and LocalStack to achieve a completely reproducible serverless deployment.
Architecture Overview: Serverless by Design
better_AQI is built from the ground up following AWS serverless best practices. Rather than running persistent, costly EC2 instances, our platform scales to zero during off-peak hours and instantly absorbs traffic spikes during peak morning commute and evening pollution alerts.
Architecture Flow:
[ React 19 Frontend (Vite) ]
|
v
[ Amazon API Gateway (HTTP API) ]
|
v
[ AWS Lambda (Python 3.12 + Mangum) ] <--- [ AWS EventBridge (Hourly Cron) ]
| | |
v v v
[ Open-Meteo & [ Amazon [ Amazon SNS
NASA FIRMS ] DynamoDB ] Spike Alerts ]
(Subscriptions)
Core AWS Services Used:
- AWS Lambda (BetterAqiApiFunction): Executes our Python 3.12 FastAPI backend through the Mangum ASGI adapter, maintaining sub-100ms response times.
- Amazon API Gateway (BetterAqiHttpApi): Manages TLS termination, global CORS, and low-latency route dispatch.
- Amazon DynamoDB (better_aqi_subscriptions): NoSQL document store persisting user coordinates, alert thresholds, and notification preferences.
- Amazon SNS (better_aqi_spike_alerts): Manages pub/sub fan-out for real-time SMS and email alerts during severe smog spikes.
- AWS EventBridge (HourlyAirQualityCheckSchedule): Evaluates live environmental sensors against subscriber alert thresholds every hour.
- Amazon Bedrock: Foundation models powering our agentic environmental reasoning engine.
Orchestrating Environmental Intelligence with AWS Strands Agents
A key innovation in better_AQI is the AI Air Advisor, built using the open-source AWS Strands Agents SDK (strands-agents) and Amazon Bedrock.
Traditional chatbots often hallucinate safety metrics. With Strands Agents, the model is equipped with typed Python tools connected directly to our scientific calculation engines:
- Tool 1: check_live_air_quality(city) -> Fetches live multi-pollutant levels (PM2.5, PM10, AQI) calibrated to Indian CPCB NAAQS breakpoints.
- Tool 2: evaluate_school_safety(pm25) -> Evaluates assembly, recess, and mid-day ventilation safety for schools.
- Tool 3: calculate_commute_inhalation(route, mode) -> Calculates inhaled toxic PM2.5 dosage and Berkeley Earth cigarette equivalents.
When a school principal asks, "Can we hold sports day outside today in Noida?", the Strands Agent executes check_live_air_quality, verifies the PM2.5 level against CPCB thresholds, calls evaluate_school_safety, and delivers an authoritative, actionable recommendation rather than generic conversational filler.
Infrastructure as Code with AWS SAM CLI and LocalStack
To ensure our cloud infrastructure is 100% reproducible and verifiable, we defined our entire stack in a concise AWS SAM template (template.yaml):
- Serverless Function: Defined using Python 3.12 runtime with HTTP API Gateway proxy integration.
- Database: Modeled as a pay-per-request Amazon DynamoDB table with a single partition key.
- Notifications: Declared an Amazon SNS topic for instant spike alert fan-out.
- Scheduling: Created an AWS EventBridge scheduled rule running hourly evaluations.
Zero-Cost Cloud Emulation with LocalStack
During early development, we avoided cloud deployment friction by using LocalStack in Docker:
docker compose -f docker-compose.localstack.yml up -d This allowed our automated pytest suite to test DynamoDB subscriptions and SNS notifications locally with zero cloud costs and zero credential dependencies.
Scientific Rigor: Moving Beyond Abstract Scores
better_AQI integrates peer-reviewed environmental models into the user experience:
- Cleanest Commute Engine: Calculates minute-by-minute respiratory uptake across transit modes (Bicycle, Two-Wheeler, Car with AC Cabin Filter, Walking) and displays inhaled toxic dosage in Berkeley Earth cigarette equivalents (22 ug PM2.5 / 24hr ≈ 1 cigarette).
- NASA Stubble Burning Plume Tracking: Combines active NASA satellite thermal hotspot coordinates across Punjab and Haryana with live boundary-layer wind vectors to track downwind smoke corridors.
- Classroom CADR Countdown: Models room volume and building envelope leakage to provide a live countdown timer until a HEPA purifier achieves safe indoor air (< 30 ug/m3).
Key Learnings & Developer Takeaways
- Agent Tool-Calling vs. Prompt Stuffing: Giving an LLM dedicated, typed Python tools via AWS Strands Agents produces orders of magnitude more reliable answers than prompting a model with raw context blobs.
- SAM Simplifies Serverless: Declaring API Gateway routes, Lambda triggers, DynamoDB tables, and EventBridge cron rules in under 120 lines of SAM YAML saved hours of AWS console clicking.
- Cloud Parity Accelerates Velocity: Testing serverless storage and pub/sub pipelines locally via LocalStack enabled us to write comprehensive unit and integration tests before touching the cloud.
Get Involved
- GitHub Repository: https://github.com/akshayaparida/better\_AQI
- Built for: WeMakeDevs & AWS Environmental Hacks 2026 (Track 01: Air)
Enjoyed reading this content? Let the author know!
Your likes, comments, shares, and saves help creators reach more builders.
Loading recommendations
Loading article