Feature-complete backend repository for the hackathon.
app/-> active FastAPI backendapi/endpointscore/database models + schedulertriggers/weather + fraud trigger logicservices/pricing, ML+SHAP prediction, PDF generation, model training utilitytests/contract tests
docs/API_CONTRACT.md-> frontend/backend integration contractdocs/BACKEND_RUNBOOK.md-> backend owner runbook + curl payloads + error handlingmain.py-> root ASGI entrypoint (app.main:app)requirements.txt-> single dependency source
python3 -m venv venv
source venv/bin/activate
pip install -r requirements.txt
uvicorn main:app --reload --port 8000- ML status:
GET /api/premium/model-status - Premium prediction (ML-first with fallback):
POST /api/premium/predict - Policy PDF download:
GET /api/policies/{rider_id}/current/document - Optional local model training:
python app/services/train_model.py - Forecast:
GET /api/forecast/{zone}(Prophet-first, fallback when Prophet unavailable) - Model monitoring summary:
GET /api/admin/model-monitoring - Resolve actual outcome for a prediction:
POST /api/admin/model-monitoring/resolve - Retrain all models immediately:
POST /api/admin/model-retrain
POST /api/demo/bootstrap: demo setupPOST /api/triggers/simulate: claim simulationGET /api/claims/{rider_id}: rider claims historyGET /api/policies/{rider_id}/current: policy statusPOST /api/policy/{id}/upgrade: Enhanced Coverage upsell (Phase 3)GET /api/rider/{id}/calendar: Earnings timeline (Phase 3)GET /api/admin/metrics: Platform health KPIs (Phase 3)GET /api/admin/claims_map: Geolocation visualization (Phase 3)GET /api/admin/fraud_flags: Suspicious claim review (Phase 3)GET /api/admin/predictions: Global risk forecasting (Phase 3)
python3 -m unittest app.tests.test_phase2_contracts -v
python3 -m unittest app.tests.test_api_endpoints -vThis repo includes render.yaml and Procfile for Render deployment.
- Create a Blueprint service in Render and point it to this repository.
- Set service root to
protoryde-backendif deploying from the umbrella repo. - Render provisions
protoryde-dbfromrender.yamland injectsDATABASE_URL. - Keep
ENABLE_SCHEDULER=falsein production unless you intentionally want live polling.
- Run preflight locally:
./scripts/render_preflight.sh
- Deploy from Render Blueprint.
- Run live smoke checks against Render URL:
BACKEND_URL=https://<your-service>.onrender.com ./scripts/render_live_smoke.sh
See full guide: docs/RENDER_FIRST_DEPLOY.md
- The app normalizes
postgres://topostgresql://automatically for SQLAlchemy compatibility. model.pklis optional; premium prediction falls back to the rule engine when the model is absent.- Scheduled retraining is optional and controlled by
ENABLE_ML_RETRAINandML_RETRAIN_INTERVAL_HOURS.