Building SaansSchool: An Automated Serverless Air Defense System for Indian Schools using AWS SAM, Lambda & DynamoDB
How we architected a 100% Free Tier serverless platform on AWS to ingest real-time CPCB ground stations and NASA satellite fire feeds, evaluate statutory environmental math, and protect millions of schoolchildren before 6:00 AM school bus departures.
Building SaansSchool: A Serverless Air-Quality Decision Support System for Indian Schools on AWS
The Problem: Making School Air-Quality Decisions Before the First Bell
During periods of severe air pollution, schools face difficult operational decisions about outdoor assemblies, physical education (PE), classroom ventilation, and student commutes.
Children are particularly vulnerable to air pollution because their lungs are still developing. Physical exertion can also increase breathing rates and the amount of polluted air inhaled during outdoor activities.
Three challenges make these decisions difficult:
- Children's exposure: School administrators need to consider the potential health effects of air pollution when planning outdoor activities.
- Time-sensitive decisions: Morning commutes and assemblies require timely environmental information before the school day begins.
- Fragmented environmental observations: Ground monitoring stations, weather services, and satellite fire-detection systems provide data with different formats, spatial coverage, and update schedules.
A city-level Air Quality Index (AQI) reading is useful, but it may not fully represent conditions at an individual school. Administrators need accessible environmental information, transparent decision rules, and practical guidance that accounts for data quality and uncertainty.
We built SaansSchool to explore how environmental data and a rules-based decision-support system can help schools make more informed air-quality decisions.
The System Architecture on AWS
SaansSchool explores a serverless architecture that separates environmental data ingestion, evaluation, storage, and communication. AWS services can support these components without requiring continuously running application servers.
The AWS Serverless Application Model (AWS SAM) provides an Infrastructure as Code approach for defining serverless resources in a
template.yaml file. The architecture described below represents the intended system design; individual services and integrations should be identified as deployed only when confirmed in the project code and AWS environment.
. Ingestion Layer: Amazon EventBridge and AWS Lambda
An Amazon EventBridge scheduled rule can invoke an AWS Lambda function named
saans-ingest at a configured interval, such as every 15 minutes.The proposed ingestion workflow uses three environmental data sources:
- Central Pollution Control Board (CPCB): Air-quality observations from Continuous Ambient Air Quality Monitoring Stations (CAAQMS), subject to data availability and access.
- NASA FIRMS — Suomi-NPP VIIRS: Near-real-time satellite thermal anomaly detections with nominal 375 m spatial resolution at nadir. These detections can help identify potential fire activity, but they do not independently establish that a fire is present or that smoke is reaching a school. NASA FIRMS documentation
- Open-Meteo: Weather observations or forecasts, including wind speed and direction, depending on the selected API endpoint and configuration.
The ingestion layer should normalize incoming records, preserve source timestamps, handle missing values, and identify unavailable or stale observations before downstream evaluation.
A 15-minute execution schedule does not guarantee that every source publishes new observations every 15 minutes. The application should retain the actual observation time and source rather than treating every retrieval as new data.
2. Recent Telemetry Storage: Amazon DynamoDB with TTL
Environmental observations and school-status records can be stored in Amazon DynamoDB, using the
SaansSchoolDailyStatus table.DynamoDB Time to Live (TTL) supports the asynchronous deletion of expired items. A TTL attribute can be configured for a desired retention period, such as 24 hours, without a separate scheduled cleanup process.
However, TTL deletion is not guaranteed to occur at the exact expiration time. Consequently, retention and data freshness must be handled separately.
SaansSchool should validate observation timestamps when reading records and avoid generating current advisories from data that is too old for the intended decision.
3. Administrative Action Audit Trail: Amazon DynamoDB
When a school administrator records an operational decision, such as moving PE indoors or changing an outdoor activity schedule, the application can record the event in the
SaansSchoolActionAudit table.An audit record may contain:
- School identifier
- Selected operational action
- Timestamp of the decision
- Associated AQI reading or advisory
- Administrator identifier, where appropriate
This record can help reconstruct the decisions made during a pollution episode.
DynamoDB does not automatically make records immutable. Appropriate access controls, restricted write permissions, monitoring, and backup or retention mechanisms are required to improve audit integrity. If immutable retention is a requirement, it must be implemented using a suitable additional mechanism.
4. Voice Announcements: Amazon Polly
Amazon Polly converts text into speech, allowing environmental advisories to be presented in an audio format.
For example, a school advisory could communicate whether outdoor activities should be reviewed, whether current observations are stale, or whether administrators should consult official guidance.
A scheduled workflow could prepare announcements before the school day begins. Voice names and language availability must be verified against the current Amazon Polly catalogue before being specified in the deployment.
Generating an audio file is not the same as broadcasting it through a school's public-address (PA) system. Physical playback requires an additional delivery integration and compatible audio equipment.
5. Multilingual Parent Notifications: Amazon SES and Amazon SNS
Multilingual communication can make school advisories more accessible to families with different language preferences.
The proposed language set includes:
- English
- Hindi
- Punjabi
- Marathi
- Bengali
- Tamil
- Telugu
Amazon Simple Email Service (Amazon SES) supports email delivery. Amazon Simple Notification Service (Amazon SNS) provides publish-subscribe messaging and supported notification integrations.
The implementation should identify which service delivers each message type. For example, SES may be used for email circulars, while SNS may support a configured SMS or other notification workflow.
Reliable delivery also requires appropriate recipient permissions, language selection, failure handling, and timestamps. These seven languages and automated delivery channels should be described as implemented only after end-to-end verification.
Mathematical Models and Environmental Calculations
Environmental decision-support systems must distinguish measured data, calculated values, and application-specific heuristics. The following methods illustrate how SaansSchool can translate environmental observations into information that school administrators can interpret.
1. CPCB National Air Quality Index: Piecewise Linear Interpolation
The Central Pollution Control Board (CPCB) National Air Quality Index uses pollutant-specific concentration breakpoints and corresponding AQI values to calculate pollutant sub-indices.
The interpolation formula is:
AQI Sub-Index Formula
AQI Sub-Index = I_low + [(I_high − I_low) / (B_high − B_low)] × (C − B_low)
Where:
- C = Measured pollutant concentration
- B_low = Lower concentration breakpoint for the relevant interval
- B_high = Upper concentration breakpoint for the relevant interval
- I_low = AQI value corresponding to the lower breakpoint
- I_high = AQI value corresponding to the upper breakpoint
Concentration units must match the units used in the applicable breakpoint table. Pollutant-specific averaging periods, data-availability requirements, and boundary conditions must also be handled according to the official methodology.
The CPCB National AQI framework covers eight pollutants: PM2.5, PM10, nitrogen dioxide (NO₂), sulphur dioxide (SO₂), carbon monoxide (CO), ozone (O₃), ammonia (NH₃), and lead (Pb). If the current SaansSchool implementation evaluates only six pollutants, it should be described as a six-pollutant implementation rather than a complete implementation of the eight-pollutant framework. CPCB National AQI report
The overall AQI is generally determined by the highest valid pollutant sub-index when the applicable data requirements are satisfied.
AQI and GRAP are not interchangeable. The Graded Response Action Plan (GRAP) is a policy framework with geographically and administratively applicable criteria. A dominant pollutant sub-index alone does not establish the statutory GRAP stage. SaansSchool should display an official GRAP classification only when the applicable official criteria and supporting information have been verified. Otherwise, its output should be labelled as a school-level advisory.
2. Wind-Direction-Based Fire Screening
Satellite thermal anomaly detections and wind observations can be combined to identify locations that may warrant further investigation.
For a detection at coordinates (lat_f, lon_f) and a school at coordinates (lat_s, lon_s), the workflow can:
- Calculate the great-circle distance between the detection and the school.
- Calculate the initial bearing from the detection to the school.
- Convert the reported wind direction into the direction the wind travels toward.
- Compare the bearing with the wind-travel direction.
- Flag detections that fall within a configurable angular threshold.
For the bearing calculation, let:
- φ₁ = Latitude of the detection in radians
- φ₂ = Latitude of the school in radians
- Δλ = School longitude minus detection longitude, in radians
The initial bearing can be calculated using:
y = sin(Δλ) × cos(φ₂)
x = cos(φ₁) × sin(φ₂) − sin(φ₁) × cos(φ₂) × cos(Δλ)
Bearing = atan2(y, x)
Convert the resulting angle to degrees and normalize it to the range 0°–360°.
If θ is the bearing from the detection to the school and θ_wind is the direction the wind travels toward, the smallest angular difference is:
Angular Difference
Δθ = |((θ − θ_wind + 180°) mod 360°) − 180°|
A screening rule might flag a potential upwind detection when:
Δθ ≤ 30°
The 30° threshold is a configurable heuristic, not a universal atmospheric-science standard. Weather providers often express wind direction as the direction the wind comes from, so the direction convention must be checked before applying this calculation.
A simplified travel-time estimate is:
Estimated Travel Time (hours)
ETA = Distance (km) / Wind Speed (km/h)
This estimate is meaningful only when wind speed is positive and the units are consistent. It assumes constant wind speed and a simplified travel path.
This method does not model atmospheric stability, terrain, plume rise, changing wind fields, or pollutant dispersion. It should therefore be described as potential upwind fire screening, not a validated Gaussian dispersion model or a confirmed prediction of smoke arrival.
3. Classroom Clean Air Delivery Rate (CADR)
Clean-air filtration can be one component of an indoor air-quality strategy. Commercial purifier prices and operating requirements may be challenging for schools with limited budgets, so lower-cost filtration designs are worth evaluating.
Clean Air Delivery Rate (CADR) describes the effective volume of filtered clean air delivered by a device per unit time.
For a rectangular classroom:
Classroom Volume (ft³) = Length (ft) × Width (ft) × Height (ft)
If the desired target is expressed in equivalent air changes per hour (ACH), the required CADR can be estimated as:
Required CADR (CFM)
Required CADR = [Classroom Volume (ft³) × Target ACH] / 60
For example, a target of 5 ACH can be used as an illustrative design assumption when comparing filtration options. It should not be presented as a universal statutory requirement; the appropriate target depends on the classroom, ventilation conditions, applicable guidance, and the purpose of the assessment.
For a filtration device with a measured CADR of 550 CFM:
CADR (m³/h) = 550 × 1.699 ≈ 934 m³/h
The equivalent air changes per hour can then be estimated using:
eACH = CADR (m³/h) / Classroom Volume (m³)
A DIY Corsi–Rosenthal box made from four MERV-13 filters and a compatible box fan may offer a lower-cost filtration option. A proposed budget of ₹2,800 per unit should be treated as a materials estimate, not a guaranteed market price.
Actual performance depends on fan characteristics, filter dimensions, airflow resistance, assembly quality, filter loading, and maintenance. A stated CADR, cost saving, or clearance time should be supported by measurements or clearly documented assumptions. These calculations complement rather than replace appropriate ventilation, indoor-air monitoring, and public-health guidance.
4. CleanAir Commute Routing
SaansSchool can explore how environmental observations and route characteristics might support more informed school commute decisions.
A potential route comparison could consider:
- Air-quality observations: Measurements near route segments, including their timestamps and spatial coverage.
- Traffic exposure: Time spent near congested roads, where reliable traffic information is available.
- Route characteristics: Distance, estimated travel duration, and available alternative routes.
- Weather context: Wind conditions that may influence local pollutant movement.
- Data confidence: Warnings when observations are distant, stale, or unavailable.
A simplified exposure calculation can be expressed as:
Estimated Inhaled Pollutant Mass = Σ (Pollutant Concentration × Minute Ventilation Rate × Segment Duration)
For consistent units, concentration may be expressed in mass per cubic metre, minute ventilation in cubic metres per minute, and segment duration in minutes. The result is an estimated inhaled pollutant mass for the selected segments, subject to the assumptions of the model.
This is not the same as the amount deposited in a person's lungs or a measured health outcome. A defensible comparison requires suitable concentration estimates, route-specific observations, travel durations, ventilation assumptions, and a clear treatment of uncertainty.
A route with less traffic or more tree cover is not automatically cleaner. A claim such as a 52.8% reduction in children's pollutant intake should only be published if it can be reproduced using a documented model and validated input data.
[Insert a screenshot of the actual SaansSchool dashboard showing a school selection, AQI information, data timestamps, and available actions.]
Operating Cost: Designing for the AWS Free Tier
Cost efficiency matters when designing systems for resource-constrained public schools. A serverless architecture can reduce the need for continuously running compute infrastructure, but serverless does not automatically mean free.
Potential AWS components include:
- AWS Lambda: Event-driven ingestion and evaluation. AWS publishes allowances for requests and compute duration, subject to current account and pricing terms.
- Amazon DynamoDB: Storage and database operations. The applicable free allowance depends on table configuration, usage, and current eligibility.
- Amazon API Gateway: HTTP endpoints for frontend and application access.
- Amazon Polly: Speech synthesis, with allowances that vary by voice type and eligibility period.
- Amazon SES and Amazon SNS: Email and notification delivery, subject to their respective pricing, configuration, and account requirements.
For example, AWS Lambda publishes a monthly allowance of one million requests and 400,000 GB-seconds of compute for eligible usage. DynamoDB publishes allowances that include 25 GB of storage and specified provisioned capacity, while API Gateway and Polly have service-specific conditions. These allowances should be checked against the current official pricing pages before deployment. Lambda pricing · DynamoDB pricing · API Gateway pricing · Polly pricing
The actual operating cost depends on request volume, execution duration, storage, database throughput, audio generation, notification volume, data transfer, and account eligibility. Email and SMS costs must be assessed separately, and an application using multiple services may incur charges even if individual components remain within their respective allowances.
Accordingly, $0.00 per month is a target to validate against a defined workload, not a guaranteed operating cost. Before a wider deployment, estimate expected usage with the AWS Pricing Calculator, configure AWS Budgets and billing alerts, and monitor actual consumption.
This approach makes it possible to evaluate the financial feasibility of SaansSchool without promising zero-cost operation across all schools and workloads.
Key Takeaways and Lessons Learned
1. Deterministic Rules Improve Explainability
For school safety decisions, transparent and testable rules make it easier to explain why an advisory was generated. Environmental calculations, data-quality checks, and policy-based decisions should be separated from language generation and notification delivery.
Official regulatory classifications should remain distinct from application-specific recommendations.
2. Infrastructure as Code Improves Reproducibility
AWS SAM provides a structured way to define serverless resources in
template.yaml . When configured, commands such as sam local start-api support local API testing, while SAM deployment workflows can help reproduce infrastructure across environments.The benefit depends on maintaining a working template, testing the defined resources, and documenting the deployment process.
3. Campus-Level Context Can Make Environmental Data More Actionable
Regional AQI readings provide valuable context but may not represent conditions at every school. Combining nearby observations, timestamps, weather information, and transparent decision rules can help administrators interpret environmental conditions more carefully.
The usefulness of a campus-level advisory depends on monitoring coverage, source reliability, data freshness, and validation.
4. Evidence and Uncertainty Matter
Environmental decision-support systems should distinguish between measured observations, calculated estimates, and recommendations. Documenting assumptions, validating calculations, and identifying stale or missing data helps administrators understand both the benefits and limitations of the system.
5. Cost Awareness Must Be Part of the Architecture
A serverless design can avoid unnecessary always-on infrastructure, but service-specific usage and pricing still matter. Measuring resource consumption early helps teams estimate realistic operating costs before expanding to more schools.
Explore SaansSchool
- Live application: https://saans-school.vercel.app/
- Source code: https://github.com/Shubhamver45/SaansSchool-
References
Enjoyed reading this content? Let the author know!
Your likes, comments, shares, and saves help creators reach more builders.
Loading recommendations
Loading article