shrishtiai/shrishti-ai-mobile-backend
0
Mobile Backend (HF2)
This is an isolated backend for the mobile app only.
It loads and runs HazardGuard models locally (same model family used by HF1 backend) and accepts scheduler requests.
Endpoints
GET /healthPOST /api/mobile/predictPOST /api/scheduler/run-mobile-alerts
Security headers
- Mobile prediction endpoint supports optional
X-Mobile-Api-Key. - Scheduler endpoint requires
X-Scheduler-Secret.
Run locally
pip install -r requirements.txt
python app.pyDeploy to Hugging Face Space
Use this folder as a Docker Space source.
Required secrets/environment variables:
SUPABASE_URLSUPABASE_SERVICE_ROLE_KEYSCHEDULER_SECRETHF_TOKEN(for downloading private model repo)MODEL_REPO_ID(defaultprojectgaia/ShrishtiAI-models)MODEL_ROOT_PATH(optional)DATASET_REPO_ID(default example:shrishtiai/shrishtiai-geospatial-data)MOBILE_CLIENT_API_KEY(optional)
Optional tuning:
MOBILE_ALERT_RISK_THRESHOLDMOBILE_ALERT_FORECAST_HOURSMOBILE_ALERT_BATCH_SIZEDATASET_LOCAL_DIR(optional, where HF dataset snapshot is stored)MOBILE_HF_TIMEOUT_SECONDSMOBILE_HF_BACKOFF_SECONDSWEATHER_OPEN_METEO_FALLBACK(defaulttrue)WEATHER_REQUEST_TIMEOUT_SECONDS(default25)NASA_MAX_RETRIES(default3)NASA_RETRY_DELAY_SECONDS(default4)NASA_RATE_LIMIT_PAUSE_SECONDS(default10)
Notes:
- On startup, this service downloads models if missing and initializes local HazardGuard inference.
- If
DATASET_REPO_IDis set, it also snapshotsfinal_lookup_tables/*.tiffrom HF dataset and auto-wiresRASTER_*_PATHenv vars before raster services initialize. POST /api/scheduler/run-mobile-alertsis protected byX-Scheduler-Secret.- This folder is standalone for HF2 deployment (includes vendored HazardGuard runtime modules).
HF Space settings
- Space SDK:
Docker - Exposed port:
7860 - Secrets: set the required variables above in Space settings.
GitHub CI/CD (repo -> HF2)
This repo includes a GitHub Actions workflow at .github/workflows/deploy-hf.yml.
On every push to main, it deploys this repo to your HF2 Space.
Required GitHub repository secrets:
HF_TOKEN: Hugging Face write tokenHF_SPACE_REPO: Space slug, for exampleshrishtiai/ShrishtiAI-mobile-backend
You can also trigger deployment manually with workflow_dispatch.
