Skip to content

About

Instant plant diagnosis, powered by AI — no lab, no wait.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

CropDoc AI

Instant plant diagnosis, powered by AI — no lab, no wait.

Built with pride for UP-AI Hackdays.

License: MIT Built for Hackathon AI Engine Fallback Engine


🌿 Problem Statement

Agriculture forms the economic and nutritional backbone for millions of households. Yet every farming season, smallholder farmers and growers face devastating crop losses—often between 20% to 40% of their total yield—due to plant pests, blights, nutrient deficiencies, and fungal infections.

In rural and underserved agrarian belts:

  • Access to Agricultural Extension Officers is Limited: The ratio of agronomists or plant pathologists to farmers is heavily imbalanced; getting an expert to visit a field in person can take days or weeks.
  • Delayed & Inaccurate Diagnosis: Early signs of foliar blight, mildew, or viral mosaic are frequently mistaken for simple water stress or general nutrient shortfall. By the time lesions become obvious, the infection has often colonized the crop canopy.
  • Costly or Harmful Misapplications: Without an exact diagnosis, farmers often guess and apply inappropriate chemical fungicides or broad-spectrum pesticides, burning crops, depleting soil biology, and wasting scarce capital.

💡 Solution Overview

CropDoc AI is a lightweight, mobile-first plant pathology companion designed to turn any smartphone or browser into an on-demand agricultural clinic.

Farmers simply take or upload a photo of a diseased crop leaf. Within seconds, CropDoc AI delivers a structured, actionable diagnosis:

  • Exact Plant & Disease Identification: Pinpoints specific pathogens (e.g., Tomato Early Blight, Powdery Mildew, Bacterial Leaf Streak) or confirms whether the leaf is healthy.
  • Observable Symptoms & Underlying Cause: Explains why the disease occurred (fungal spore splash, high humidity, insect vectors, or nutrient imbalance).
  • Graded Severity Level: Categorizes severity as Mild, Moderate, or Severe with color-coded alerts to guide immediate response.
  • Actionable Treatment Protocol: Offers step-by-step guidance combining organic cultural practices (neem sprays, pruning, irrigation adjustments) and approved targeted treatments.
  • Preventive Best Practices: Equips the farmer with long-term prevention strategies (crop rotation, resistant cultivars, optimal plant spacing).
  • Bilingual Interface (English & Hindi): Delivers all medical-botanical explanations and treatment instructions in simple, regionally accessible English or authentic Hindi (हिंदी).

🚀 Key Features

  • Instant Leaf Photo Upload & Drag-and-Drop: Supports mobile camera capture, file uploads, and curated 1-click test samples (including Tomato Early Blight, Leaf Chlorosis, Mildew, and non-plant edge case testing).
  • Direct Multimodal AI Pathology: Employs vision-language reasoning to detect botanical anomalies directly from visual leaf patterns without needing heavy, inflexible convolutional classifier heads.
  • Structured, Standardized Output: Enforces strict, typed schema outputs guaranteeing consistent diagnosis fields (plant name, pathogen, severity, causes, steps, and tips).
  • High-Availability Fallback Architecture: Includes automated multi-tier failover (Google Gemini primary vision with sub-second Groq Vision fallback) to guarantee 99.9% uptime during high-concurrency hackathon judging or sudden upstream rate-limits.
  • Color-Coded Severity Visualization: Distinct visual badges (Emerald for Healthy, Amber for Moderate, Crimson for Severe) give farmers immediate situational awareness.
  • Bilingual Accessibility (English & Hindi): Instant toggle enables farmers to receive treatments in their preferred language with regional agricultural terminology.
  • Non-Plant Leaf Guardrail: Protects users from misdiagnosis by verifying that the image is a valid botanical specimen before attempting disease analysis.

🛠️ Technology Stack

