AI-Powered Carbon Emission & AQI Intelligence Platform for Bengaluru
Frontend (React + Vite + Tailwind)
└── Zustand Global State
└── Map Tab (Source of Truth for Location)
└── Predict Tab → Insights + Solutions
└── Simulate Tab
└── Forecast Tab
└── Backend API (Flask)
└── predict_final.py (YOUR TRAINED ML MODEL)
Copy predict_final.py and all model files into ./model/ directory:
model/
predict_final.py
*.pkl / *.joblib / *.h5 (your trained model files)
cd backend
pip install -r requirements.txt
# Create .env
cp .env.example .env
# Edit PREDICT_DIR to point to your model directory
python app.py# Root directory
cp .env.example .env
# Set VITE_BACKEND_URL=http://localhost:5000
npm install
npm run dev# Build frontend first
npm run build
# Run with Docker Compose
docker-compose up --build| Method | Endpoint | Description |
|---|---|---|
| POST | /api/predict |
Run ML prediction |
| POST | /api/forecast |
Generate 6-12 hour forecast |
| POST | /api/simulate |
Simulate parameter changes |
| GET | /health |
Health check |
{
"latitude": 12.9716,
"longitude": 77.5946,
"date": "2024-01-15",
"time": "14:30"
}{
"latitude": 12.9716,
"longitude": 77.5946,
"date": "2024-01-15",
"hours": 12
}{
"latitude": 12.9716,
"longitude": 77.5946,
"date": "2024-01-15",
"time": "14:30",
"ndvi_override": 0.6,
"temperature_override": 25.0,
"building_density_override": 30.0
}The bridge (backend/services/model_bridge.py) tries multiple function signatures:
# It will try these in order:
predict(lat, lng, date, time)
predict(latitude=lat, longitude=lng, date=date, time=time)
predict({'latitude': lat, 'longitude': lng, 'date': date, 'time': time})The function name is auto-detected from: predict, run_prediction, predict_aqi, main, get_prediction
Return value is normalized — supports both dict and object returns.
| Tab | Data Source |
|---|---|
| Map | OpenStreetMap + Nominatim geocoding |
| Predict | predict_final.py via /api/predict |
| Insights | Prediction result (NO extra API calls) |
| Simulate | /api/simulate (reruns ML with overrides) |
| Forecast | /api/forecast (reruns ML per hour) |
| Solutions | Rule-based AI engine (frontend only) |