{"id":50443487,"url":"https://github.com/aryankdev/agro-ai","last_synced_at":"2026-05-31T20:00:45.895Z","repository":{"id":356799114,"uuid":"1233285515","full_name":"aryanKDev/Agro-ai","owner":"aryanKDev","description":"AI-powered Plant Disease Detection System using TensorFlow, Flask, and Gemini AI","archived":false,"fork":false,"pushed_at":"2026-05-28T19:34:07.000Z","size":86770,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-05-28T21:18:13.705Z","etag":null,"topics":["ai","computer-vision","deep-learning","flask","gemini-ai","huggingface","machine-learning","plant-disease-detection","tensorflow"],"latest_commit_sha":null,"homepage":"https://aryan-29-agro-ai.hf.space","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/aryanKDev.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2026-05-08T19:46:34.000Z","updated_at":"2026-05-28T19:34:11.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/aryanKDev/Agro-ai","commit_stats":null,"previous_names":["aryankdev/agro-ai"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/aryanKDev/Agro-ai","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aryanKDev%2FAgro-ai","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aryanKDev%2FAgro-ai/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aryanKDev%2FAgro-ai/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aryanKDev%2FAgro-ai/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/aryanKDev","download_url":"https://codeload.github.com/aryanKDev/Agro-ai/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aryanKDev%2FAgro-ai/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":33746513,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-05-31T02:00:06.040Z","response_time":95,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ai","computer-vision","deep-learning","flask","gemini-ai","huggingface","machine-learning","plant-disease-detection","tensorflow"],"created_at":"2026-05-31T20:00:38.214Z","updated_at":"2026-05-31T20:00:45.872Z","avatar_url":"https://github.com/aryanKDev.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cdiv align=\"center\"\u003e\n\n# 🌿 AgroAI — Intelligent Plant Disease Detection Platform\n\n**Phase 1 Complete · Multi-User SaaS · AI-Powered · Real-Time Intelligence**\n\n[![Python](https://img.shields.io/badge/Python-3.10+-3776AB?style=for-the-badge\u0026logo=python\u0026logoColor=white)](https://python.org)\n[![Flask](https://img.shields.io/badge/Flask-3.x-000000?style=for-the-badge\u0026logo=flask\u0026logoColor=white)](https://flask.palletsprojects.com)\n[![MongoDB](https://img.shields.io/badge/MongoDB-Atlas-47A248?style=for-the-badge\u0026logo=mongodb\u0026logoColor=white)](https://mongodb.com/atlas)\n[![TensorFlow](https://img.shields.io/badge/TensorFlow-2.x-FF6F00?style=for-the-badge\u0026logo=tensorflow\u0026logoColor=white)](https://tensorflow.org)\n[![License: MIT](https://img.shields.io/badge/License-MIT-green?style=for-the-badge)](LICENSE)\n\n\u003e AgroAI is a production-grade agricultural intelligence SaaS platform that combines **TensorFlow deep learning**, **Google Gemini AI**, **real-time weather data**, and a **predictive disease risk engine** to help farmers detect plant diseases, understand risk, and take action — all from their browser.\n\n\u003c/div\u003e\n\n---\n\n## ✨ Features\n\n| Feature | Description |\n|---|---|\n| 🔬 **AI Disease Detection** | TensorFlow CNN model trained on 87,000+ plant images across 38 disease classes |\n| 🔐 **JWT Authentication** | Secure register/login/logout with bcrypt password hashing |\n| 👤 **Multi-User SaaS** | Full data isolation — each user sees only their own scans, history, and analytics |\n| ☁️ **MongoDB Atlas** | Cloud-persisted scan history with user-scoped queries |\n| 🌦️ **Weather Intelligence** | Real-time weather via OpenWeatherMap API with 30-min cache and simulated fallback |\n| 📍 **Geolocation Weather** | Auto-detects user's GPS location via `navigator.geolocation` |\n| 🦠 **Disease Risk Engine** | Fuzzy-logic risk scoring (HIGH/MEDIUM/LOW) based on disease type + weather conditions |\n| 📊 **Analytics Dashboard** | Personalised KPIs, risk distribution charts, and activity timeline per user |\n| 💬 **Gemini AI Chatbot** | Context-aware plant disease assistant powered by Google Gemini 1.5 Flash |\n| 📄 **PDF Reports** | Premium AI-generated scan reports via ReportLab |\n| 🌍 **Farming Insights** | 9 threshold-based agronomic advisory rules from weather data |\n\n---\n\n## 🏗️ Architecture\n\n```\n┌─────────────────────────────────────────────────────────────┐\n│                     AgroAI Platform                         │\n├───────────────┬─────────────────────┬───────────────────────┤\n│   Frontend    │      Backend        │     Intelligence       │\n│               │                    │                        │\n│  HTML5/CSS3   │   Flask 3.x        │  TensorFlow CNN        │\n│  Vanilla JS   │   Flask-JWT-Extended│  Gemini 1.5 Flash      │\n│  Chart.js     │   PyMongo          │  Risk Engine (Fuzzy)   │\n│  Glassmorphism│   Flask-Bcrypt     │  Weather Service (OWM) │\n│               │   ReportLab        │  Farming Insights      │\n└───────────────┴─────────────────────┴───────────────────────┘\n                           │\n                    MongoDB Atlas\n                  (User-Scoped Data)\n```\n\n### Data Flow — Authenticated Scan\n\n```\nBrowser (logged in)\n  → POST /predict  +  Authorization: Bearer \u003cJWT\u003e\n  → get_optional_user_id()  →  ObjectId(\"user123\")\n  → TensorFlow prediction  →  disease_name, confidence\n  → get_weather(\"Bhopal\")  →  humidity, temperature\n  → risk_engine.analyse_risk()  →  HIGH/MEDIUM/LOW\n  → MongoDB: { disease, confidence, userId, riskLevel, weatherSnapshot }\n  → Response: { disease_name, riskLevel, riskScore, riskReason }\n  → Frontend: History page updates immediately ✅\n```\n\n---\n\n## 🚀 Quick Start\n\n### Prerequisites\n\n- Python 3.10+\n- MongoDB Atlas cluster (free tier works)\n- Google Gemini API key ([get one](https://aistudio.google.com/app/apikey))\n- OpenWeatherMap API key ([get one](https://openweathermap.org/api)) *(optional — has simulation fallback)*\n\n### Installation\n\n```bash\n# 1. Clone the repository\ngit clone https://github.com/yourusername/PDDS.git\ncd PDDS/plant-disease-detection-system\n\n# 2. Create and activate virtual environment\npython -m venv venv\nvenv\\Scripts\\activate          # Windows\n# source venv/bin/activate     # macOS/Linux\n\n# 3. Install dependencies\npip install -r requirements.txt\n\n# 4. Configure environment variables\ncp .env.example .env\n# Edit .env with your actual keys (see Environment Variables section)\n\n# 5. Run the application\npython app.py\n```\n\nOpen **http://127.0.0.1:5000** in your browser.\n\n---\n\n## 🔐 Environment Variables\n\nCreate a `.env` file in the project root (never commit this file):\n\n```env\n# Google Gemini AI\nGOOGLE_API_KEY=your_gemini_api_key_here\n\n# MongoDB Atlas\nMONGO_URI=mongodb+srv://username:password@cluster.mongodb.net/agroai?retryWrites=true\u0026w=majority\n\n# JWT Authentication\nJWT_SECRET_KEY=your_strong_random_secret_here_min_32_chars\nJWT_ACCESS_TOKEN_EXPIRES=86400\n\n# OpenWeatherMap (optional — falls back to simulation if missing)\nOPENWEATHER_API_KEY=your_openweathermap_api_key_here\n```\n\n\u003e ⚠️ **Security**: The `.env` file is listed in `.gitignore` and will never be committed. All secrets must live here only.\n\n---\n\n## 📁 Project Structure\n\n```\nplant-disease-detection-system/\n├── app.py                    # Flask application \u0026 all API routes\n├── database.py               # MongoDB Atlas CRUD operations (user-scoped)\n├── risk_engine.py            # Fuzzy-logic disease spread risk scoring\n├── pdf_generator.py          # ReportLab PDF report generation\n├── disease_rules.json        # 38-class disease→risk threshold mapping\n├── auth/\n│   └── routes.py             # JWT auth blueprints (register/login/logout/profile)\n├── services/\n│   ├── weather_service.py    # OpenWeatherMap + GPS coord lookup + fallback\n│   └── farming_insights.py  # Agronomic threshold-based advisory rules\n├── index.html                # Single-page application shell\n├── script.js                 # Frontend modules (Router, Storage, Analytics, Weather, RiskCard)\n├── auth.js                   # JWT auth state manager (window.Auth)\n├── style.css                 # Glassmorphic CSS design system\n├── requirements.txt          # Python dependencies\n├── .env.example              # Environment variable template\n├── .gitignore                # Excludes .env, __pycache__, venv, etc.\n└── trained_plant_disease_model.keras  # TensorFlow CNN (38 classes)\n```\n\n---\n\n## 🔌 API Reference\n\n### Authentication\n\n| Method | Endpoint | Auth | Description |\n|---|---|---|---|\n| `POST` | `/api/auth/register` | None | Create new account |\n| `POST` | `/api/auth/login` | None | Login, returns JWT |\n| `POST` | `/api/auth/logout` | JWT | Invalidate session |\n| `GET` | `/api/auth/profile` | JWT | Get user profile |\n| `PUT` | `/api/auth/profile` | JWT | Update profile |\n\n### Core AI\n\n| Method | Endpoint | Auth | Description |\n|---|---|---|---|\n| `POST` | `/predict` | Optional | Run disease detection + risk analysis |\n| `POST` | `/chat` | None | Gemini AI chatbot |\n| `POST` | `/generate-report` | None | Generate PDF report |\n\n### Data \u0026 Intelligence\n\n| Method | Endpoint | Auth | Description |\n|---|---|---|---|\n| `GET` | `/api/scans` | Optional | Get scan history (user-scoped if JWT present) |\n| `DELETE` | `/api/scans/\u003cid\u003e` | Optional | Delete a scan |\n| `GET` | `/api/dashboard` | **Required** | Personalised KPIs and analytics |\n| `GET` | `/api/weather?city=X` | None | Weather by city name |\n| `GET` | `/api/weather?lat=X\u0026lon=Y` | None | Weather by GPS coordinates |\n| `POST` | `/api/risk-analysis` | None | Standalone risk analysis |\n\n---\n\n## 🧪 Testing\n\nRun the automated regression suite (requires server running):\n\n```bash\n# Start server in one terminal\npython app.py\n\n# Run regression tests in another\npython verify_bugfix.py     # 29 API tests\npython prove_scan_fix.py    # Scan persistence proof\n```\n\n---\n\n## 🌿 Supported Diseases (38 Classes)\n\nThe model detects diseases across **14 plant species**:\n\n| Plant | Diseases Detected |\n|---|---|\n| Tomato | Early Blight, Late Blight, Leaf Mold, Septoria, Spider Mites, Target Spot, Mosaic Virus, Yellow Leaf Curl, Bacterial Spot, Healthy |\n| Potato | Early Blight, Late Blight, Healthy |\n| Corn/Maize | Cercospora, Common Rust, Northern Blight, Healthy |\n| Apple | Black Rot, Cedar Rust, Scab, Healthy |\n| Grape | Black Rot, Esca, Isariopsis Leaf Spot, Healthy |\n| + 9 more | Peach, Cherry, Pepper, Strawberry, Soybean, Squash, Blueberry, Raspberry, Orange |\n\n---\n\n## 🔒 Security Features\n\n- **Password hashing**: `bcrypt` with salt rounds\n- **JWT tokens**: HS256 signed, 24-hour expiry\n- **Data isolation**: All MongoDB queries scoped by `userId` (ObjectId)\n- **Optional auth on `/predict`**: JWT injected automatically when logged in\n- **No secrets in source**: All credentials in `.env` (git-ignored)\n- **CORS**: Configured for local dev; restrict origins in production\n\n---\n\n## 📸 Screenshots\n\n\u003e *Glassmorphic dark UI with real-time intelligence*\n\n| Feature | Screenshot |\n|---|---|\n| Disease Detection | Upload → AI Analysis → Risk Card |\n| Weather Dashboard | Live weather + Smart Farming Insights |\n| Analytics Page | KPI cards + Risk distribution chart |\n| Scan History | Per-user MongoDB-backed history with risk badges |\n\n---\n\n## 🗺️ Roadmap\n\n- [x] **Phase 1A** — JWT Auth + Multi-User SaaS\n- [x] **Phase 1B** — User Dashboard \u0026 Analytics\n- [x] **Phase 1C** — Real-Time Weather Integration\n- [x] **Phase 1D** — Farming Insights Engine\n- [x] **Phase 1E** — Disease Risk Prediction Engine\n- [ ] **Phase 2** — Subscription tiers + Stripe billing\n- [ ] **Phase 2** — Mobile PWA with offline detection\n- [ ] **Phase 3** — Multi-farm management + team accounts\n- [ ] **Phase 3** — Historical weather trend analysis\n\n---\n\n## 🤝 Contributing\n\n1. Fork the repository\n2. Create your feature branch (`git checkout -b feature/phase-2-billing`)\n3. Commit your changes (`git commit -m 'Add Stripe billing integration'`)\n4. Push to the branch (`git push origin feature/phase-2-billing`)\n5. Open a Pull Request\n\n---\n\n## 📄 License\n\nThis project is licensed under the MIT License — see the [LICENSE](LICENSE) file for details.\n\n---\n\n\u003cdiv align=\"center\"\u003e\n\nBuilt with 🌿 by the AgroAI Team · Powered by TensorFlow, Flask, MongoDB Atlas \u0026 Google Gemini\n\n\u003c/div\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faryankdev%2Fagro-ai","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Faryankdev%2Fagro-ai","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faryankdev%2Fagro-ai/lists"}