AgriSense Rwanda - AI-powered agricultural intelligence platform
# AgriSense Rwanda — Early Warning System for Crop Water Stress
A FastAPI microservice that detects crop water stress in Rwanda's Gatsibo district using satellite imagery (NDVI, evapotranspiration), rainfall data, a Neo4j knowledge graph, rule-based alert logic, and LLM-powered natural language explanations.
## Architecture
```
┌──────────┐ ┌──────────────────┐ ┌────────────┐
│ Frontend │────▶│ FastAPI Gateway │────▶│ Neo4j KG │
│ (client) │◀────│ /api/v1/* │◀────│ │
└──────────┘ └──────┬───────────┘ └────────────┘
│
┌───────────┼───────────┐
│ │ │
┌──────▼──┐ ┌─────▼────┐ ┌───▼──────┐
│ Data │ │ Alert │ │ LLM │
│ Ingest │ │ Engine │ │ Layer │
└────┬────┘ └──────────┘ └──────────┘
│
┌───────┼────────┬──────────┐
│ │ │ │
DEA CHIRPS WaPOR Agri Survey
```
## Tech Stack
- **API**: FastAPI + Uvicorn
- **ORM**: SQLAlchemy + Alembic (PostgreSQL + PostGIS)
- **Knowledge Graph**: Neo4j (Community Edition)
- **Data Processing**: xarray, rasterio, geopandas
- **Satellite Data**: Digital Earth Africa, CHIRPS, FAO WaPOR
- **LLM**: Configurable (OpenAI / Anthropic Claude)
- **Caching**: Redis
- **Containerization**: Docker + Docker Compose
- **Task Scheduling**: APScheduler
## Quick Start
```bash
# Clone and configure
cp .env.example .env
# Edit .env with your API keys
# Start all services
docker-compose up -d
# Run database migrations
docker-compose exec api alembic upgrade head
# Populate knowledge graph with base data
docker-compose exec api python -m scripts.seed_knowledge_graph
# Trigger initial data ingestion
docker-compose exec api python -m scripts.ingest_data
```
## API Endpoints
| Method | Endpoint | Description |
|--------|----------|-------------|
| GET | `/api/v1/health` | Service health check |
| GET | `/api/v1/districts` | List pilot districts |
| GET | `/api/v1/districts/{id}` | District detail with crops |
| GET | `/api/v1/crops` | List moni …