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 β¦