A comprehensive MERN stack application designed to help farmers access government schemes, get instant support through an AI-powered chatbot, and manage their profiles efficiently.
- Features
- Tech Stack
- Prerequisites
- Installation
- Configuration
- Running the Application
- Deployment
- Project Structure
- API Documentation
- Contributing
- License
- AI-Powered Chatbot - Get instant answers to farming-related queries
- WhatsApp Bot Integration - Support via WhatsApp messaging
- Government Schemes - Browse and search government schemes for farmers
- Interactive Maps - Location-based services using Google Maps
- User Authentication - Secure JWT-based authentication with email verification
- User Profiles - Manage personal information and preferences
- Multilingual Support - Available in English and Hindi
- Text-to-Speech - Audio support for accessibility
- File Upload - Cloudinary integration for image uploads
- React 19 - UI library
- React Router v7 - Client-side routing
- Tailwind CSS v4 - Utility-first CSS framework
- Flowbite React - UI components
- Vite - Build tool
- i18next - Internationalization
- Node.js - Runtime environment
- Express 5 - Web framework
- MongoDB - Database
- Mongoose - ODM for MongoDB
- JWT - Authentication
- Cloudinary - File storage
- Google Cloud TTS - Text-to-speech
- SendGrid/Nodemailer - Email service
- LangChain - AI chatbot framework
- ChromaDB - Vector database for chatbot
Before you begin, ensure you have the following installed:
- Node.js (v18 or higher) - Download
- Python (v3.8 or higher) - Required for AI chatbot
- MongoDB Atlas Account - Sign up
- Git - Download
git clone https://github.com/yourusername/farmers-support-platform.git
cd farmers-support-platformcd server
npm installcd ../client/Learning
npm installcd ../../
pip install -r requirements.txtCreate a .env file in the server directory:
cd server
cp .env.example .envEdit the .env file and configure:
# Server Configuration
PORT=3000
# MongoDB Configuration
MONGODB_URL=mongodb+srv://your-username:your-password@your-cluster.mongodb.net
DB_NAME=farmers
# CORS Configuration
CORS_ORIGIN=http://localhost:5173
# JWT Secret (generate using: node -e "console.log(require('crypto').randomBytes(32).toString('hex'))")
JWT_SECRET=your-secure-jwt-secret
# Cloudinary Configuration (https://cloudinary.com)
CLOUDINARY_CLOUD_NAME=your-cloud-name
CLOUDINARY_API_KEY=your-api-key
CLOUDINARY_API_SECRET=your-api-secretMongoDB:
- Go to MongoDB Atlas
- Create a free cluster
- Click "Connect" → "Connect your application"
- Copy the connection string and replace
<password>with your database password
Cloudinary:
- Sign up at Cloudinary
- Go to Dashboard
- Copy Cloud Name, API Key, and API Secret
JWT Secret: Generate a secure random string:
node -e "console.log(require('crypto').randomBytes(32).toString('hex'))"Google Cloud TTS (Optional):
- Create a project in Google Cloud Console
- Enable Text-to-Speech API
- Create a service account and download JSON key
- Place the key file in
server/keys/tts-sa.json
Create a .env file in the client/Learning directory:
cd client/Learning
cp .env.example .envEdit the .env file:
# Google Maps API Key
VITE_API_KEY=your-google-maps-api-key
# Backend API URL
VITE_API_BASE_URL=http://localhost:3000/api/v1Google Maps API:
- Go to Google Cloud Console
- Enable Maps JavaScript API
- Create credentials (API Key)
- Copy the API key
mongodcd server
npm run dev
# Server will start on http://localhost:3000cd client/Learning
npm run dev
# Frontend will start on http://localhost:5173python chatbot_service.pypython whatsapp_bot.pyYou can create a root package.json to run everything together:
{
"scripts": {
"dev": "concurrently \"npm run server\" \"npm run client\"",
"server": "cd server && npm run dev",
"client": "cd client/Learning && npm run dev"
}
}Then run:
npm install -g concurrently
npm run devReady to deploy your application to production? We've prepared a comprehensive deployment guide.
Recommended Stack:
- Frontend: Vercel (Free)
- Backend: Render (Free)
- Database: MongoDB Atlas (Already set up)
-
Deploy Backend to Render
- Sign up at render.com
- Connect your GitHub repository
- Set root directory to
server - Add environment variables
- Deploy!
-
Deploy Frontend to Vercel
- Sign up at vercel.com
- Import your GitHub repository
- Set root directory to
client/Learning - Add environment variables
- Deploy!
-
Update CORS Settings
- Update backend
CORS_ORIGINwith your Vercel URL
- Update backend
The detailed guide includes:
- Step-by-step instructions with screenshots
- Environment variable configuration
- Troubleshooting tips
- Alternative deployment options
- Free tier optimization
farmers-support-platform/
├── server/ # Backend application
│ ├── controllers/ # Request handlers
│ ├── models/ # Mongoose models
│ ├── routes/ # API routes
│ ├── middleware/ # Custom middleware
│ ├── utils/ # Utility functions
│ ├── keys/ # Service account keys (git-ignored)
│ ├── uploads/ # Temporary file uploads (git-ignored)
│ ├── .env # Environment variables (git-ignored)
│ └── package.json # Server dependencies
│
├── client/Learning/ # Frontend application
│ ├── src/
│ │ ├── components/ # React components
│ │ │ ├── Auth/ # Authentication components
│ │ │ ├── Chatbot/ # Chatbot interface
│ │ │ ├── Dashboard/ # Dashboard components
│ │ │ ├── Maps/ # Google Maps components
│ │ │ └── SchemesList/ # Government schemes
│ │ ├── context/ # React Context (Auth, Toast)
│ │ ├── hooks/ # Custom hooks
│ │ ├── config/ # Configuration files
│ │ └── utils/ # Utility functions
│ ├── public/locales/ # i18n translations
│ ├── .env # Environment variables (git-ignored)
│ └── package.json # Client dependencies
│
├── chatbot_service.py # AI chatbot service
├── whatsapp_bot.py # WhatsApp bot integration
├── vector.py # Vector database operations
├── process_schemes.py # Scheme processing utilities
├── requirements.txt # Python dependencies
├── .gitignore # Git ignore rules
└── README.md # This file
POST /api/v1/auth/register
Content-Type: application/json
{
"email": "user@example.com",
"password": "password123",
"name": "John Doe"
}POST /api/v1/auth/login
Content-Type: application/json
{
"email": "user@example.com",
"password": "password123"
}POST /api/v1/auth/forgot-password
Content-Type: application/json
{
"email": "user@example.com"
}GET /api/v1/users/profile
Authorization: Bearer <token>PATCH /api/v1/users/profile
Authorization: Bearer <token>
Content-Type: multipart/form-data
{
"name": "John Doe Updated",
"avatar": <file>
}GET /api/v1/schemesGET /api/v1/schemes/search?q=farmingPOST /api/v1/chatbot/message
Content-Type: application/json
Authorization: Bearer <token>
{
"message": "What are the benefits of organic farming?"
}POST /api/v1/tts/synthesize
Content-Type: application/json
{
"text": "Hello farmer",
"language": "en-US"
}Contributions are welcome! Please follow these steps:
- Fork the repository
- Create a feature branch (
git checkout -b feature/AmazingFeature) - Commit your changes (
git commit -m 'Add some AmazingFeature') - Push to the branch (
git push origin feature/AmazingFeature) - Open a Pull Request
This project is licensed under the ISC License.
- Keshav - Initial work
- Government of India for scheme data
- MongoDB for database services
- Cloudinary for file storage
- Google Cloud for Maps and TTS services
- All contributors who help improve this project
For questions or support, please open an issue on GitHub.
Made with ❤️ for farmers