File size: 1,940 Bytes
221080b | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 | ---
title: DataX Outlet Intelligence API
emoji: π
colorFrom: blue
colorTo: indigo
sdk: docker
app_port: 7860
pinned: false
license: apache-2.0
short_description: Outlet potential + SHAP + Gemini XAI backend
---
# DataX Outlet Intelligence β Backend (Hugging Face Space)
FastAPI service that exposes the gold-layer artifacts of the
DataStorm v7.0 pipeline through 18 JSON endpoints, including an
on-demand Gemini 2.5 Flash narrative for any outlet.
This Space is **automatically rebuilt** on every push to the `main`
branch of the source GitHub repo via a GitHub Actions workflow.
| | |
|---|---|
| Source | <https://github.com/AdithaBuwaneka/DataX-DataStorm-7.0> |
| Workflow | `.github/workflows/deploy-backend-to-hf.yml` |
| Health probe | `GET /health` |
| OpenAPI / Swagger | `GET /docs` |
## Required Space secret
| Name | Where to set | Purpose |
|---|---|---|
| `GEMINI_API_KEY` | Settings β Variables and secrets β New secret | Enables the `/api/xai/explain/{id}` Gemini narrative endpoint |
Without `GEMINI_API_KEY` the rest of the API still works; only the
narrative endpoint returns HTTP 503.
## Endpoints (summary)
| Endpoint | Returns |
|---|---|
| `GET /health` | Liveness probe + data-loaded confirmation |
| `GET /api/summary` | Dashboard KPI tiles |
| `GET /api/outlets` | Paginated outlet list |
| `GET /api/outlets/{id}` | Drill-down + SHAP + counterfactual + actions + cooler ROI |
| `POST /api/xai/explain/{id}` | Gemini narrative |
| `GET /api/budget/*` | LKR 5M Western Province allocation |
| `GET /api/cooler-roi/*` | Top-100 cooler deployment |
| `GET /api/dormancy/*` | At-risk outlets |
| `GET /api/scorecard` | 10-distributor benchmark |
| `GET /api/territories` | HDBSCAN clusters |
| `GET /api/forensics` | Beyond-DQ forensic findings |
| `GET /api/shap/global` | Global mean \|SHAP\| ranking |
Full reference at <https://huggingface.co/spaces/adithaf7/datax-outlet-intelligence-api/docs>.
|