Skip to content

BadrinathanTV/Farm-AI

Repository files navigation

Farm-AI: Intelligent Agricultural Assistant 👨‍🌾

Project Status Python Frontend Backend

📖 Overview

Farm-AI is a cutting-edge, multi-agent artificial intelligence system designed to assist farmers with daily agricultural tasks. It leverages modern LLMs (Language Models) and RAG (Retrieval-Augmented Generation) to provide personalized advice, market intelligence, weather forecasts, and plant disease diagnosis.

The system is built on a modular LangGraph architecture, orchestrating specialized agents that share a unified memory of the farmer's profile, crops, and past activities.

🏗️ Architecture

The system uses a Supervisor-Worker pattern with a Decoupled React + FastAPI architecture.

graph TD
    User((User)) -->|Browser| Frontend[React Frontend]
    User -->|SMS| Twilio[Twilio Gateway]
    
    Frontend -->|REST API| Backend[FastAPI Backend]
    Twilio -->|Webhook| Backend
    
    subgraph "FastAPI Backend"
        Backend -->|State| Supervisor{Supervisor Agent}
        
        subgraph "Agent Ecosystem"
            Supervisor -->|Routing| Profile[Farmer Profile Agent]
            Supervisor -->|Routing| Knowledge[Knowledge Support Agent]
            Supervisor -->|Routing| Market[Market Intelligence Agent]
            Supervisor -->|Routing| Weather[Weather Agent]
            Supervisor -->|Routing| Disease[Plant Disease Agent]
        end
        
        subgraph "Core Services"
            Knowledge -->|RAG Retrieval| RAG[RAG Service]
            RAG -->|Hybrid Search| VectorDB[(FAISS + BM25)]
            Profile <-->|Read/Write| DB[(MongoDB)]
            AllAgents <-->|Context| Memory[Memory Service]
        end
        
        Disease -->|Image Analysis| VisionModel[Vision LLM]
    end
Loading

🚀 Key Features

  1. Modern Web Interface: Built with React 19, Vite, and Tailwind CSS for a premium, responsive experience.
  2. Robust RAG: Hybrid Search (FAISS + BM25) for accurate retrieval from agricultural manuals.
  3. MCP Integration: Uses Model Context Protocol to safely connect LLMs to live tools (Search, Weather).
  4. Multi-Modal: Supports Text and Image inputs for plant disease diagnosis.
  5. Context-Aware: Remembers user profile and active crops across sessions.

🛠️ Installation & Setup

Prerequisites

  • Python 3.12+
  • Node.js 18+
  • MongoDB instance

1. Clone & Install Dependencies

Backend:

uv sync

Frontend:

cd frontend
npm install

2. Configure Environment

Create a .env file in the root directory:

OPENAI_API_KEY=sk-...
MONGO_URI=mongodb://...
MCP_PORT=8001

3. Run the Application

Use the helper script to start Backend, Frontend, and MCP servers:

./run_farm_ai.sh

📁 Project Structure

├── backend/            # FastAPI Application & Agents
│   ├── agents/         # Agent definitions
│   ├── api/            # REST Endpoints
│   ├── core/           # Shared services
│   └── main.py         # Entry point
├── frontend/           # React Application
│   ├── src/            # Components & Logic
│   └── index.html
├── EVAL/               # Evaluation scripts
├── knowledge_base/     # Raw PDF documents
└── run_farm_ai.sh      # Startup script

🤝 Contributing

  1. Fork the repo.
  2. Create a feature branch.
  3. Run tests and evaluation.
  4. Submit a Pull Request.

Built with ❤️ for generic farming communities.

About

AI-powered farming assistant built with LangChain & LangGraph. Orchestrates specialized agents for RAG-based advisory, crop health monitoring, and local market analytics via MCP.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors