An AI powered software to predict the yeild of different crops based on weather and soil conditions
  • Jupyter Notebook 99.1%
  • Python 0.9%
Find a file
2026-02-13 00:00:24 +05:30
backend updated 2026-02-11 20:15:19 +05:30
frontend containerised the application 2026-01-30 20:06:48 +05:30
.gitignore containerised the application 2026-01-30 20:06:48 +05:30
compose.yml containerised the application 2026-01-30 20:06:48 +05:30
README.md added readme 2026-02-13 00:00:24 +05:30

🌾 Crop Yield Prediction System

Logo

GitHub stars

GitHub forks

GitHub issues

GitHub license

An AI-powered software to predict the yield of different crops based on weather and soil conditions.

Live Demo | Documentation

📖 Overview

This project is an advanced AI-powered application designed to assist farmers and agricultural professionals in making informed decisions by accurately predicting crop yields. By leveraging machine learning models, it analyzes various environmental factors such as weather patterns and soil conditions to forecast the expected harvest. The system comprises a user-friendly web interface (frontend) for inputting data and visualizing results, backed by a robust API (backend) that houses the predictive AI model. The entire application is containerized with Docker, ensuring easy setup, scalability, and consistent deployment across different environments.

Features

  • 🎯 AI-Powered Crop Yield Prediction: Utilizes advanced machine learning models to provide accurate yield forecasts.
  • 🧑‍💻 Intuitive Web Interface: A user-friendly frontend allows for easy input of weather and soil data.
  • 📊 Data-Driven Insights: Provides predictions based on comprehensive analysis of environmental conditions.
  • 🌐 API-Driven Backend: A dedicated backend service exposes prediction capabilities via a RESTful API.
  • 🐳 Containerized Deployment: Entire application packaged with Docker and orchestrated via Docker Compose for seamless setup and portability.
  • ⚙️ Modular Architecture: Separate frontend and backend services facilitate independent development and maintenance.

🖥️ Screenshots

Screenshot 1

Screenshot 2

🛠️ Tech Stack

Frontend:

HTML5

CSS3

JavaScript

Web Framework

Backend (AI/ML & API):

Python

ML Framework

Web Framework

DevOps & Containerization:

Docker

Docker Compose

Database:

Database

🚀 Quick Start

Follow these steps to get the Crop Yield Prediction system up and running on your local machine.

Prerequisites

Before you begin, ensure you have the following installed:

  • Git: For cloning the repository.
  • Docker: For containerizing the application services.
  • Docker Compose: For orchestrating the multi-container application.

Installation

  1. Clone the repository

    git clone https://github.com/shrishjay/Crop-Yeild-Prediction.git
    cd Crop-Yeild-Prediction
    
  2. Build and start the services The compose.yml file will build the necessary Docker images and start both the frontend and backend services.

    docker compose up --build
    

    This command will:

    • Build the Docker image for the frontend service.
    • Build the Docker image for the backend (AI/ML) service.
    • Start both services, making them accessible on their configured ports.
  3. Environment setup (if applicable for specific services) Individual services (frontend/backend) might require .env files for configuration, usually based on an .env.example file within their respective directories.

    # Example for backend service, if it has .env.example
    cp backend/.env.example backend/.env
    # Configure variables inside backend/.env
    
    # Example for frontend service, if it has .env.example
    cp frontend/.env.example frontend/.env
    # Configure variables inside frontend/.env
    

    Note: The compose.yml might also pass environment variables directly to containers, reducing the need for .env files in some cases.

  4. Database setup (if applicable) If a database service is included or configured by compose.yml, it will be set up automatically. For manual database migrations or setup, you might need to execute commands within the backend container.

    # Example: Running migrations in the backend container
    # docker compose exec backend python manage.py migrate
    
  5. Open your browser Once the services are up, the frontend application should be accessible. Visit http://localhost:[detected_frontend_port] (e.g., http://localhost:3000 or http://localhost:80).

📁 Project Structure

Crop-Yeild-Prediction/
├── .gitignore          # Specifies intentionally untracked files to ignore
├── backend/            # Contains the Python backend code and AI/ML models
│   ├── Dockerfile      # Dockerfile for building the backend service image
│   ├── requirements.txt# Python dependencies
│   ├── main.py         # Main entry point for the backend API
│   └── models/         # Directory for trained ML models, if applicable
├── compose.yml         # Docker Compose configuration file for multi-service setup
└── frontend/           # Contains the web application's frontend code
    ├── Dockerfile      # Dockerfile for building the frontend service image
    ├── package.json    # Frontend dependencies and scripts (for Node.js ecosystem)
    ├── src/            # Source code for the frontend application
    └── public/         # Static assets for the frontend

⚙️ Configuration

Environment Variables

