A full-stack Air Quality Index (AQI) forecasting application with a FastAPI backend (Prophet-based 30-day forecasts and on-demand inference) and a React frontend featuring maps and charts for interactive exploration.
- Forecasting API (FastAPI): endpoints for point inference and 30-day forecasts (Prophet).
- Model loader abstraction: simple hot-swap of trained models via a loader utility.
- React UI: calendar picker, line charts, city search, and a live clock.
- Maps: Leaflet map with marker + popup; recenters when a new city is selected.
- Charts: Recharts line chart for “30-Day AQI Forecast.”
- UI polish: lucide-react icons, framer-motion animations.
AQI_Forecasting/
├── backend/ # FastAPI app, model loading, prediction/forecast routes
├── frontend/ # React app (Leaflet, Recharts, framer-motion, lucide-react)
├── .gitignore
└── https://github.com/jackso1328/AQI_Forecasting/raw/refs/heads/main/frontend/node_modules/d3-interpolate/src/transform/Forecasting-AQ-v1.1.zip
Backend
- Python, FastAPI, Uvicorn
- Prophet (time-series forecasting)
- Pydantic for request schemas
- Requests (external data fetch, if needed)
Frontend
- React (hooks)
- Leaflet (map)
- Recharts (charts)
- framer-motion (animations)
- lucide-react (icons)
- react-calendar (date UI)
Base URL (dev): http://127.0.0.1:8000
GET / → { "status": "ok" }
POST /predict
{
"PM25": 42.0,
"PM10": 80.0,
"NO2": 18.0,
"NO": 0.0,
"NH3": 0.0
}GET /forecast?city=Chennai
Optional: lat, lon, start_date (ISO), horizon_days (default 30)
Response:
{
"city": "Chennai",
"horizon_days": 30,
"series": [
{"date": "2025-09-26", "aqi": 102.1},
...
]
}- Trained Prophet model on historical AQI data.
- Saved artifact loaded at API start via
https://github.com/jackso1328/AQI_Forecasting/raw/refs/heads/main/frontend/node_modules/d3-interpolate/src/transform/Forecasting-AQ-v1.1.zip(). - Forecast pipeline:
- Build future dataframe for 30 days.
- Prophet
predict→ extractyhatas AQI. - Return compact series for the frontend chart.
- City search triggers geocoding → map re-centers.
- 30-Day AQI Forecast line chart renders
/forecastdata. - Calendar lets users pick dates.
- Live 24h clock updates every second.
cd backend
python -m venv .venv
source .venv/bin/activate # Windows: .venv\Scripts\activate
pip install -r https://github.com/jackso1328/AQI_Forecasting/raw/refs/heads/main/frontend/node_modules/d3-interpolate/src/transform/Forecasting-AQ-v1.1.zip
uvicorn main:app --reloadcd frontend
npm install
npm run dev- Update
API_BASEin code/config if your backend runs elsewhere.
Backend:
https://github.com/jackso1328/AQI_Forecasting/raw/refs/heads/main/frontend/node_modules/d3-interpolate/src/transform/Forecasting-AQ-v1.1.zip
Frontend:
VITE_API_BASE=http://127.0.0.1:8000
curl http://127.0.0.1:8000/
curl -X POST http://127.0.0.1:8000/predict \
-H "Content-Type: application/json" \
-d '{"PM25":42,"PM10":80,"NO2":18,"NO":0,"NH3":0}'- CORS is enabled for dev.
- Type-safe request validation via Pydantic.
- Map recentering works when searching new city.
- Consider adding Prophet confidence bands (
yhat_lower/upper) to chart.
- Add unit tests for forecasting pipeline.
- Add city autocomplete with debounce.
- Persist recent searches in localStorage.
- Dockerize backend & frontend.
PRs and issues welcome. Please open an issue to discuss major changes first.
Add a LICENSE file (MIT recommended) at the repo root.