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.
- πΎ 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
| 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 |
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
git clone https://github.com/<your-username>/PlantDoc.git
cd PlantDocUsing npm:
npm installOr using Bun:
bun installCreate 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
npm run devApp will be live at http://localhost:5173/ π
A Python-based API (FastAPI/Flask) serves the trained ML model for disease prediction.
POST /predictβ accepts an image file and returns the predicted disease.- Optionally sends an SMS with treatment advice if
phone_numberis included.
Example:
curl -X POST -F "image=@leaf.jpg" -F "phone_number=+91XXXXXXXXXX" https://api.plantdoc.ai/predictTrain using a dataset such as PlantVillage:
python src/model/train.py --data data/processed --epochs 30 --model resnet18 --save-dir models/run1Uses 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.
- 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| 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 |
- Import GitHub repo
- Add environment variables under project settings
- Deploy automatically from
main
docker build -t plantdoc-api -f docker/Dockerfile.api .
docker run -p 8000:8000 --env-file .env plantdoc-api- Go to https://supabase.com β Create a new project
- Get your API URL and Anon Key from Project Settings β API tab
- Paste them into
.envasVITE_SUPABASE_URLandVITE_SUPABASE_ANON_KEY - Use Supabase Auth for signup/login (email/password or OAuth)
Run frontend tests:
npm run testRun backend model tests:
pytest -q- Fork the repository
- Create a new branch:
git checkout -b feature/your-feature - Commit changes:
git commit -m 'Add new feature' - Push and open a Pull Request π―
- Do not commit
.envor credentials - Mask phone numbers in logs
- Use HTTPS and authentication for production APIs
This project is released under the MIT License. See LICENSE for details.
- PlantVillage dataset & open-source contributors
- Twilio for SMS SDK support
- Supabase for authentication and database services
- OpenAI / PyTorch / HuggingFace models for reference
Maintainer: Abinas Dash Email: royalabinashdash2007@gmail.com
A unified AI + Web platform empowering farmers with real-time crop health insights and actionable solutions πΎ