Layer Technologies
Primary Multimodal Vision Google Gemini API (gemini-3.6-flash / gemini-3.8-flash) via @google/genai TypeScript SDK
Fallback Vision Engine Groq Vision API (qwen/qwen3.8-27b / qwen/qwen3.6-27b) via high-speed inference
Tertiary Vision Engine Mistral Pixtral Vision (pixtral-12b-2409) multimodal Chat Completions
Frontend Framework React 18, TypeScript, Vite
Styling & Design System Tailwind CSS, Glassmorphic organic UI design, Lucide Icons
Animations & Transitions Motion (motion/react) for tactile feedback and smooth layout shifts
Backend & API Layer Node.js, Express, Server-side API key isolation (/api/diagnose)
Prototyping & Hosting Google AI Studio Build, Cloud Run container environment

🧠 How AI Is Used

Unlike legacy agricultural apps that chain together brittle, pre-trained CNN image classification models with generic, separate chatbot prompts:

  1. Direct Visual Reasoning (Zero-Shot & Few-Shot Botanical Intelligence): Gemini analyzes the uploaded leaf's visual features directly—evaluating concentric lesion rings, leaf margin chlorosis, vascular wilting, and fungal mycelium patterns.
  2. Context-Aware Etiology & Pathology: The AI reasons over host plant species, pathogen lifecycle, and infection vectors (such as Alternaria solani in nightshades) to explain the root cause rather than merely returning a raw classification label.
  3. Structured Schema Enforcement: The multimodal model is constrained by strict JSON schema definitions, returning typed arrays of treatment steps, preventive guidelines, and severity ratings that directly populate the interactive UI.
  4. AI is the Core Engine, Not a Gimmick: AI does not sit in an optional chat widget; it powers the central end-to-end diagnostic workflow, localization pipeline, and agricultural advisory synthesis.

💻 Setup & Installation Instructions

Follow these steps to run CropDoc AI locally on your development machine:

Prerequisites

  • Node.js (v18.0.0 or higher)
  • npm or bun / yarn
  • Gemini API Key from Google AI Studio
  • (Optional) Groq API Key from Groq Console for fallback redundancy

1. Clone the Repository

git clone https://github.com/your-username/cropdoc-ai.git
cd cropdoc-ai

2. Install Dependencies

npm install

3. Configure Environment Variables

Create a .env file in the root directory (based on .env.example):

cp .env.example .env

Add your API credentials:

# Required for primary diagnosis
GEMINI_API_KEY=your_google_gemini_api_key_here

# Optional: Enables high-availability fallback
GROQ_API_KEY=your_groq_api_key_here
MISTRAL_API_KEY=your_mistral_api_key_here

4. Run the Application

yarn dev

Open your browser and navigate to http://localhost:3000.

5. Production Build

yarn install && yarn build
node dist/server.cjs

🌐 Live Application


🌍 Impact & Future Scope

Real-World Impact

  • Saves Agricultural Yield: Enables early-stage detection before fungal spores or viral blights spread across an entire field.
  • Democratizes Agronomy: Bridges the digital divide for smallholder farmers by putting expert diagnostic knowledge directly into their hands for free.
  • Reduces Chemical Contamination: Guides farmers toward targeted cultural remedies and organic solutions, preventing excessive pesticide application.

Future Roadmap

  • Offline Edge Inference: Package lightweight quantized vision models for zero-connectivity field operation in remote rural zones.
  • Regional Dialect & Voice Input: Integrate vernacular audio input and spoken audio diagnostic playback for low-literacy farmers.
  • Local Weather & Microclimate Alerts: Correlate hyper-local weather forecast data (humidity, upcoming rains) with fungal spore risk models to alert farmers proactively.
  • Government & Agri-Kendra Helpline Bridge: One-click escalation to connect local agricultural universities, Krishi Vigyan Kendras (KVK), or state agronomists.
  • Farm History & Disease Timeline: Track recurring field infections season-over-season to optimize crop rotation planning.

📜 Originality Statement

This project, CropDoc AI, was ideated, architected, and developed specifically for the UPAI Hackdays hackathon. All source code, multimodal prompts, UI components, and fallback integrations represent original work created in accordance with the hackathon rules and guidelines.


📄 License

This project is licensed under the MIT License — see the LICENSE file for details.

About

Instant plant diagnosis, powered by AI — no lab, no wait.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages