Spaces:
Sleeping
Sleeping
File size: 1,889 Bytes
102ebcc de9025d 102ebcc de9025d 102ebcc de9025d | 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 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 | ---
title: Barcli Mesa API
emoji: π‘οΈ
colorFrom: blue
colorTo: red
sdk: docker
pinned: false
short_description: Mesa ABM simulation API for Barcelona climate vulnerability
---
# Barcli Mesa API
FastAPI backend providing Mesa-based agent simulation for the [Barcli](https://barcli.vercel.app) frontend.
## Endpoints
| Method | Path | Description |
|--------|------|-------------|
| `GET` | `/health` | Liveness check |
| `POST` | `/simulate/single` | Single-agent A\* pathfinding with climate weighting |
| `POST` | `/simulate/multi` | 20-agent shelter-seeking with 4 personas |
## POST /simulate/single
```json
{
"start": [-2.1734, 41.3851],
"end": [-2.1700, 41.3900],
"climate_weight": 0.5,
"baseline_index": null,
"policy_index": null
}
```
Returns `baseline_path`, `policy_path` (arrays of `[lng, lat]`) and `baseline_profile`, `policy_profile` (vulnerability scores 0β1 per node).
## POST /simulate/multi
```json
{
"shelter_coord": [-2.1720, 41.3870],
"baseline_index": null,
"policy_index": null,
"seed": 42
}
```
Returns per-frame `baseline_snapshots`/`policy_snapshots` and `persona_breakdown` with arrived counts per persona.
## Data files required
Place these in the `data/` directory (same files as the frontend's `public/data/`):
- `data/climate_isochrone.geojson` β road network (LineString features)
- `data/data.geojson` β climate vulnerability points (heat, SPEI, urban_health fields)
- `data/climate_shelters.geojson` β shelter locations (Point features)
## Files
```
βββ app.py FastAPI app + graph loading + routes
βββ mesa_single.py Mesa single-agent A* model
βββ mesa_multi.py Mesa multi-agent shelter model
βββ requirements.txt
βββ Dockerfile
βββ data/
βββ climate_isochrone.geojson
βββ data.geojson
βββ climate_shelters.geojson
```
|