AI-powered agricultural advisory for smallholder farmers in Zimbabwe
# 🌾 SmartFarmerAI
**AI-powered agricultural advisory for smallholder farmers in Zimbabwe** —
accessible on any phone via USSD, WhatsApp, and web, built for 2G networks
and near-zero data budgets.
Built by Info Impact Solutions (Pvt) Ltd in
partnership with the **Smallholder Agriculture Cluster Program (SACP)**,
funded by IFAD/OPEC and the Government of Zimbabwe.
## The problem
Zimbabwe's ~1.7M smallholder farmers face climate variability with limited
access to timely, localized agricultural extension advice. Most extension
apps assume a smartphone, mobile data, and English literacy — none of which
can be assumed for this audience.
## The approach
A **3-tier hybrid AI pipeline** that answers farmer questions as cheaply and
quickly as possible, escalating only when needed:
```
Farmer question (USSD / WhatsApp / Web)
│
▼
┌─────────────────────────────────────────┐
│ TIER 1: Template Match │ ~44 verified templates,
│ Local TF-IDF vector search, <50ms, free │ sourced from SACP manuals
└───────────────────┬───────────────────────┘
│ no confident match
▼
┌─────────────────────────────────────────┐
│ TIER 2: Decision Engine │ District + season +
│ Context-aware rules, DB-backed │ weather + crop stage
└───────────────────┬───────────────────────┘
│ no matching rule
▼
┌─────────────────────────────────────────┐
│ TIER 3: LLM Fallback │ Hugging Face free tier
│ For genuine edge cases │
└─────────────────────────────────────────┘
```
See `docs/ARCHITECTURE.md` for the full technical
breakdown.
## Quick start
```bash
# 1. Install dependencies
pip install -r requirements.txt
# 2. Configure environment (copy .env.example if present, or create .env with:)
# HUGGINGFACE_API_KEY=... (Tier 3 LLM - free tier)
# SUPABASE_DB_URL=... (Tier 2 Decision Engine - optional but recommended)
# SUPABASE_URL / SUPABASE_ANON_KEY
# 3. Run the gateway
python gateway.py …