Empowering farmers with direct consumer access—bringing fresh, organic, and locally grown produce straight to your home.
- About
- Features
- Tech Stack
- Project Structure
- Getting Started
- Environment Variables
- API Endpoints
- Color Palette
- Contributing
- License
FarmerHub is a full-stack web application that bridges the gap between local farmers and consumers. It provides a platform where farmers can list their fresh produce, and consumers can purchase directly from them—ensuring fair prices for farmers and fresh, organic products for consumers.
The platform features three distinct user roles:
- Users (Consumers): Browse and purchase fresh produce
- Sellers (Farmers): List products, manage orders, and use AI-powered crop assistance
- Admins: Manage platform operations, verify sellers, and oversee all activities
- 🛒 Marketplace - Browse and search fresh produce from local farmers
- 🛍️ Shopping Cart - Add products and manage purchases
- ❤️ Wishlist - Save favorite products for later
- 📦 Order Tracking - Track order status in real-time
- 💬 Support System - Submit tickets and get help
- 📊 Dashboard Overview - Sales analytics and order statistics
- 📝 Product Management - Add, edit, and delete product listings
- 📋 Order Management - View and update order status
- 🤖 CropSense AI - AI-powered crop health analysis and farming tips
- 👤 Profile Management - Update business information and settings
- 👥 User Management - Manage all users and sellers
- ✅ Seller Verification - Verify farmer accounts
- 📈 Platform Analytics - Overview of platform metrics
- 🎫 Support Tickets - Handle customer support requests
- 📧 Email Verification - Secure account verification via email
- 🔑 Password Reset - Forgot password recovery flow
- 🍪 JWT Authentication - Secure token-based authentication
- 🛡️ Role-Based Access Control - Protected routes by user role
- 🎥 Video Tutorials - Agricultural educational content
- 🎧 Audiobooks - Listen to farming guides and tips
- 🔍 Searchable Content - Find resources by category
| Technology | Purpose |
|---|---|
| React 18 | UI Framework |
| Vite | Build Tool & Dev Server |
| Tailwind CSS | Styling |
| Framer Motion | Animations |
| React Router v6 | Routing |
| Zustand | State Management |
| React Three Fiber | 3D Graphics (Homepage) |
| Axios | HTTP Client |
| React Hot Toast | Notifications |
| Lucide React | Icons |
| Recharts | Charts & Analytics |
| Leaflet | Maps Integration |
| Technology | Purpose |
|---|---|
| Node.js | Runtime Environment |
| Express.js | Web Framework |
| MongoDB | Database |
| Mongoose | ODM |
| JWT | Authentication |
| Bcrypt.js | Password Hashing |
| Nodemailer | Email Service |
| Cloudinary | Image Storage |
| Google Generative AI | AI Features |
| Express File Upload | File Handling |
SAI/
├── 📂 backend/
│ ├── 📂 config/ # Configuration files
│ │ ├── cloudinary.js # Cloudinary setup
│ │ └── emailConfig.js # Email configuration
│ ├── 📂 controllers/ # Route controllers
│ │ ├── admin.controller.js
│ │ ├── ai.controller.js
│ │ ├── auth.controller.js
│ │ ├── order.controller.js
│ │ ├── product.controller.js
│ │ ├── support.controller.js
│ │ ├── upload.controller.js
│ │ └── wishlist.controller.js
│ ├── 📂 db/ # Database connection
│ │ └── connectDB.js
│ ├── 📂 mailer/ # Email templates & service
│ │ ├── emailTemplate.js
│ │ └── mail.js
│ ├── 📂 middleware/ # Express middleware
│ │ ├── upload.middleware.js
│ │ ├── verifyAdmin.js
│ │ └── verifyAuth.js
│ ├── 📂 models/ # Mongoose models
│ │ ├── account.model.js
│ │ ├── order.model.js
│ │ ├── product.model.js
│ │ └── support.model.js
│ ├── 📂 routes/ # API routes
│ ├── 📂 utils/ # Utility functions
│ ├── index.js # Server entry point
│ └── package.json
│
├── 📂 frontend/
│ ├── 📂 public/
│ │ └── 📂 assets/ # Static assets
│ ├── 📂 src/
│ │ ├── 📂 components/ # React components
│ │ │ ├── 📂 admin/ # Admin components
│ │ │ ├── 📂 seller/ # Seller components
│ │ │ └── 📂 user/ # User components
│ │ ├── 📂 layouts/ # Layout components
│ │ ├── 📂 pages/ # Page components
│ │ ├── 📂 store/ # Zustand stores
│ │ ├── 📂 utils/ # Utility functions
│ │ ├── App.jsx # Main app component
│ │ ├── main.jsx # Entry point
│ │ └── index.css # Global styles
│ ├── index.html
│ ├── tailwind.config.js
│ ├── vite.config.js
│ └── package.json
│
├── package.json # Root package.json
└── README.md
- Node.js (v18 or higher)
- npm or yarn
- MongoDB (local or Atlas)
- Cloudinary account
- Gmail account (for email service)
-
Clone the repository
git clone https://github.com/anupamraj176/SAI.git cd SAI -
Install backend dependencies
cd backend npm install -
Install frontend dependencies
cd ../frontend npm install -
Set up environment variables (see Environment Variables)
-
Start the development servers
Backend (from
/backenddirectory):npm run dev
Frontend (from
/frontenddirectory):npm run dev
-
Open your browser
- Frontend:
http://localhost:5173 - Backend API:
http://localhost:5001
- Frontend:
Create a .env file in the /backend directory:
# Server
PORT=5001
NODE_ENV=development
# MongoDB
MONGO_URI=your_mongodb_connection_string
# JWT
JWT_SECRET=your_jwt_secret_key
# Cloudinary
CLOUDINARY_CLOUD_NAME=your_cloudinary_cloud_name
CLOUDINARY_API_KEY=your_cloudinary_api_key
CLOUDINARY_API_SECRET=your_cloudinary_api_secret
# Email (Gmail)
EMAIL_USER=your_gmail_address
EMAIL_PASS=your_gmail_app_password
# Google AI (for CropSense AI feature)
GOOGLE_AI_KEY=your_google_generative_ai_key
# Frontend URL (for CORS)
CLIENT_URL=http://localhost:5173| Method | Endpoint | Description |
|---|---|---|
| POST | /api/auth/signup |
Register new user |
| POST | /api/auth/login |
Login user |
| POST | /api/auth/logout |
Logout user |
| POST | /api/auth/verify-email |
Verify email |
| POST | /api/auth/forgot-password |
Request password reset |
| POST | /api/auth/reset-password/:token |
Reset password |
| GET | /api/auth/check-auth |
Check authentication status |
| Method | Endpoint | Description |
|---|---|---|
| GET | /api/products |
Get all products |
| GET | /api/products/:id |
Get product by ID |
| POST | /api/products |
Create product (Seller) |
| PUT | /api/products/:id |
Update product (Seller) |
| DELETE | /api/products/:id |
Delete product (Seller) |
| Method | Endpoint | Description |
|---|---|---|
| GET | /api/orders |
Get user orders |
| GET | /api/orders/seller |
Get seller orders |
| POST | /api/orders |
Create order |
| PUT | /api/orders/:id/status |
Update order status |
| Method | Endpoint | Description |
|---|---|---|
| GET | /api/support |
Get support tickets |
| POST | /api/support |
Create support ticket |
| Method | Endpoint | Description |
|---|---|---|
| POST | /api/ai/analyze |
Analyze crop image |
| Method | Endpoint | Description |
|---|---|---|
| GET | /api/admin/users |
Get all users |
| PUT | /api/admin/verify-seller/:id |
Verify seller |
FarmerHub uses a nature-inspired green color palette that reflects its agricultural theme:
Contributions are welcome! Please feel free to submit a Pull Request.
- Fork the repository
- Create your 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.
Anupam Raj
- GitHub: @anupamraj176
🌾 FarmerHub - Connecting Farms to Families 🏠
Made with ❤️ for farmers everywhere









