AI-powered crop disease diagnosis backend using Google Gemini Vision API and IPFS storage.
- AI Image Analysis - Diagnose crop diseases using Gemini Vision API
- AI Chatbot - Agricultural advisor powered by Gemini Pro
- IPFS Storage - Decentralized image storage via NFT.Storage
- Blockchain Ready - Returns IPFS CIDs for on-chain storage
GET /health
Returns server status.
POST /analyze
Body: {
"imageBase64": "data:image/jpeg;base64,...",
"plantType": "Tomato" (optional)
}
Returns diagnosis, confidence, and IPFS CID.
POST /chat
Body: {
"message": "How do I treat early blight?",
"context": "Tomato plant with brown spots" (optional)
}
Returns AI agricultural advice.
-
Install dependencies
npm install
-
Configure environment variables
cp env.example .env
Edit
.envand add:GEMINI_API_KEY- Your Google Gemini API keyIPFS_API_KEY- Your NFT.Storage API key (optional)
-
Run locally
npm start # or for development npm run dev -
Test
curl http://localhost:3000/health
This backend is configured for Vercel deployment:
- Push to GitHub
- Import to Vercel
- Set environment variables in Vercel dashboard
- Deploy!
See ../DEPLOY_TO_VERCEL.md for detailed instructions.
GEMINI_API_KEY- Required for AI analysisIPFS_API_KEY- Optional, for IPFS storagePORT- Server port (default: 3000)NODE_ENV- Environment (production/development)
- Express.js - Web framework
- Google Gemini AI - Vision and chat models
- NFT.Storage - IPFS storage
- CORS - Cross-origin support
MIT