An end-to-end environmental intelligence microservice and reactive decision-support platform built with FastAPI and Streamlit. The system ingests multi-pollutant sensor telemetry, executes official CPCB / NAAQS piecewise linear interpolation algorithms to calculate Air Quality Index (AQI) sub-indices, attributes dominant toxic drivers, and serves dynamic health advisories via a validated REST API.
flowchart TD
subgraph UI ["Frontend: Streamlit Reactive Dashboard (:8501)"]
A1[Radial Severity Gauge & Dynamic Theming]
A2[Telemetry Sliders & What-If Simulator]
A3[Sub-Index Comparative Visualizer]
end
subgraph API ["Backend: FastAPI Microservice (:8000)"]
B1[Pydantic v2 Schema Validation]
B2[CPCB / NAAQS Piecewise Linear Engine]
B3[Dominant Toxic Driver Attribution]
B4[OpenAPI / Swagger Documentation]
end
UI -->|HTTP POST JSON Payload| API
API -->|Validated AQI & Health Advisory| UI
For any given pollutant concentration
Where:
-
$C_p$ : Measured concentration of pollutant$p$ . -
$B_{\text{hi}}, B_{\text{lo}}$ : Breakpoint concentration bracket containing$C_p$ . -
$I_{\text{hi}}, I_{\text{lo}}$ : Sub-index values corresponding to$B_{\text{hi}}$ and$B_{\text{lo}}$ .
The overall Air Quality Index represents the maximum sub-index across all monitored chemical agents:
| Category | AQI Range | PM2.5 ( |
PM10 ( |
|
|
CO ( |
|---|---|---|---|---|---|---|
| Good | 0 – 50 | 0 – 30 | 0 – 50 | 0 – 40 | 0 – 40 | 0 – 1.0 |
| Satisfactory | 51 – 100 | 31 – 60 | 51 – 100 | 41 – 80 | 41 – 80 | 1.1 – 2.0 |
| Moderate | 101 – 200 | 61 – 90 | 101 – 250 | 81 – 180 | 81 – 380 | 2.1 – 10.0 |
| Poor | 201 – 300 | 91 – 120 | 251 – 350 | 181 – 280 | 381 – 800 | 10.1 – 17.0 |
| Very Poor | 301 – 400 | 121 – 250 | 351 – 430 | 281 – 400 | 801 – 1600 | 17.1 – 34.0 |
| Severe | 401 – 500 | 250+ | 430+ | 400+ | 1600+ | 34.0+ |
- Route:
POST /api/v1/aqi/calculate - Request Payload:
{
"pm25": 54.7,
"pm10": 84.7,
"no2": 42.4,
"so2": 11.5,
"co": 2.18,
"nox": 91.8,
"vocs": 112.2,
"co2": 439.3,
"temperature": 30.5
}- Response Payload (HTTP 200 OK):
{
"overall_aqi": 103.1,
"category": "Moderate",
"dominant_pollutant": "CO",
"sub_indices": {
"PM2.5": 91.2,
"PM10": 84.7,
"NO2": 53.0,
"SO2": 14.4,
"CO": 103.1
},
"color_hex": "#e67e22",
"health_advisory": "Breathing discomfort to people with lung, asthma, and heart diseases.",
"actionable_guidance": "Consider reducing prolonged outdoor exertion."
}| File / Directory | Purpose |
|---|---|
air_quality_dataset.csv |
Multi-pollutant sensor telemetry dataset |
api.py |
FastAPI REST microservice & Pydantic validation schemas |
app.py |
Streamlit reactive UI with Plotly visual components |
dashboard_preview.png |
UI screenshot: Real-time gauge & sub-index breakdown |
swagger_docs_preview.png |
API screenshot: OpenAPI /docs test harness |
requirements.txt |
Project dependencies |
README.md |
Architecture, mathematical formulations & documentation |
git clone [https://github.com/AshutoshTembhekar/air-quality-intelligence-engine.git](https://github.com/AshutoshTembhekar/air-quality-intelligence-engine.git)
cd air-quality-intelligence-enginepy -3.12 -m pip install -r requirements.txtpy -3.12 -m uvicorn api:app --reload --port 8000- Interactive Swagger API documentation:
http://127.0.0.1:8000/docs - Raw JSON schema:
http://127.0.0.1:8000/openapi.json
In a separate terminal instance:
py -3.12 -m streamlit run app.py- Access the interactive dashboard:
http://localhost:8501

