Skip to content

ABINAS-cyber/PlantDoc-An-Autonomous-AI-Agent-for-Plant-Disease-Detection-and-SMS-Based-Treatment-Delivery

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

2 Commits
Β 
Β 
Β 
Β 

Repository files navigation

🌿 PlantDoc β€” Autonomous AI Agent for Plant Disease Detection & SMS-Based Treatment Delivery

License: MIT Build Status


🌍 Overview

PlantDoc is an AI-powered platform designed to detect plant diseases from leaf images and deliver treatment advice directly to farmers via SMS. The system integrates a React + TypeScript + Vite web frontend with a backend AI model and Supabase authentication. It provides an end-to-end pipeline β€” from disease detection to treatment recommendation delivery.


πŸš€ Features

  • 🌾 AI-based disease detection from uploaded leaf images
  • πŸ’¬ SMS delivery of treatment recommendations (Twilio or custom gateway)
  • πŸ” Supabase authentication for secure user management
  • πŸ“± Responsive web app built with TailwindCSS
  • ☁️ Fast and modular deployment using Vite and Docker
  • πŸ“Š Visual dashboards for prediction history and disease insights

🧩 Tech Stack

Layer Technology
Frontend React + TypeScript + Vite
Styling TailwindCSS
Auth / Database Supabase
Backend Model API Python / FastAPI (optional integration)
SMS Gateway Twilio / Nexmo / Local Gateway
Config Tools ESLint, PostCSS, tsconfig

πŸ“‚ Repository Structure

plantdoc/
β”œβ”€β”€ public/                  # Static assets
β”œβ”€β”€ src/                     # React components, pages, and logic
β”‚   β”œβ”€β”€ components/          # Reusable UI components
β”‚   β”œβ”€β”€ pages/               # Main route pages
β”‚   β”œβ”€β”€ hooks/               # Custom React hooks
β”‚   β”œβ”€β”€ utils/               # Utility/helper functions
β”‚   └── main.tsx             # Application entry
β”œβ”€β”€ supabase/                # Supabase client & schema definitions
β”œβ”€β”€ .env.example             # Example environment variables
β”œβ”€β”€ package.json             # Project dependencies and scripts
β”œβ”€β”€ tailwind.config.ts       # Tailwind configuration
β”œβ”€β”€ vite.config.ts           # Vite setup and build settings
β”œβ”€β”€ docker/                  # Dockerfile(s) for backend & frontend
β”œβ”€β”€ src/api/                 # Backend REST API for inference
β”œβ”€β”€ src/model/               # ML model and preprocessing scripts
β”œβ”€β”€ src/sms/                 # SMS adapter (Twilio/Nexmo)
β”œβ”€β”€ src/recommender/         # Disease β†’ Treatment mapping logic
└── README.md

βš™οΈ Setup & Installation

1️⃣ Clone the repository

git clone https://github.com/<your-username>/PlantDoc.git
cd PlantDoc

2️⃣ Install dependencies

Using npm:

npm install

Or using Bun:

bun install

3️⃣ Environment Variables

Create a .env file in the project root (copy from .env.example):

# Supabase
VITE_SUPABASE_URL=your_supabase_url
VITE_SUPABASE_ANON_KEY=your_supabase_key

# Model API
VITE_API_URL=https://your-ai-api-endpoint/predict

# SMS Gateway (Twilio example)
SMS_PROVIDER=twilio
TWILIO_ACCOUNT_SID=your_sid_here
TWILIO_AUTH_TOKEN=your_token_here
TWILIO_FROM_NUMBER=+1234567890

4️⃣ Run the Development Server

npm run dev

App will be live at http://localhost:5173/ πŸŽ‰


🧠 AI Model & Backend API

A Python-based API (FastAPI/Flask) serves the trained ML model for disease prediction.

Example Model Inference Endpoint

  • POST /predict β€” accepts an image file and returns the predicted disease.
  • Optionally sends an SMS with treatment advice if phone_number is included.

Example:

curl -X POST -F "image=@leaf.jpg" -F "phone_number=+91XXXXXXXXXX" https://api.plantdoc.ai/predict

Model Training

Train using a dataset such as PlantVillage:

python src/model/train.py --data data/processed --epochs 30 --model resnet18 --save-dir models/run1

πŸ’¬ SMS Treatment Delivery

Uses Twilio SDK to send treatment recommendations to farmers.

Example:

from src.sms.twilio_adapter import TwilioClient
client = TwilioClient(account_sid, auth_token, from_number)
client.send_sms(to='+91XXXXXXXXXX', body='Detected: Early Blight. Recommended: ...')

⚠️ Use sandbox/test credentials for development to avoid SMS charges.


πŸ“Š Evaluation Metrics

  • Accuracy, Precision, Recall, F1-score per class
  • Confusion matrix visualization
  • Batch evaluation supported
python src/model/evaluate.py --model models/run1/best_model.pth --data data/val

🧾 Available Frontend Scripts

Command Description
npm run dev Run local development server
npm run build Build production bundle
npm run preview Preview production build locally
npm run lint Run code linter

☁️ Deployment

Frontend (Vercel / Netlify)

  • Import GitHub repo
  • Add environment variables under project settings
  • Deploy automatically from main

Backend (Docker Example)

docker build -t plantdoc-api -f docker/Dockerfile.api .
docker run -p 8000:8000 --env-file .env plantdoc-api

πŸ§‘β€πŸŒΎ Supabase Setup (Quick Guide)

  1. Go to https://supabase.com β†’ Create a new project
  2. Get your API URL and Anon Key from Project Settings β†’ API tab
  3. Paste them into .env as VITE_SUPABASE_URL and VITE_SUPABASE_ANON_KEY
  4. Use Supabase Auth for signup/login (email/password or OAuth)

πŸ§ͺ Testing

Run frontend tests:

npm run test

Run backend model tests:

pytest -q

🧰 Contributing

  1. Fork the repository
  2. Create a new branch: git checkout -b feature/your-feature
  3. Commit changes: git commit -m 'Add new feature'
  4. Push and open a Pull Request 🎯

πŸ”’ Security & Privacy

  • Do not commit .env or credentials
  • Mask phone numbers in logs
  • Use HTTPS and authentication for production APIs

πŸ“œ License

This project is released under the MIT License. See LICENSE for details.


🀝 Acknowledgements

  • PlantVillage dataset & open-source contributors
  • Twilio for SMS SDK support
  • Supabase for authentication and database services
  • OpenAI / PyTorch / HuggingFace models for reference

πŸ“¬ Contact

Maintainer: Abinas Dash Email: royalabinashdash2007@gmail.com

A unified AI + Web platform empowering farmers with real-time crop health insights and actionable solutions 🌾

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors