How we built it

FarmDoc Lite is a React + TypeScript + Vite web app on Firebase, with all AI running through Firebase AI Logic.

  • Hybrid inference: English requests use PREFER_ON_DEVICE, so Chrome's built-in Gemini Nano handles them when the device supports it, with automatic fallback to cloud Gemini (gemini-3.5-flash-lite). When the device is offline, the app uses ONLY_ON_DEVICE. Hausa and Pidgin use ONLY_IN_CLOUD, because the on-device model supports only a few languages. Every result shows a badge saying whether it ran on-device or in the cloud.
  • One schema for both paths: a single JSON schema drives on-device (responseConstraint) and cloud (responseSchema) output, so the UI always receives the same structure: photo clarity, what was seen, up to three causes with confidence, urgency, steps for today, and when to see a professional.
  • Deterministic safety layer in code: the AI explains, but plain rules decide how cautious to be. Urgency can only be raised, never lowered, by poultry warning signs in the farmer's note or by "most affected". Any step that looks like a dose or a named drug or chemical is replaced with "ask a vet or extension officer". An unclear photo, low confidence or high urgency always shows a "see a vet or extension officer" banner.
  • Built for weak networks: photos are resized to 768px JPEG in the browser before upload, which keeps requests small on 3G and fits the on-device model's input limit.
  • Security: Firebase App Check with Fraud Defense (reCAPTCHA Enterprise) protects every AI call. The app is hosted on Firebase Hosting, and the code is open source under the MIT license.

Challenges we ran into

  • App Check enforcement: Firebase AI Logic now requires App Check, and debug-token setup for local development took real debugging. The console also deprecated reCAPTCHA Classic, so I moved to Fraud Defense.
  • An SDK detail that cost time: passing custom cloud parameters in hybrid mode removed the SDK's default model, which produced a "must provide a model name" error until I set the model explicitly.
  • On-device availability: Chrome's on-device model reported as unavailable on my development laptop, so the results I tested ran through the cloud path. I built the on-device and offline routing but could not verify it on my own hardware. On-device inference needs a supported desktop Chrome device.
  • Phone photo picking: my first version sent phones straight to the camera, and a later version failed to read gallery photos. I fixed both by separating camera and gallery buttons and adding a fallback image decoder.
  • Connectivity: I built this from Kaltungo on a slow, unstable connection, with dropped installs and long waits. That is also why the app is designed for weak networks.

Accomplishments that we're proud of

  • A complete, deployed app that goes from a photo to a clear, plain-language action plan in one screen.
  • A safety design that does not trust the AI alone. Fixed rules cannot be talked out of escalating a dangerous poultry case, and they strip dosing advice.
  • A genuine hybrid architecture with three routing modes, one shared schema, and honest labelling of where each answer came from.
  • Hausa and Pidgin output from the first version, with the fixed safety text translated.
  • Built solo within the hackathon window, while dealing with weak internet in a small town.

What we learned

  • Hybrid AI is mostly a design question about failure: what runs where, what happens when the device cannot run the model, and how to tell the user honestly which path answered.
  • For high-stakes advice such as animal health, the useful part is not the AI's cleverness but the guardrails around it. Clear urgency levels and a "see a professional" rule matter more than long explanations.
  • Production-grade App Check and API setup are a real part of shipping AI apps, not an afterthought.
  • Testing on the hardware your users have matters. Not every device can run on-device models, so a fallback path is essential, not optional.

What's next for FarmDoc Lite

  • Have native Hausa and Pidgin speakers review the translated safety text and the AI's wording.
  • Add a local directory of vets, extension officers and agro-dealers, starting with Gombe State.
  • Pilot with farmers and the poultry depot in Kaltungo, and measure whether the triage steps help and whether the urgency levels feel right.
  • Cache first-aid guides offline, so basic guidance works even without any AI model.
  • Test the on-device path on supported devices and publish what we find.

Built With

Share this project:

Updates

Submission history