# Shamba AI πΏ
Crop disease detection for Kenyan smallholder farmers.
Upload or photograph a diseased leaf β get a diagnosis, treatment steps,
yield impact estimate, and nearest agro-vet β in English or Swahili.
---
## Quick start (local dev)
```bash
cp .env.example .env # fill in your keys
docker compose up # API + worker + Redis + Postgres + frontend
```
Frontend:
localhost
API docs:
localhost
---
## Project structure
```
shamba-ai/
βββ backend/
β βββ app/
β β βββ api/routes/ # FastAPI routers
β β β βββ diagnosis.py # submit, poll result, feedback
β β β βββ knowledge.py # disease knowledge base
β β βββ core/ # config, database
β β βββ models/ # SQLAlchemy models
β β βββ schemas/ # Pydantic schemas
β β βββ services/
β β β βββ preprocessing.py # CLAHE, unsharp mask, white balance
β β β βββ inference.py # ONNX Runtime + TTA + temperature scaling
β β β βββ gradcam.py # Grad-CAM heatmap generation
β β β βββ knowledge.py # disease KB with Kenyan treatments
β β β βββ storage.py # Cloudflare R2
β β β βββ sms.py # Africa is Talking SMS
β β βββ tasks/
β β βββ celery_app.py # async inference worker
β βββ ml/
β βββ train.py # EfficientNet-B0 + Albumentations
β βββ export_onnx.py # PyTorch β ONNX
β βββ calibrate.py # temperature scaling
βββ frontend/
βββ src/
βββ components/
β βββ capture/ # CaptureScreen with tips + quality check
β βββ diagnosis/ # Result screen + diagnosing screen
β βββ layout/ # AppLayout + header
β βββ ui/ # LanguageToggle
βββ hooks/
β βββ useDiagnosis.ts # full flow: compress β quality check β upload β poll
βββ lib/
β βββ api.ts # API client
β βββ imageUtils.ts # compression + blur detection
β βββ uploadQueue.ts # IndexedDB offline queue
βββ i18 β¦