Skip to content

anasuddin1/FarmMate-Pro

Repository files navigation

🌱 FarmMate

FarmMate is a Python-based multi-agent system designed to assist farmers by combining expert crop disease diagnosis with real-time local weather observations.

This repository serves as an educational demo of the Model Context Protocol (MCP) and Agentic Design Patterns (ADK).


📋 Table of Contents

  1. The Problem & The Solution
  2. Architecture Diagram
  3. Dashboard Preview & Workflows
  4. How it Works: Key Concepts
  5. File Structure
  6. Setup & Installation
  7. Running the Application
  8. Camera Presentation Guide

🔍 The Problem & The Solution

The Problem

When a farmer identifies symptoms of a crop disease (e.g. brown leaf spots), they need two critical pieces of information to act effectively:

  1. Diagnosis: What disease is this, and how is it treated?
  2. Context (Weather): Is it about to rain? Is it extremely windy? Is it scorching hot?

Applying treatment without checking the weather is wasteful and potentially harmful. For instance, spraying a liquid fungicide right before a heavy rain will wash the chemical away. Spraying botanical oils (like neem oil) during peak sun can burn plant foliage.

The Solution

FarmMate solves this with an orchestrator-agent framework:

  • The DiagnosisAgent identifies the disease and suggests remedies based on local crop knowledge.
  • The WeatherAgent dynamically retrieves real-time weather details.
  • The Orchestrator combines both outputs to create weather-aware action plans (e.g., advising the farmer to delay spraying until a storm passes, or adjusting irrigation).

🏗️ Architecture Diagram

Here is how data flows through the system:

       [ Farmer / Streamlit UI ]
                   │
                   ▼  (Submits crop problem & city)
            [ Orchestrator ]
             /            \
            / (Concurrent) \
           ▼                ▼
   [DiagnosisAgent]    [WeatherAgent]
     │                      │
     ├─► Reads Local        └─► Spawns MCP client stdio transport
     │   Knowledge File         │
     │   (farming_knowledge.md) └──► Connects to [Weather MCP Server]
     │                                     │
     └─► Calls Gemini API                  └─► Fetches Open-Meteo REST API
           (diagnose symptoms)                   (lat/lon & forecast)
           
                   │                        │
                   ▼                        ▼
           (Diagnosis Report)        (Weather Report)
            \                              /
             \                            /
              └──► [ Orchestrator ] ◄────┘
                         │
                         ├─► Synthesizes results using Gemini API
                         │
                         ▼
             [ Farmer / Streamlit UI ]
         (Displays Unified Action Plan)

🖼️ Dashboard Preview & Workflows

Below is a visual walk-through of the FarmMate Pro dashboard in action:

1. Interactive Demo Session

You can load symptom presets and cities with a single click to test different scenarios: Interactive Demo Session

2. Live Weather Widget & Pathology Report

The system queries coordinates and fetches weather forecasts from Open-Meteo, displaying them in modern metric cards: Live Weather Context

3. Synthesized Weather-Aware Spray Plan

The orchestrator combines pathology with live weather constraints, providing direct spray timelines and a download report button: Action Recommendation Plan


💡 How it Works: Key Concepts

1. Model Context Protocol (MCP)

MCP is an open standard that enables developers to build secure, modular integrations ("servers") that expose data and tools to AI models ("clients").

  • In FarmMate, weather_mcp.py is the MCP Server. It exposes a tool called get_weather.
  • agents.py contains the MCP Client code inside the WeatherAgent. It runs the server script as a subprocess, initializes the protocol, and calls the get_weather tool.

2. Agentic Patterns (ADK)

  • Specialized Agents: Instead of asking a single prompt to do everything, we split roles. DiagnosisAgent specializes in crop disease, and WeatherAgent specializes in data gathering.
  • Orchestration: The Orchestrator manages the lifecycle of the agents, executing tasks concurrently, and merging their outputs into a final synthesized recommendation.

📂 File Structure

  • skills/farming_knowledge.md - Grounding reference data for crop symptoms and standard cures.
  • weather_mcp.py - Custom weather MCP server using FastMCP wrapping Open-Meteo.
  • agents.py - Core classes: DiagnosisAgent, WeatherAgent, and Orchestrator.
  • app.py - Beautiful, easy-to-use Streamlit web interface.
  • .env.template - Example configurations for environment variables.
  • requirements.txt - Project python package dependencies.

About

AI multi-agent system for farmers — crop diagnosis + weather-aware advice using Gemini, MCP, and Streamlit

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages