Inspiration

Millions of smallholder farmers face devastating crop losses every year due to late or inaccurate detection of pests and plant diseases. When a crop gets sick, farmers often lack immediate access to expert agronomists and struggle to organize a structured treatment regimen. We wanted to bridge this gap by bringing an "expert agronomist" directly to the farmer's pocket. Our goal was to go beyond a simple chatbot and build an Agentic AI—a system that doesn't just give advice, but actually takes action to help manage the farm.

What it does

AgriGuard is a smart agricultural assistant built for action. It operates in three core steps:

  1. Multimodal Diagnosis: Users upload an image of an affected leaf. Using Gemini's Vision capabilities, the app instantly identifies the disease, assesses the severity, and explains the root cause.
  2. Agentic Workflow (Actionable Scheduling): Instead of just giving a wall of text, AgriGuard translates the diagnosis into a concrete treatment plan. With a single click, the app uses OAuth 2.0 to sync directly with the user's Google Calendar, creating scheduled reminders for tasks like manual pest checking or biopesticide application.
  3. Interactive Agronomist (Multi-turn Chat): Farming is contextual. Below the diagnosis, a chat interface allows farmers to ask follow-up questions (e.g., "Where can I buy this fertilizer?" or "Is it safe to spray if it rains tomorrow?"), utilizing Gemini's context window for continuous, intelligent conversation.

How we built it

  • Backend: Built with Python and Flask.
  • AI Engine: We utilized Google Gemini Flash & Lite models via the google-genai SDK. We leveraged its Multimodal/Vision capabilities for image analysis and structured prompting to ensure the AI generates clear, safe, and logical agricultural advice.
  • Integrations: We implemented Google Cloud OAuth 2.0 and the Google Calendar API to allow seamless and secure event creation on the user's personal calendar.
  • Frontend: HTML/CSS/JavaScript with a responsive, intuitive interface tailored for easy use in the field.

Challenges we ran into

  • Agentic Integration: Connecting the AI's logic to a real-world application like Google Calendar was challenging. We had to navigate Google Cloud Console setups, configure OAuth consent screens for external users, and resolve URI redirect mismatch errors to ensure a secure authentication flow.
  • API Rate Limits & Reliability: During testing, we encountered 429 RESOURCE_EXHAUSTED limits. We overcame this by engineering a smart Model Fallback System in our backend. If the primary Gemini model hits a rate limit, the application automatically catches the error and seamlessly falls back to high-quota models (like Gemini Flash Lite), ensuring zero downtime for the user.

Accomplishments that we're proud of

We are incredibly proud of making the leap from a "Generative AI" to an "Agentic AI." Successfully authenticating user sessions and seeing Gemini's recommended tasks magically appear in a real Google Calendar proved that AI can be a proactive tool, rather than just a reactive search engine.

What we learned

  • Advanced Prompting: How to instruct Gemini to maintain a specific persona (a professional yet accessible agronomist) and structure its output logically.
  • Seamless Fallbacks: Implementing try-except loops to manage API quotas gracefully.
  • Cloud Architecture: A deeper understanding of Google Cloud's security protocols, OAuth flows, and credentials.json management.

What's next for AgriGuard

  • Hyper-Local Translation: Implementing localized language support to make the app accessible to older farmers in remote regions.
  • Native Video Analysis: Utilizing Gemini's massive context window to process short videos of an entire field, rather than just single images.
  • Weather API Integration: Passing real-time location weather data to Gemini via Function Calling to prevent scheduling fertilizer applications right before heavy rainfall.

Built With

Share this project:

Updates