AI-powered farm productivity and carbon-credit app for smallholder farmers in Uganda
# FarmSight AI
An Android app helping smallholder farmers in Uganda decide where to plant trees for
better crop yield and carbon credits, and helping NGOs monitor farms at scale.
Built with Kotlin, Jetpack Compose, Material 3, MVVM, Room, Coroutines/Flow, and a
lightweight manual DI container (no Hilt -- kept simple and easy to trace).
## Honest status: what's real vs. mocked
This matters, especially for anything touching carbon-credit or yield claims.
**Fully real and functional:**
- Offline-first local database (Room) -- the whole app works with no internet
- Farm boundary drawing on a live OpenStreetMap map (osmdroid), plus GPS point capture
- Polygon area calculation (shoelace formula)
- Rule-based recommendation engine -- transparent, auditable rules (see
`RuleBasedRecommendationEngine.kt`'s doc comment for the exact formulas)
- One-page PDF report generation (Android's built-in `PdfDocument`, no external library)
- English / Runyankore-Rukiga language toggle, including live translation of the
dynamically-generated recommendation text via the real omuhingi.lovable.app API,
with offline caching (Room) so a translation seen once works offline forever after
- WorkManager-based offline sync queue (`needsSync` flags + connectivity-constrained
background worker)
- **Real on-device crop health analysis from a farmer-taken photo** (`OpenCvHealthAnalyzer.kt`,
using the real `org.opencv:opencv` library). Tap any zone on the Health Map to take
a photo of that spot; OpenCV computes an Excess Green Index (a standard RGB-only
vegetation index -- see that file's doc comment) and replaces the zone's mock
estimate with a real score. This exists because satellite NDVI is ~10m/pixel, which
is too coarse to say much about a typical 0.5-2 hectare smallholder plot -- a photo
from where the farmer is standing is a much better-fitted signal for this use case.
A zone shows a camera icon until it's been photographed, and a checkmark after --
the app never hides which zones are stil …