AI-Based Farmer Query Support and Advisory System - A comprehensive platform that provides farmers with expert agricultural advice through AI-powered conversations.
Digital Krishi Officer is an intelligent agricultural advisory system designed to help farmers get instant expert advice on:
- Pest Management - Identify and control agricultural pests
- Disease Control - Diagnose and treat crop diseases
- Fertilizer Advice - Optimize fertilizer usage for better yields
- Weather Guidance - Make weather-informed farming decisions
- Crop Planning - Plan seasonal crops and rotations
- Market Information - Get current market prices and trends
- Government Schemes - Access information about agricultural subsidies and programs
- AI-Powered Chat - Instant responses using Google Gemini 2.5 Flash Lite
- Real-time Streaming - Live AI responses with WebSocket support
- Multi-language Support - English, Malayalam, and Hindi
- Image Upload - Upload crop/pest images for visual analysis
- Conversation History - Persistent chat threads and message history
- User Authentication - Secure JWT-based authentication
- Responsive Design - Works seamlessly on desktop and mobile
- Real-time Communication - Socket.io for live updates
- Dark Mode Support - Automatic theme switching
- Offline Capability - Progressive Web App features
- Data Security - Encrypted passwords and secure API endpoints
- Scalable Architecture - Microservices-ready backend design
- Runtime: Node.js with Express.js
- Database: MongoDB with Mongoose ODM
- AI Integration: OpenRouter with Google Gemini 2.5 Flash Lite
- Authentication: JWT with bcryptjs
- Real-time: Socket.io
- Logging: Winston
- Validation: Express-validator
- Framework: React 19 with Vite
- Styling: Tailwind CSS 4
- State Management: Zustand + Context API
- Routing: React Router v6
- Forms: React Hook Form
- UI Components: Lucide React icons
- Notifications: React Hot Toast
SIH/
βββ backend/
β βββ config/ # Database and OpenRouter configuration
β βββ controllers/ # Route controllers
β βββ middleware/ # Authentication and error handling
β βββ models/ # MongoDB schemas
β βββ routes/ # API routes
β βββ utils/ # Utility functions
β βββ logs/ # Application logs
β βββ server.js # Main server file
β βββ package.json # Backend dependencies
βββ frontend/
β βββ src/
β β βββ components/ # Reusable UI components
β β βββ context/ # React context providers
β β βββ pages/ # Page components
β β βββ services/ # API service functions
β β βββ main.jsx # Application entry point
β βββ public/ # Static assets
β βββ package.json # Frontend dependencies
βββ .env.example # Environment variables template
βββ README.md # Project documentation
- Node.js (v18 or higher)
- MongoDB (local or cloud)
- OpenRouter API key
-
Navigate to backend directory
cd backend -
Install dependencies
npm install
-
Environment Configuration
cp .env.example .env
Update
.envwith your configuration:MONGODB_URI=mongodb://localhost:27017/sih-farmer-advisory JWT_SECRET=your-super-secret-jwt-key OPENROUTER_API_KEY=your-openrouter-api-key FRONTEND_URL=http://localhost:5173
-
Start the server
# Development mode npm run dev # Production mode npm start
-
Navigate to frontend directory
cd frontend -
Install dependencies
npm install
-
Environment Configuration
cp .env.example .env
Update
.envwith your configuration:VITE_API_BASE_URL=http://localhost:5000/api VITE_SOCKET_URL=http://localhost:5000
-
Start the development server
npm run dev
-
Access the application Open http://localhost:5173 in your browser
{
username: String,
email: String,
password: String (encrypted),
profile: {
firstName: String,
lastName: String,
location: String,
farmSize: String,
cropTypes: [String],
experience: String
},
createdOn: Date,
updatedOn: Date
}{
userId: ObjectId,
title: String,
category: String,
status: String,
messageCount: Number,
createdOn: Date,
updatedOn: Date
}{
threadId: ObjectId,
userId: ObjectId,
role: String, // 'user' | 'assistant'
content: String,
metadata: {
model: String,
tokens: Object,
processingTime: Number
},
createdOn: Date,
updatedOn: Date
}POST /api/auth/register- User registrationPOST /api/auth/login- User loginGET /api/auth/me- Get user profilePOST /api/auth/logout- User logout
GET /api/threads- Get user threadsPOST /api/threads- Create new threadGET /api/chat/history/:threadId- Get chat historyPOST /api/chat/stream- Stream AI chat response
GET /api/users/profile- Get user profilePUT /api/users/profile- Update user profileGET /api/users/stats- Get user statistics
- Set up MongoDB Atlas or local MongoDB
- Configure environment variables
- Deploy to platforms like Heroku, Railway, or DigitalOcean
- Set up SSL certificates for HTTPS
- Build the production bundle:
npm run build - Deploy to platforms like Vercel, Netlify, or AWS S3
- Configure environment variables for production
- Fork the repository
- Create a feature branch:
git checkout -b feature/amazing-feature - Commit your changes:
git commit -m 'Add amazing feature' - Push to the branch:
git push origin feature/amazing-feature - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
- Agricultural Experts - Domain knowledge and advisory content
- AI/ML Engineers - AI model integration and optimization
- Full Stack Developers - Application development and deployment
- UI/UX Designers - User interface and experience design
For support and questions:
- Email: support@digitalkrishi.com
- Phone: +91-1234567890
- GitHub Issues: Create an issue
- OpenRouter for AI model access
- MongoDB for database services
- All the farmers who provided feedback and requirements
- Open source community for the amazing tools and libraries
Digital Krishi Officer - Empowering farmers with AI-powered agricultural expertise πΎ