Skip to content

Repository files navigation

KrishiSaarthi AI - Smart Farming Advisor

A web application that helps farmers make crop and fertilizer decisions using simple inputs, even without soil reports.


๐Ÿ“ธ Screenshots

๐Ÿ  Main Interface (Home Page)

Home Page

๐Ÿ“Š Farming Advisors

Soil Report Advisor Questionnaire Advisor

๐Ÿ”ฌ Support Services

Soil Testing Labs Government Schemes


๐ŸŒพ Overview

KrishiSaarthi AI is a hackathon-ready farming recommendation system that provides:

  • Crop Recommendations: Suggest top 2-3 crops based on farm conditions
  • Fertilizer Planning: Detailed NPK recommendations with costs
  • Multiple Input Methods: Soil report or simple questionnaire
  • Location-based Guidance: Find nearby soil testing labs
  • Government Schemes: Information on agricultural benefits and subsidies

๐Ÿš€ Features

Core Features

  1. Soil Report Analysis - Upload soil test results (N, P, K, pH) for precise recommendations

  2. Questionnaire Mode - Simple questions for farmers without soil reports

  3. Smart Recommendations:

    • Crop suitability scoring
    • Fertilizer calculation and scheduling
    • Cost optimization suggestions
    • Yield potential estimates
  4. Support Services:

    • Soil testing lab finder with contact details
    • Government schemes information
    • Agricultural best practices guide
    • Cost-saving tips

๐Ÿ“ Project Structure

AstraX_Greentech/
โ”œโ”€โ”€ frontend/                 # React Frontend
โ”‚   โ”œโ”€โ”€ public/
โ”‚   โ”‚   โ””โ”€โ”€ index.html       # HTML template
โ”‚   โ”œโ”€โ”€ src/
โ”‚   โ”‚   โ”œโ”€โ”€ pages/           # Page components
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ Home.js
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ SoilReportAdvisor.js
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ QuestionnaireAdvisor.js
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ SoilTestingLabs.js
โ”‚   โ”‚   โ”‚   โ””โ”€โ”€ GovernmentSchemes.js
โ”‚   โ”‚   โ”œโ”€โ”€ services/        # API services
โ”‚   โ”‚   โ”‚   โ””โ”€โ”€ api.js       # Axios configuration
โ”‚   โ”‚   โ”œโ”€โ”€ styles/          # CSS files
โ”‚   โ”‚   โ”œโ”€โ”€ App.js
โ”‚   โ”‚   โ””โ”€โ”€ index.js
โ”‚   โ””โ”€โ”€ package.json
โ”‚
โ”œโ”€โ”€ backend/                  # Node.js Backend
โ”‚   โ”œโ”€โ”€ routes/              # API routes
โ”‚   โ”‚   โ”œโ”€โ”€ recommendations.js
โ”‚   โ”‚   โ”œโ”€โ”€ soilLabs.js
โ”‚   โ”‚   โ””โ”€โ”€ schemes.js
โ”‚   โ”œโ”€โ”€ services/            # Business logic
โ”‚   โ”‚   โ””โ”€โ”€ recommendationEngine.js
โ”‚   โ”œโ”€โ”€ data/                # Mock data
โ”‚   โ”‚   โ”œโ”€โ”€ soilLabs.js
โ”‚   โ”‚   โ””โ”€โ”€ schemes.js
โ”‚   โ”œโ”€โ”€ server.js            # Express server
โ”‚   โ”œโ”€โ”€ package.json
โ”‚   โ””โ”€โ”€ .env.example
โ”‚
โ””โ”€โ”€ README.md

๐Ÿ› ๏ธ Tech Stack

Frontend:

  • React 18
  • React Router DOM
  • Axios (HTTP client)
  • CSS3 (Responsive Design)

Backend:

  • Node.js
  • Express.js
  • CORS
  • dotenv

โš™๏ธ Installation & Setup

1. Clone the Repository

git clone https://github.com/ankitkumar764/AstraX_Greentech.git
cd AstraX_Greentech

2. Backend Setup

# Navigate to backend directory
cd backend

# Install dependencies
npm install

# Create .env file
copy .env.example .env

# Start the backend server
npm run dev
# Backend runs on http://localhost:5000

