Documentation

Installation Guide

AgriAdvisor – AI-Powered Agricultural Advisory System with Marketplace

Step-by-step Setup Verified Instructions Chat Support
Back to Project
Complete Guide

AgriAdvisor – Installation Guide

Follow the steps below to set up and run the AgriAdvisor project on your local machine. The project has two parts: a Flask backend and a React.js frontend. Both must be running simultaneously for the application to work correctly.

Prerequisites

Make sure the following software is installed on your system before proceeding:

  • Python 3.10 or above – Required for the Flask backend and ML models
  • Node.js 18 or above – Required for the React.js frontend
  • pip – Python package manager (comes with Python)
  • npm – Node package manager (comes with Node.js)
  • Git – To clone the repository

Step 1 – Clone the Repository

Open your terminal or command prompt and run the following command to clone the project:

git clone <repository_url>
cd AgriAdvisor

Step 2 – Install Backend Dependencies

Navigate to the root project folder and install all required Python packages using pip:

pip install -r requirements.txt

This will install Flask, TensorFlow, scikit-learn, Flask-JWT-Extended, Flask-SQLAlchemy, Flask-Mail, Razorpay SDK, and all other required libraries.

Step 3 – Configure Environment Variables

Create a .env file in the root directory of the project. You can copy the example file if provided:

cp .env.example .env

Open the .env file and fill in the following values:

SECRET_KEY=your-secret-key
JWT_SECRET_KEY=your-jwt-secret
SQLALCHEMY_DATABASE_URI=sqlite:///agri.db

MAIL_SERVER=smtp.gmail.com
MAIL_PORT=587
MAIL_USE_TLS=True
MAIL_USERNAME=your@gmail.com
MAIL_PASSWORD=your-gmail-app-password

RAZORPAY_KEY_ID=rzp_test_xxxxxxxxxxxxxx
RAZORPAY_KEY_SECRET=your-razorpay-secret

OPENWEATHER_API_KEY=your-openweathermap-api-key

FRONTEND_URL=http://localhost:5173

Important: For Gmail, you must use an App Password, not your regular Gmail account password. Generate one from your Google Account security settings under Two-Factor Authentication.

Step 4 – Download the Plant Disease Dataset and Train the Model

The plant disease detection module requires a trained EfficientNetB4 model. Follow these steps:

  1. Download the Plant Disease Dataset from the Google Drive link provided in the project README file.
  2. Place the downloaded dataset inside the dataset/ folder in the root directory.
  3. Open and run the Jupyter Notebook file: Leaf_Deases (1).ipynb
  4. After training is complete, save the trained model as: models/plant_disease_efficientnet.h5

Note: If a pre-trained model file is already included in the project package you purchased, you can skip the training step and directly place the .h5 file in the models/ folder.

Step 5 – Start the Flask Backend Server

Run the backend server using one of the following commands:

Option A – Using Python directly (recommended for development):

python app.py

Option B – Using Flask CLI (recommended for background running):

flask run --host=0.0.0.0 --port=5001 --no-debugger --no-reload

The Flask backend will start and run at: http://localhost:5001

The SQLite database file agri.db will be automatically created on the first run. Do not delete this file while the server is running.

Step 6 – Install and Start the React Frontend

Open a new terminal window, navigate to the frontend folder, and run the following commands:

cd frontend
npm install
npm run dev

The React frontend will start and run at: http://localhost:5173

Important: Keep both the Flask backend terminal and the React frontend terminal running at the same time. Closing either one will break the application.

Step 7 – Open the Application in Your Browser

Once both servers are running, open your web browser and navigate to:

http://localhost:5173

You will see the AgriAdvisor landing page. You can register a new account or use the demo credentials below to log in immediately:

  • Email: demo@agri.com
  • Password: Demo@12345

Step 8 – Testing Razorpay Payments

Razorpay is configured in test mode. To test the payment flow, use the following Razorpay test card details on the checkout screen:

  • Card Number: 4111 1111 1111 1111
  • Expiry: Any future date
  • CVV: Any 3 digits
  • OTP: 1234 (Razorpay test OTP)

No real money will be charged during test mode transactions.

Common Issues and Fixes

  • CORS Error on frontend: Make sure the FRONTEND_URL in your .env file exactly matches the URL where your React app is running, including the port number.
  • Gmail OTP not received: Check that you have used a Gmail App Password and not your regular password. Also check your spam folder.
  • Model file not found error: Ensure the trained .h5 model file is placed inside the models/ directory and the filename matches exactly as referenced in the code.
  • Port already in use: If port 5001 or 5173 is already occupied, change the port in the run command and update the FRONTEND_URL and API base URL accordingly.
  • pip install fails: Try upgrading pip first using: python -m pip install --upgrade pip and then re-run the install command.

Need Help Setting Up?

If you face any difficulty during installation, CodeAj offers a dedicated Project Setup and Source Code Explanation service. Our team will set up the project on your system, walk you through the entire codebase, and answer your questions in a one-on-one session. Visit projects.codeaj.com/project-setup to book this service.

Need Help?

Our team is here to assist you with installation and setup.

Chat with Us
Chat with us