Both frontend and backend services might rely on environment variables for sensitive data (API keys, database credentials) or configuration settings.

| Variable | Description | Default | Required |

|----------|-------------|---------|----------|

| FRONTEND_API_URL | Base URL for the backend API from the frontend. | http://backend:5000 | Yes |

| BACKEND_PORT | Port on which the backend service listens. | 5000 | Yes |

| DATABASE_URL | Connection string for the database. | sqlite:///db.sqlite | No |

| API_KEY | Example API key for external services. | None | No |

Configuration Files

  • compose.yml: Defines the services, networks, and volumes for the Dockerized application.
  • backend/Dockerfile: Instructions for building the backend Docker image.
  • frontend/Dockerfile: Instructions for building the frontend Docker image.
  • backend/requirements.txt: Lists Python dependencies for the backend.
  • frontend/package.json: Lists Node.js dependencies and scripts for the frontend.

🔧 Development

For focused development on individual services outside of the full Docker Compose setup, you can follow these general steps:

Backend Development (Python)

  1. Navigate into the backend directory: cd backend
  2. Install Python dependencies: pip install -r requirements.txt
  3. Run the backend development server: python main.py (or similar command depending on the framework, e.g., flask run or uvicorn main:app --reload).

Frontend Development (JavaScript Framework)

  1. Navigate into the frontend directory: cd frontend
  2. Install Node.js dependencies: npm install (or yarn install, pnpm install)
  3. Start the frontend development server: npm run dev (or yarn dev, pnpm dev, npm start).

Available Scripts (within package.json for frontend, Makefile or similar for backend)

| Command (Frontend) | Description |

|--------------------|-------------|

| npm run dev | Starts the development server with hot-reloading. |

| npm run build | Compiles the application for production deployment. |

| npm test | Runs unit and integration tests. |

🧪 Testing

To run tests for the application:


# Example: Run backend tests
docker compose exec backend pytest

# Example: Run frontend tests
docker compose exec frontend npm test

Note: Specific test commands depend on the testing frameworks configured within the backend and frontend services.

🚀 Deployment

The compose.yml file is designed for both local development and can serve as a foundation for production deployments.

Production Build

To create optimized production builds for the individual services:


# Example for frontend (run from within the frontend container or local setup)
cd frontend
npm run build

# Example for backend (Docker build is typically optimized by default)

Deployment Options

  • Docker Compose: The provided compose.yml can be used to deploy the application on a single server with Docker.
  • Container Orchestration: For larger-scale deployments, the Docker images built by docker compose build can be deployed to Kubernetes, AWS ECS, Google Cloud Run, or other container orchestration platforms.

📚 API Reference

The backend service provides a RESTful API for interacting with the crop yield prediction model.

Base URL

http://localhost:[backend_port]/api/v1

Endpoints

POST /predict

Submits weather and soil data to get a crop yield prediction.

Parameters:

| Name | Type | Description | Required |

|------|------|-------------|----------|

| temperature | number | Average temperature in Celsius. | Yes |

| humidity | number | Average relative humidity in percentage. | Yes |

| rainfall | number | Total rainfall in mm. | Yes |

| soil_type | string | Type of soil (e.g., "loamy", "sandy"). | Yes |

| crop_type | string | Type of crop for prediction. | Yes |

Example Request:

POST /predict
Content-Type: application/json

{
  "temperature": 25.5,
  "humidity": 70,
  "rainfall": 1200,
  "soil_type": "loamy",
  "crop_type": "wheat"
}

Example Response:

HTTP/1.1 200 OK
Content-Type: application/json

{
  "crop_type": "wheat",
  "predicted_yield": 5.2,
  "unit": "tons/hectare"
}

🤝 Contributing

We welcome contributions to enhance the Crop Yield Prediction System! Please follow these guidelines:

  1. Fork the repository.
  2. Create a new branch for your feature or bug fix.
  3. Implement your changes, ensuring they adhere to the project's coding standards.
  4. Write comprehensive tests for your changes.
  5. Commit your changes with clear, descriptive messages.
  6. Push your branch and open a Pull Request.

Please see our Contributing Guide for more detailed instructions.

Development Setup for Contributors

Ensure you have Docker and Docker Compose installed. You can run docker compose up --build to get the entire environment running. For individual service development, refer to the "Development" section above.

📄 License

This project is licensed under the LICENSE_NAME - see the LICENSE file for details.

🙏 Acknowledgments

  • Built upon the powerful capabilities of Python and its machine learning ecosystem.
  • Powered by modern web technologies for an interactive user experience.
  • Containerized with Docker and Docker Compose for robust deployment.
  • Inspired by the need for data-driven agriculture.

📞 Support & Contact


Star this repo if you find it helpful!

Made with ❤️ by shrishjay