🌟 Inspiration
The inspiration for AgriSustain stemmed from the critical challenges faced by smallholder farmers in Kenya, who often lack access to timely, precise agronomic information. While valuable data exists on soil health and climate, transforming that information into profitable, localized decisions—from which crop to plant to how to manage a sudden pest outbreak—remains a major barrier to food security and economic growth. We set out to build a powerful, accessible tool to bridge this gap.
🎯 What it does
AgriSustain acts as an AI-powered agronomy consultant delivered instantly via a mobile-friendly web application. It performs three primary functions:
- Crop Recommendation: Analyzes real-time soil data (pH, clay, organic carbon) and current weather conditions to recommend the 3 best, most profitable crops suitable for the farm's exact context in Kenya.
- Disease Diagnosis: Provides instant analysis of plant health by allowing the user to upload an image of a leaf. It identifies the disease or pest and delivers a structured treatment and prevention plan.
- Community Alerts: Leverages a Community Map to allow farmers to report new pest sightings, generating real-time alerts to prevent widespread crop damage across local farming regions.
🏗️ How we built it
AgriSustain is a Next.js application powered by the Google Gemini API (@google/genai).
- Data Fusion: We integrated external, real-time soil chemistry data from the ISRIC World Soil Information API to feed into the Gemini prompt context.
- Structured Output (Crop Recommendation): We use the Gemini 2.5 Flash model with a
responseSchemato enforce a clean JSON structure, ensuring recommendations (including planting tips and confidence levels) are reliable and machine-readable. - Multimodal Analysis (Diagnosis): The Gemini 2.5 Flash model analyzes image data (Base64 encoded) alongside a system prompt acting as an expert Plant Pathologist, again using structured output for the diagnosis.
- Reliability: We utilized a low
temperaturefor diagnostic tasks to ensure consistent, predictable advice.
🛑 Challenges we ran into
- Integrating Diverse Data: Successfully merging external, non-Gemini data (like the ISRIC soil API's complex nested JSON structure) with the AI prompt context required precise data mapping and robust error handling when the external API failed.
- Ensuring Output Reliability: Initial attempts to get clean JSON failed due to models occasionally wrapping output in markdown blocks (e.g., ```json). This was successfully solved by migrating to the latest
@google/genaiSDK and leveraging the powerfulresponseSchemafeature, which guarantees a perfectly parsable JSON response.
✅ Accomplishments that we're proud of
We are most proud of building a solution that provides expert-level advice at scale, making advanced agronomy accessible to anyone with a smartphone.
- Achieving Data-Driven Reliability: Successfully engineering the Gemini API endpoints to produce 100% reliable, structured JSON output for both text-based recommendations and complex image-based diagnosis.
- Creating a Localized Tool: Integrating the community-based features (Pest Alert and Community Map) to foster localized knowledge sharing, making the tool immediately relevant and trustworthy for the Kenyan context.
🧠 What we learned
We learned the critical importance of engineering not just the prompt itself, but the expected output structure. This project showed us how to transform a general-purpose LLM into a deterministic, reliable API endpoint by forcing JSON output with responseSchema, turning AI reasoning into a predictable data source.
🚀 What's next for AgriSustain
- Expanded Crop Modeling: Integrate more detailed regional climate models to offer advice for specific sub-counties in Kenya.
- Multilingual Support: Implement translation capabilities (starting with Swahili) to make the application fully accessible to all local communities.
- Preventative Scheduling: Introduce a proactive module that uses historical data to recommend preventative treatments before pests or diseases even appear.
Built With
- google-gemini-api-(@google/genai)
- information
- isric
- next.js-(react)
- openstreetmap
- openweathermap
- soil
- supabase-(authentication/database)
- tailwind-css
- typescript
- vercel
- world
Log in or sign up for Devpost to join the conversation.