Skip to content

This project serves as the API for Soilitical, it handles all user requests as well as fetching the ML Model's response and handing it to the frontend

License

Notifications You must be signed in to change notification settings

Soilitical/Soilitical-AI-Api

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

32 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🌱 Soilitical API

Soilitical's API provides an endpoint for interacting with our machine learning model, designed to predict the most suitable crop to grow based on various input parameters. This API is built using Django and offers a single endpoint for receiving the prediction.

🚀 Table of Contents

📦 Installation

1. Clone the Repository

git clone https://github.com/your-repository/soilitical-api.git
cd soilitical-api

2. Install Dependencies

pip install -r requirements.txt

3. Database Setup

python manage.py migrate

🔧 Configuration

1. Environment Variables

Create a .env file in the root directory with the following variables:

# SECURITY_KEY must be a random string
SECURITY_KEY=your-secret-key-here

# DEBUG mode (set to False for production)
DEBUG=True

🚀 API Documentation

1. Make Prediction

  • Endpoint: /predict
  • Method: POST
  • Description: Takes input data to make a prediction using the machine learning model. Returns the predicted class label.

Request Format:

Headers:

Content-Type: application/json

Request Body:

{
	"soil_type": "clayey soil - loamy soil",
	"ec_value": 0.97,
	"temperature": 23.0,
	"n_value": 23.85,
	"p_value": 15.61,
	"k_value": 20.49
}

Example Request:

curl -X POST https://api_example.com/predict \
  -H "Content-Type: application/json" \
  -d '{"soil_type":"clayey soil - loamy soil","ec_value":0.97,"temperature":23.0,"n_value":23.85,"p_value":15.61,"k_value":20.49}'

Example Response:

{
	"prediction": "Mangoes"
}

Error Handling

  • 400 Bad Request: Invalid input format or missing required fields
  • 500 Internal Server Error: Model prediction failed

Prediction Example On Website: (Live at: Soilitical)

Prediction

🎨 Contribution Guidelines

We welcome contributions to improve the API. Please follow these guidelines:

  • Fork the repository and create a new branch.
  • Ensure your code follows best practices and is well-documented.
  • Open a pull request with a detailed description of your changes.

About

This project serves as the API for Soilitical, it handles all user requests as well as fetching the ML Model's response and handing it to the frontend

Topics

Resources

License

Stars

Watchers

Forks

Languages