Skip to content

Shakya-kumar/agroweb

Repository files navigation

AgroAlly - Agricultural Intelligence Platform

AgroAlly Python Flask License

An intelligent web application for modern agriculture

FeaturesInstallationUsageProject StructureContact


📋 Table of Contents


🌾 Overview

AgroAlly is a comprehensive agricultural intelligence platform designed to empower farmers and agricultural professionals with data-driven insights. The platform leverages agricultural datasets and simple machine-learning style logic to provide intelligent recommendations for crop selection, soil analysis, and disease detection.

This repository is structured and documented to be suitable for academic review (e.g. submission to a professor) and for demonstration in interviews or portfolios.


✨ Features

1. Crop Recommendation System

  • Analyzes 7 key parameters: Nitrogen (N), Phosphorus (P), Potassium (K), Temperature, Humidity, pH, and Rainfall
  • Uses Euclidean distance on a curated dataset to find the most similar crop conditions
  • Provides recommendations in both English and Hindi using crop-name mapping

2. Soil Analysis & Fertilizer Recommendations

  • Compares current soil parameters with optimal values for a target crop
  • Highlights nutrient deficiencies or surpluses (N, P, K)
  • Suggests fertilizer types and approximate application amounts (Urea, DAP, MOP)
  • Adds general agronomic advice (pH correction, temperature, humidity, rainfall)

3. Disease Detection (Image-Based)

  • Upload plant images for disease analysis
  • Three analysis modes:
    • Leaf Disease Detection
    • Fruit Disease Detection
    • Root Disease Detection
  • Uses PyTorch resnet18 model when available, with a safe mock fallback when not
  • Provides human-readable treatment recommendations per plant and disease type

4. User Management & History

  • Secure login and registration using hashed passwords
  • Session-based authentication with Flask
  • Per-user history of:
    • Crop recommendations
    • Soil analyses
    • Disease analyses
  • History is stored in SQLite and rendered in a readable JSON-like format

🛠 Technology Stack

Backend

  • Framework: Flask 3.0.0
  • Language: Python 3.11
  • Database: SQLite (development, academic demo)
  • Authentication: Werkzeug password hashing
  • Data Processing: Pandas, NumPy

Frontend

  • Framework: Bootstrap 5
  • Languages: HTML5, CSS3, Jinja2 templates
  • Icons: Font Awesome 6
  • Design: Responsive, dashboard-style layout with sidebar navigation

Machine Learning (Optional)

  • Framework: PyTorch (optional, for disease detection)
  • Model: ResNet18-based classifier when model weights are available
  • Fallback: Mock predictions with deterministic, user-friendly outputs

📦 Installation

Prerequisites

  • Python 3.11 or higher
  • pip (Python package manager)
  • Git (for cloning repository)

Step 1: Clone the Repository

git clone https://github.com/Shakya-kumar/agroweb.git
cd agroweb

Step 2: Create Virtual Environment

# Windows
python -m venv venv
venv\Scripts\activate

# Linux/Mac
python3 -m venv venv
source venv/bin/activate

Step 3: Install Dependencies

pip install -r requirements.txt

Step 4: Run the Application (Local Development)

python app.py

The application will be available at http://localhost:5000.


🚀 Usage

1. Register and Login

  1. Open http://localhost:5000 in your browser.
  2. Click Register to create a new account.
  3. After registration you are automatically logged in and redirected to the dashboard.

2. Main Features (from the Sidebar)

  • Dashboard: High-level entry point via login redirect.
  • Crop Recommendation: Enter soil parameters and receive the most suitable crop suggestion.
  • Soil Analysis: Provide a target crop and soil parameters for detailed nutrient and pH guidance.
  • Disease Detection: Upload an image, select plant type and disease type (leaf/fruit/root) to get a prediction and treatment advice.
  • History: View all your past analyses and recommendations.
  • Contact & Reviews: Simple pages to demonstrate user feedback and contact details.

📁 Project Structure

agroally/
├── app.py                 # Main Flask application (auth + features + APIs)
├── wsgi.py                # WSGI entry point for production
├── requirements.txt       # Python dependencies
├── runtime.txt            # Python version specification (for deployment)
├── Procfile               # Process file for deployment (Gunicorn/WSGI)
├── .gitignore             # Git ignore rules
│
├── Crop_dataset.csv       # Crop recommendation dataset
│
├── templates/             # Flask Jinja2 templates
│   ├── base.html          # Base layout (sidebar, footer, etc.)
│   ├── login.html         # Login page
│   ├── register.html      # Registration page
│   ├── dashboard.html     # User dashboard
│   ├── crop_recommendation.html
│   ├── crop_recommendations.html
│   ├── crop_result.html
│   ├── soil_analysis.html
│   ├── soil_analysis_result.html
│   ├── disease_analysis.html
│   ├── disease_result.html
│   ├── grow_crop.html
│   ├── view_history.html
│   ├── contact.html
│   ├── reviews.html
│   ├── 404.html           # Error pages
│   └── 500.html
│
├── TESTING_GUIDE.md       # (Optional) notes for deployment/testing
└── instance/ (auto-created at runtime)
    └── users.db           # SQLite database

Note: the repository has been cleaned to remove unused legacy files (old login.py and standalone SPA assets), keeping only what is necessary for a clean, professional academic submission.


📡 API Documentation

Main Application Endpoints

Method Endpoint Description
GET / Redirects to login or dashboard
GET/POST /login User authentication
GET/POST /register User registration
GET /dashboard User dashboard
GET/POST /crop_recommendation Crop recommendation form + result
GET/POST /soil_analysis Soil analysis form + result
GET /disease_analysis Disease detection upload page
POST /analyze_disease Process disease detection
GET /history User history
GET /logout User logout

JSON API Endpoints (for integration)

Method Endpoint Description Request Body
POST /api/recommend Get crop recommendation JSON with N, P, K, temperature, humidity, ph, rainfall
POST /api/crop-requirements Get crop requirements JSON with crop_name and soil parameters

Example request:

curl -X POST http://localhost:5000/api/recommend \
  -H "Content-Type: application/json" \
  -d '{
    "N": 90,
    "P": 42,
    "K": 43,
    "temperature": 20.9,
    "humidity": 82,
    "ph": 6.5,
    "rainfall": 202.9
  }'

📞 Contact

Academic / project contact details used in the app:

  • Address: 84 Kalpana Nagar, 2nd Floor, Bhopal
  • Phone: +91 95890 02214
  • Email: support@agroally.com

For repository issues or suggestions, you can also open an issue on GitHub.


Built with ❤️ for Agriculture

⬆ Back to Top

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors