This starter matches your 4-week plan and gives you a working FastAPI backend + ML training scaffold.
# 1) Create env & install deps
python -m venv .venv && source .venv/bin/activate # Windows: .venv\Scripts\activate
pip install -r requirements.txt
# 2) (Optional) Put your CSV into ./data/crop_data.csv and edit training/train.py feature names
# 3) Train model (writes ./model artifacts)
python training/train.py
# 4) Run API (uses ./model artifacts + OpenWeatherMap)
uvicorn app.main:app --host 0.0.0.0 --port 8000
# 5) Test
curl -X POST http://localhost:8000/recommend -H "Content-Type: application/json" -d @sample_request.jsonCopy .env.example to .env and set your OpenWeatherMap key:
OPENWEATHER_API_KEY=your_key_here
training/train.py– edit feature names to fit your dataset, trains an XGBoost Classifier, saves model and encoders.app/main.py– FastAPI app exposing/health,/recommend,/weather,/climate-alerts.app/utils.py– weather fetching + caching with TTL.app/config.py– env + settings.requirements.txt– dependencies.sample_request.json– example request body.Dockerfile,Procfile– deployment helpers (Render/Heroku compatible).