Humanitarian strategy sandbox: crisis data, fragility simulation (TTC, Equity Shift), Success Twins (semantic project matching), and contrarian memos.
Stack: Backend: FastAPI (uvicorn). Frontend: Vite + React.
-
Build Parquet data (from repo root):
python scripts/preprocess.py
Produces
backend/data/crises.parquetandbackend/data/projects.parquet.Success Twin project data: The app loads projects from
data/projects.parquet. If you see "Not enough projects in crisis country MLI" (or BFA/NER/TCD), seed at least 2 projects per epicenter:python -m backend.scripts.seed_epicenter_projects
This adds synthetic MLI, BFA, NER, TCD projects to
data/projects.parquetso "Find Success Twin" works for every epicenter. -
Backend dependencies:
pip install -r backend/requirements.txt
-
Frontend dependencies:
cd frontend && pnpm install
Or:
npm installif you don’t use pnpm.
From repo root:
uvicorn backend.main:app --reload --host 0.0.0.0 --port 8000cd frontend && pnpm devOr: npm run dev. App: http://localhost:5173 (or next free port).
Optional: set VITE_API_BASE_URL=http://localhost:8000 in frontend/.env.local (defaults to that if unset).
Single one-command smoketest (run from repo root):
python run_smoketest.pyPrints a dict of *_ok flags and a final line: All *_ok flags True: True or False. Exit code 0 only if all flags are True. Use before hacking, after pulling, and before demos.
Lightweight sanity check of HTTP endpoints (no server needed; uses FastAPI TestClient):
python backend/check_api_contract.pyVerifies GET /crises/, POST /simulate/, GET /twins/PRJ001, POST /memos/. Exits 0 on PASS, 1 on FAIL.
The “Similar Projects (VectorAI)” feature uses the Actian VectorAI DB beta for nearest-neighbor search over project embeddings. Without it, the backend falls back to in-memory search from parquet.
Clone and start the Actian VectorAI DB (gRPC default localhost:50051):
git clone https://github.com/hackmamba-io/actian-vectorAI-db-beta
cd actian-vectorAI-db-beta && docker compose up -dInstall the actiancortex wheel from the Actian repo (see that repo’s README for the latest install steps). Example:
pip install path/to/actian-vectorAI-db-beta/wheels/actiancortex-*.whlSet in .env or .env.local (or export before running backend/ingestion):
| Variable | Example | Description |
|---|---|---|
ACTIAN_VECTORAI_CONNECTION_STRING |
localhost:50051 |
VectorAI gRPC host:port |
ACTIAN_PROJECTS_COLLECTION |
projects |
Collection name for project embeddings |
ACTIAN_PROJECTS_DIMENSION |
5 |
(Optional) Embedding dimension; default 5 to match DataML |
Ensure project embeddings exist, then run the ingestion script (from repo root):
# Build project embeddings (if not already done)
python -m dataml.src.embeddings # or your DataML pipeline
# Ingest into VectorAI DB
python -m backend.scripts.ingest_vectorai_projectsThis reads dataml/data/processed/project_embeddings.parquet and batch-upserts into the Actian collection. Then “Find similar projects” in the app uses the real vector DB.
- Start – Open the app. Left panel: “Configure Scenario.”
- Pick a crisis – Choose one from the dropdown (e.g. “GHO Estimates (SYR 2024)”).
- Set funding – Adjust Health Δ and WASH Δ (e.g. -1M Health, +0.5M WASH).
- Set shocks – Optionally change Inflation %, Drought, Conflict level.
- Run scenario – Click “Run Scenario.” Center “Impact” panel shows baseline vs scenario TTC and Equity Shift.
- Find Success Twin – Right panel: click “Find Success Twin” for sample project PRJ001.
- Generate memo – Click “Generate Memo.” Read title, body, and key risks.
- Vary inputs – Change funding or shocks, run again, compare impact and memo.