# AgriSmart Kenya
React Native (Expo) + Supabase mobile app for crop disease diagnosis, market
prices, and weather advisories for smallholder farmers in Kenya. Built as a
bilingual (English/Swahili), mobile-first tool for farmers who are often on
mid-range or older phones and unreliable rural connections, not just a demo
for ideal conditions.
## Features
- **AI-assisted crop disease diagnosis.** A farmer photographs or picks a
leaf photo, selects the crop, and the photo is sent to Google's Gemini
vision model (`src/lib/geminiVision.js`) with a prompt written specifically
for smallholder Kenyan farming. The response is parsed into a disease name,
scientific name, confidence score, plain-language explanation, and a
numbered treatment plan (`src/lib/geminiParse.js`).
- **Photo optimisation for low-end phones and slow connections.** Before a
photo goes anywhere, `src/lib/imageUtils.js` resizes it to a 1024px long
edge and re-encodes it as 70%-quality JPEG. Raw camera output on a modern
phone can be several megabytes; on a rural or metered connection that turns
a single diagnosis into a multi-minute wait or a failed upload. This step
keeps both the Gemini call and the Storage upload small and fast, with no
visible loss of detail for disease identification, and shows a
"Processing photo…" state so the app doesn't feel frozen while it works.
This is a standardisation/compression step, not photo enhancement, it
won't sharpen a badly blurred or badly lit photo, only make whatever photo
is taken quick and reliable to send.
- **Disease matching against a structured table.** Gemini returns free text,
which on its own can't be reliably queried or joined. `src/lib/diseaseMatch.js`
fuzzy-matches that text against the app's own `diseases` table so a
diagnosis links to a real `disease_id` where possible, while still keeping
Gemini's raw text in `ai_disease_name` if no match is found.
- **A real "this isn't a plant" path.** If the photo clearly isn't a leaf,
the app skips the Stor …