Streamlit dashboard for Ghana agriculture data
# Ghana Agriculture Analytics Platform
Self-contained data pipeline + FastAPI backend + Streamlit dashboard for Ghana agriculture data.
## Components
- `scripts/` — download (FAOSTAT, World Bank, HDX), clean, merge, and analyse the data.
- `app/` — FastAPI backend (DDD-style self-contained domains) exposing `/api/v1/*` endpoints.
- `dashboard/` — Streamlit multi-page frontend consuming the API.
- `data/raw`, `data/cleaned`, `data/merged`, `output/` — pipeline artifacts.
## Run
Full setup, start/stop and troubleshooting instructions: see **START_SERVERS.md**.
Quick start (Windows) — double-click or run:
```
run_app.bat
```
Standalone (no API required — the dashboard reads the data files directly):
```
streamlit run dashboard/app.py
```
Full stack (API + dashboard):
```
python -m uvicorn app.main:app --host 127.0.0.1 --port 8000 # terminal 1
streamlit run dashboard/app.py # terminal 2
```
The dashboard is self-contained; it only talks to the API when `AGRI_API_URL` is set.
## Deploy to Streamlit Cloud (single app)
The dashboard runs as a single self-contained app. Push this repo to GitHub, then
create an app in Streamlit Cloud pointing at **`dashboard/app.py`**. The data under
`data/cleaned`, `data/merged` and `data/geo` is committed (raw downloads are
gitignored). Optionally set the `AGRI_API_URL` secret to use a remote API instead.
## Reproduce the data
```
python scripts/download_faostat.py
python scripts/download_worldbank.py
python scripts/download_hdx.py
python scripts/clean_data.py
python scripts/merge_data.py
python scripts/analyse_data.py
```
## API overview
`GET /api/v1/analytics/overview` — dataset summary (also `/trends`, `/correlation`, `/search`).
Domain routers: `geographical`, `crop-production`, `commodity-price`, `food-security`,
`livestock`, `climate-agriculture`, `land-use`. Interactive docs at `/docs`.