3. Frontend Setup (in new terminal)

# Navigate to frontend directory
cd frontend

# Install dependencies
npm install

# Start the development server
npm start
# Frontend opens at http://localhost:3000

๐ŸŽฏ Usage Guide

Soil Report Mode

  1. Click on "๐Ÿ“Š Soil Report" from navigation
  2. Enter your soil test parameters (N, P, K, pH)
  3. Select your crop and budget
  4. Get detailed fertilizer recommendations

Questionnaire Mode

  1. Click on "โ“ Questionnaire"
  2. Answer simple questions about your farm
  3. Receive top 3 crop recommendations with fertilizer plans

Other Features

  • Soil Testing Labs: Find nearby labs with contact details
  • Government Schemes: Browse agricultural subsidies and benefits
  • Testing Guide: Learn how to collect soil samples

๐Ÿ“Š API Endpoints

Recommendations

POST /api/recommendations/get
POST /api/recommendations/soil-report

Soil Labs

GET /api/soil-labs/:state
GET /api/soil-labs

Government Schemes

GET /api/schemes/list
GET /api/schemes/category/:category

๐ŸŽ“ Supported Crops

  • Wheat (Rabi)
  • Rice (Kharif)
  • Maize (Kharif/Rabi)
  • Cotton (Kharif)
  • Sugarcane (Kharif/Rabi)
  • Pulses (Rabi)
  • Vegetables (Year-round)

๐Ÿงฎ How Recommendations Work

  1. Crop Scoring: Algorithm evaluates soil type, season, pH, water needs, and budget
  2. Fertilizer Calculation: Determines NPK deficit and calculates optimal fertilizer mix
  3. Cost Optimization: Provides cost-saving suggestions and government scheme info

๐Ÿ“‹ Fertilizer Types

Fertilizer N% P% K% Cost/50kg
Urea 46 0 0 โ‚น250
DAP 18 46 0 โ‚น1100
MOP 0 0 60 โ‚น600
Neem 3 1 1 โ‚น400

๐Ÿ” Environment Variables

Create .env in backend directory:

PORT=5000
NODE_ENV=development
FRONTEND_URL=http://localhost:3000

๐Ÿ“ฑ Example API Responses

Soil Report API

{
  "success": true,
  "crop": "wheat",
  "soilAnalysis": {
    "nitrogen": 200,
    "phosphorus": 20,
    "potassium": 150,
    "pH": 6.8
  },
  "fertilizerPlan": {
    "recommendations": [
      {
        "name": "DAP",
        "bags": 2,
        "timing": "At planting",
        "cost": 2200
      }
    ],
    "totalCost": 3500
  }
}

๐Ÿš€ Deployment

The project is actively deployed and accessible at:

Backend (Render)

The backend runs on Render with automatic deployments enabled for pushes to the main branch.

Frontend (Vercel)

cd frontend
npm run build
vercel --prod

๐Ÿ”„ Extending the System

Add New Crops

Edit backend/services/recommendationEngine.js and add to cropDatabase

Add States in Soil Labs

Edit backend/data/soilLabs.js

Add Government Schemes

Edit backend/data/schemes.js

๐Ÿ› Troubleshooting

Backend not running:

  • Ensure Node.js is installed: node --version
  • Run npm install in backend folder
  • Check port 5000 is free

Frontend API errors:

  • Verify backend is running
  • Check REACT_APP_API_URL in frontend .env
  • Open browser console for error messages

Port in use:

# Windows
netstat -ano | findstr :5000
taskkill /PID <PID> /F

# Linux/Mac
lsof -i :5000
kill -9 <PID>

๐Ÿ“ž Support

For issues or questions, check:

  1. Troubleshooting section above
  2. Browser console (F12)
  3. Backend terminal logs

๐ŸŽฏ Future Enhancements

  • Database integration (MongoDB)
  • User authentication
  • Real crop price updates
  • Weather-based recommendations
  • Mobile app
  • Multi-language support
  • Plant disease detection
  • Historical yield tracking

Made with ๐ŸŒฑ for Indian Farmers

About

KrishiSaarthi AI is a smart farming advisor that helps farmers make crop and fertilizer decisions using soil data or simple inputs, enabling better yield, cost optimization, and sustainable farming.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages