Skip to content

Durgeshwar-AI/BhuSetu

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

31 Commits
 
 
 
 
 
 
 
 

Repository files navigation

BhuSetu

BhuSetu is a lightweight full-stack application that helps farmers get tailored crop recommendations by analyzing soil images and local weather using generative AI. The project includes a React + Vite TypeScript frontend and a Node.js + Express backend (MongoDB) that integrates with Google Generative AI.

Key features

  • Soil analysis from a base64 image
  • Weather summary for a geographic location
  • JSON-formatted crop recommendations with suitability scores
  • User accounts with JWT authentication and history of past suggestions

Tech stack

  • Frontend: React, TypeScript, Vite, TailwindCSS
  • Backend: Node.js, Express, Mongoose (MongoDB)
  • AI: Google Generative AI (Gemini)

Repository layout

  • client/ — React + Vite frontend
  • server/ — Express API, controllers, routes, services

Prerequisites

  • Node.js (16+ recommended)
  • npm or yarn
  • A MongoDB instance (Atlas or local)
  • Google Generative AI API key

Environment variables (server) Create a .env file in server/ with:

MONGODB_URI=your_mongodb_connection_string
PORT=5000
FRONTEND_URL=http://localhost:5173
JWT_SECRET=your_jwt_secret
API_KEY=your_google_generative_api_key

Defaults used by the app:

  • Frontend dev server: http://localhost:5173 (Vite default)
  • Backend default port: 5000

Getting started (development)

  1. Start the backend
cd server
npm install
# create .env as above
npm run dev   # uses nodemon, or `npm start` to run node index.js
  1. Start the frontend
cd client
npm install
npm run dev

Open the frontend at the Vite URL (usually http://localhost:5173). The frontend communicates with the backend at the FRONTEND_URL/CORS origin set in the server .env.

API overview

  • POST /api/user/register — register a new user

    • Body: { "username": "...", "email": "...", "password": "..." }
    • Returns: { message, token, user }
  • POST /api/user/login — authenticate

    • Body: { "email": "...", "password": "..." }
    • Returns: { message, token, user }
  • GET /api/user/profile — get profile (uses token)

    • Header: Authorization: Bearer <token>
  • POST /api/crop — generate reports & recommendations

    • Body (JSON):
      • soilImage: base64 image string (required)
      • lat, long (coordinates)
      • area, areaType (e.g., hectares, acres)
      • additionalDetails (optional)
    • Header optional: Authorization: Bearer <token> (if present, suggestion saved to user history)
    • Returns: { weatherReport, soilReport, cropRec, message }

Example curl (register):

curl -X POST http://localhost:5000/api/user/register \
	-H "Content-Type: application/json" \
	-d '{"username":"Farmer","email":"farmer@example.com","password":"password"}'

Notes & tips

  • The backend increases JSON payload limits to support large base64 images — be mindful of very large uploads.
  • API_KEY must be a valid Google Generative AI key; the server code uses @google/generative-ai and the gemini-2.5-flash model.
  • Crop recommendations are expected to be returned as strict JSON from the AI; the server parses and transforms that JSON into an array of crop objects.
  • Authentication uses JWT stored client-side (e.g., localStorage) and sent as Authorization: Bearer <token>.

Production

  • Build frontend: from client/ run npm run build and serve the produced dist from a static server or integrate into the backend.
  • For production, ensure JWT_SECRET and API_KEY are strong secrets and MONGODB_URI points to a secure production database.

Contributing

  • Open issues or PRs for bugs and features.
  • Keep changes focused and add docs for new endpoints or env variables.

License

This repository does not include an explicit license file. Add one (e.g., MIT) if you plan to open-source the project.

About

AI-powered agricultural decision support platform that analyzes soil images and location data to provide crop recommendations, soil health reports, and weather intelligence for Indian farmers.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors