FarmHelp is a web-based platform designed to empower farmers with real-time, personalized, and localized farming support. The backend of FarmHelp is built using Python and Flask, providing various APIs to deliver agricultural expertise and support to farmers.
The FarmHelp backend includes the following features:
-
Weather Data API
- Retrieves weather data for a specific city and provides a summary including temperature, humidity, wind speed, rain chance, and forecast.
-
Farming Insights API
- Analyzes weather data and provides farming-specific insights such as best farming practices, irrigation techniques, pest and disease risks, and weather-related farming risks.
-
Crop Image Analysis API
- Analyzes uploaded crop images to detect diseases and provides treatment recommendations using AI.
-
Price Prediction API
- Predicts crop prices based on input data such as day of the year, minimum price, and maximum price.
-
AI Chat API
- A chatbot that answers farming queries and provides guidance in real-time.
-
Weather Prediction API
- Predicts weather for a specific city for the next three days using AI.
To set up the FarmHelp backend locally, follow these steps:
-
Clone the repository:
git clone https://github.com/rishabhrawat05/FarmHelpBackend.git
-
Navigate to the project directory:
cd FarmHelpBackend
-
Create and activate a virtual environment:
python -m venv venv source venv/bin/activate # On Windows use `venv\Scripts\activate`
-
Install the required dependencies:
pip install -r requirements.txt
-
Set up environment variables:
Create a
.env
file in the project root and add the following environment variables:GEN_API_KEY=your_genai_api_key API_KEY=your_weather_api_key
-
Download the machine learning model:
The model is downloaded automatically when the application is started.
To run the FarmHelp backend, use the following command:
python main.py
The backend will be available at http://0.0.0.0:5000
.
-
Weather Data API
- Endpoint:
/weather
- Method:
POST
- Payload:
{ "city": "city_name" }
- Response: Weather summary for the specified city.
- Endpoint:
-
Farming Insights API
- Endpoint:
/farming-insights
- Method:
POST
- Payload:
{ "city": "city_name", "weather_summary": "summary", "language": "language" }
- Response: Farming-specific insights based on the weather data.
- Endpoint:
-
Crop Image Analysis API
- Endpoint:
/analyze-crop
- Method:
POST
- Payload: Image file and
language
in form data. - Response: Disease analysis and treatment recommendations for the uploaded crop image.
- Endpoint:
-
Price Prediction API
- Endpoint:
/predict
- Method:
POST
- Payload:
{ "dayOfYear": int, "minPrice": float, "maxPrice": float }
- Response: Predicted crop price.
- Endpoint:
-
AI Chat API
- Endpoint:
/chat
- Method:
POST
- Payload:
{ "message": "user_message" }
- Response: Response from the chatbot.
- Endpoint:
-
Weather Prediction API
- Endpoint:
/predict-weather
- Method:
POST
- Payload:
{ "city": "city_name" }
- Response: Weather prediction for the next three days.
- Endpoint:
We welcome contributions from the community! To contribute to this project, follow these steps:
- Fork the repository.
- Make your changes and commit them.
- Send a pull request with a description of your changes.
For any questions or further information, you can reach out to the project maintainer.