https://github.com/debabrataghoosh/agrotrade-fullstack-project
AgroTrade is a full-featured agri-commerce platform connecting Indian farmers, sellers, and buyers. Features include crop listings, seller portals, real-time chat, order management, and multilingual support. Built with Next.js 15, Tailwind CSS v4, Clerk Auth, MongoDB Atlas, Socket.IO, and Stripe. Deployed on Vercel + Render.
https://github.com/debabrataghoosh/agrotrade-fullstack-project
aggricultureanalysis clerk ecommerce-website mongodb-atlas nextjs15 real-time-chat render socket-io stripe tailwindcss-v4 vercel-deployment
Last synced: about 2 months ago
JSON representation
AgroTrade is a full-featured agri-commerce platform connecting Indian farmers, sellers, and buyers. Features include crop listings, seller portals, real-time chat, order management, and multilingual support. Built with Next.js 15, Tailwind CSS v4, Clerk Auth, MongoDB Atlas, Socket.IO, and Stripe. Deployed on Vercel + Render.
- Host: GitHub
- URL: https://github.com/debabrataghoosh/agrotrade-fullstack-project
- Owner: debabrataghoosh
- Created: 2025-07-07T09:44:22.000Z (3 months ago)
- Default Branch: main
- Last Pushed: 2025-08-14T11:11:14.000Z (2 months ago)
- Last Synced: 2025-08-14T12:25:36.059Z (2 months ago)
- Topics: aggricultureanalysis, clerk, ecommerce-website, mongodb-atlas, nextjs15, real-time-chat, render, socket-io, stripe, tailwindcss-v4, vercel-deployment
- Language: TypeScript
- Homepage: https://agrotrade-blush.vercel.app
- Size: 75.1 MB
- Stars: 3
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# πΎ AgroTrade - Complete Agri-Commerce Platform
**AgroTrade** is a modern, production-ready agri-commerce platform built to empower Indian farmers, sellers, and buyers. The platform supports direct crop trading, real-time buyer-seller chat, secure checkout, product management, and multilingual support β all through a seamless web experience.
---
## π Live Demo & Production URLs
### **π Production Deployment**
- **Main Application**: [https://agrotrade-ebrbvlkmi-debabrata-ghoshs-projects.vercel.app](https://agrotrade-ebrbvlkmi-debabrata-ghoshs-projects.vercel.app)
- **Socket Server**: [https://agrotrade-fullstack-project.onrender.com](https://agrotrade-fullstack-project.onrender.com)
- **GitHub Repository**: [https://github.com/debabrataghoosh/AgroTrade-fullstack-project](https://github.com/debabrataghoosh/AgroTrade-fullstack-project)---
## β¨ Complete Feature Set
### π **Homepage & User Experience**
- **Modern UI/UX** with Tailwind CSS v4
- **Location selector** for regional product discovery
- **Advanced search** with category filtering
- **Multilingual support** (Bengali, Hindi, Tamil, etc.)
- **"Become a Seller"** onboarding with benefits
- **Dynamic product sections**:
- New Products
- Popular Products
- Featured Products
- **User authentication** via Clerk
- **Wishlist management**
- **Real-time chat integration**### π§βπΎ **Seller Portal & Dashboard**
- **Secure authentication** via Clerk
- **Product management** with image uploads
- **Live/unlive toggle** for product visibility
- **Order management** with buyer addresses
- **Real-time chat** for bulk order negotiation
- **Sales analytics** and performance tracking
- **Product editing** and inventory management
- **Settings management**### π **Buyer Experience & E-commerce**
- **Product browsing** with advanced filters
- **Secure checkout** via Stripe integration
- **Real-time chat** with sellers
- **Order tracking** and history
- **Wishlist management**
- **Address management**
- **Payment options** (Stripe + COD)
- **Order success** and confirmation### π¬ **Real-Time Communication System**
- **Instant messaging** between buyers and sellers
- **Product-specific chat rooms**
- **Real-time notifications**
- **Message history** and persistence
- **File sharing** capabilities
- **Socket.IO integration** with Render hosting---
## π **Complete Tech Stack & Dependencies**
### **π Frontend Framework**
- **Next.js 15.3.4** with App Router and Turbopack
- **React 19.0.0** with latest features
- **TypeScript 5.8.3** for type safety
- **Tailwind CSS v4** for modern design system### **π¨ UI/UX Libraries**
- **@headlessui/react 2.2.4** - Accessible UI components
- **@heroicons/react 2.2.0** - Beautiful SVG icons
- **react-icons 5.5.0** - Comprehensive icon library
- **framer-motion 12.23.0** - Smooth animations
- **aos 2.3.4** - Scroll animations
- **swiper 11.2.10** - Touch slider
- **clsx 2.1.1** - Conditional CSS classes### **π Authentication & Security**
- **@clerk/nextjs 6.23.2** - Complete auth solution
- **@clerk/backend 2.7.0** - Server-side auth
- **bcryptjs 3.0.2** - Password hashing
- **next-auth 4.24.11** - Alternative auth (legacy)### **π³ Payment & E-commerce**
- **@stripe/react-stripe-js 3.9.0** - Stripe React components
- **@stripe/stripe-js 7.8.0** - Stripe JavaScript SDK
- **stripe 18.4.0** - Server-side Stripe integration### **ποΈ Database & Backend**
- **mongoose 8.16.1** - MongoDB ODM
- **socket.io 4.8.1** - Real-time communication
- **socket.io-client 4.8.1** - Client-side sockets
- **axios 1.10.0** - HTTP client### **π File Management**
- **cloudinary 2.7.0** - Cloud image storage
- **formidable 3.5.4** - File upload handling### **π Forms & Validation**
- **react-hook-form 7.59.0** - Form management
- **dotenv 17.1.0** - Environment variables### **π§ Development Tools**
- **eslint 9** - Code linting
- **ts-node 10.9.2** - TypeScript execution
- **@types/node 20.19.4** - Node.js types
- **@types/react 19** - React types
- **@types/react-dom 19** - React DOM types
- **@types/aos 3.0.7** - AOS types
- **@types/formidable 3.4.5** - Formidable types---
## π **Deployment & Infrastructure**
### **π Frontend Hosting - Vercel**
- **Platform**: Vercel (Next.js optimized)
- **Build Command**: `npm run build`
- **Output Directory**: `.next`
- **Framework**: Next.js
- **Features**:
- Automatic HTTPS
- Global CDN
- Edge functions
- Automatic deployments
- Performance analytics### **π Socket Server - Render**
- **Platform**: Render (100% FREE FOREVER)
- **Service Type**: Web service
- **Environment**: Node.js
- **Plan**: Free tier
- **Features**:
- Automatic HTTPS
- Custom domain support
- Environment variables
- Health monitoring
- Auto-scaling### **ποΈ Database - MongoDB Atlas**
- **Platform**: MongoDB Atlas
- **Type**: Cloud-hosted MongoDB
- **Features**:
- Automatic backups
- Global distribution
- Built-in security
- Performance monitoring
- Connection pooling### **π Authentication - Clerk**
- **Platform**: Clerk.dev
- **Features**:
- Multi-factor authentication
- Social logins
- User management
- Webhook support
- Role-based access### **π³ Payments - Stripe**
- **Platform**: Stripe
- **Features**:
- Secure checkout
- Webhook processing
- Multiple payment methods
- Fraud protection
- Analytics dashboard---
## π» **Development Setup & Installation**
### **1. Clone the Repository**
```bash
git clone https://github.com/debabrataghoosh/AgroTrade-fullstack-project.git
cd AgroTrade-fullstack-project
```### **2. Install Dependencies**
```bash
# Install main dependencies
npm install# Install socket server dependencies
cd socket-server
npm install
cd ..
```### **3. Environment Variables Setup**
Create a `.env.local` file in the root folder:
```env
# Clerk Authentication
NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY=your_clerk_publishable_key
CLERK_SECRET_KEY=your_clerk_secret_key
CLERK_WEBHOOK_SECRET=your_clerk_webhook_secret# MongoDB Database
MONGODB_URI=your_mongodb_atlas_connection_string# Stripe Payment
STRIPE_SECRET_KEY=your_stripe_secret_key
STRIPE_WEBHOOK_SECRET=your_stripe_webhook_secret
NEXT_PUBLIC_STRIPE_PUBLISHABLE_KEY=your_stripe_publishable_key# Cloudinary (Optional)
CLOUDINARY_CLOUD_NAME=your_cloudinary_name
CLOUDINARY_API_KEY=your_cloudinary_api_key
CLOUDINARY_API_SECRET=your_cloudinary_secret# Socket Server
NEXT_PUBLIC_SOCKET_URL=https://your-socket-server.onrender.com
```### **4. Database Setup**
1. **MongoDB Atlas**: Create a cluster and get your connection string
2. **Collections**: The app will automatically create required collections
3. **Indexes**: Database indexes are automatically created for performance### **5. Run Development Servers**
```bash
# Option 1: Run frontend only
npm run dev# Option 2: Run socket server only
npm run socket# Option 3: Run both simultaneously (recommended)
npm run dev:all
```Open your browser at: [http://localhost:3000](http://localhost:3000)
---
## π§ **Project Structure & Architecture**
```
AgroTrade/
βββ src/
β βββ app/ # Next.js App Router
β β βββ api/ # API routes
β β β βββ auth/ # Authentication endpoints
β β β βββ buyer-chats/ # Buyer chat management
β β β βββ create-checkout-session/ # Stripe checkout
β β β βββ health/ # Health monitoring
β β β βββ messages/ # Chat message handling
β β β βββ orders/ # Order management
β β β βββ products/ # Product CRUD operations
β β β βββ seller-chats/ # Seller chat management
β β β βββ socket/ # Socket.IO integration
β β β βββ user/ # User management
β β β βββ webhooks/ # Stripe webhooks
β β β βββ wishlist/ # Wishlist operations
β β βββ components/ # Reusable components
β β βββ dashboard/ # Seller dashboard
β β βββ products/ # Product pages
β β βββ chat/ # Real-time chat
β β βββ seller/ # Seller portal
β β βββ checkout/ # Payment checkout
β β βββ orders/ # Order management
β β βββ wishlist/ # Wishlist pages
β βββ lib/
β β βββ models/ # MongoDB schemas
β β β βββ User.ts # User model
β β β βββ Product.ts # Product model
β β β βββ Order.ts # Order model
β β β βββ Message.ts # Chat message model
β β β βββ Wishlist.ts # Wishlist model
β β βββ mongodb.ts # Database connection
β β βββ mongodbClientPromise.ts # Client promise
β βββ middleware.ts # Route protection
βββ socket-server/ # Real-time communication server
β βββ server.js # Socket.IO server
β βββ package.json # Socket server dependencies
β βββ render.yaml # Render deployment config
βββ public/ # Static assets
β βββ assets/ # Images and media
βββ vercel.json # Vercel deployment config
βββ next.config.ts # Next.js configuration
βββ tailwind.config.js # Tailwind CSS config
βββ tsconfig.json # TypeScript config
βββ package.json # Main dependencies and scripts
```---
## π **Deployment Guide**
### **Frontend Deployment (Vercel)**
1. **Connect GitHub** repository to Vercel
2. **Set environment variables** in Vercel dashboard
3. **Configure build settings**:
- Build Command: `npm run build`
- Output Directory: `.next`
- Install Command: `npm install`
4. **Automatic deployment** on every push to main branch### **Socket Server Deployment (Render)**
1. **Create Render account** (100% FREE FOREVER)
2. **Connect GitHub** repository
3. **Set root directory** to `socket-server`
4. **Configure environment**:
- Build Command: `npm install`
- Start Command: `npm start`
5. **Deploy** with automatic HTTPS### **Database Setup (MongoDB Atlas)**
1. **Create cluster** in MongoDB Atlas
2. **Set up network access** (IP whitelist or 0.0.0.0/0)
3. **Create database user** with read/write permissions
4. **Get connection string** and add to environment variables### **External Services Configuration**
1. **Clerk**: Set up authentication and webhooks
2. **Stripe**: Configure webhook endpoints
3. **Cloudinary**: Set up image upload credentials---
## π― **Key Features & Implementation Status**
### **β Production Ready Features**
- **TypeScript compilation** with strict type checking
- **Error handling** and graceful fallbacks
- **Performance optimization** with database indexes
- **Security** with protected API routes
- **Responsive design** for all devices
- **SEO optimization** with Next.js### **β Real-Time Features**
- **Live chat** between buyers and sellers
- **Instant notifications** for new messages
- **Socket.IO integration** with Render hosting
- **Message persistence** in MongoDB
- **Connection status monitoring**### **β E-commerce Features**
- **Product catalog** with advanced filtering
- **Secure checkout** via Stripe
- **Order management** system
- **Wishlist functionality**
- **User role management**
- **Payment processing**### **β Authentication & Security**
- **Multi-factor authentication** via Clerk
- **Role-based access control**
- **Protected API routes**
- **Secure payment processing**
- **Data validation**---
## π **Troubleshooting & Common Issues**
### **Development Issues**
1. **MissingSchemaError**: Ensure all models are imported via `@/lib/models`
2. **Socket connection failed**: Check Render socket server status
3. **MongoDB timeout**: Verify connection string and network access
4. **Build errors**: Check TypeScript compilation and dependencies### **Deployment Issues**
1. **Vercel build failures**: Check for TypeScript errors locally
2. **Render socket server down**: Monitor Render dashboard
3. **MongoDB connection issues**: Verify Atlas network access
4. **Stripe webhook failures**: Check webhook endpoint configuration### **Performance Issues**
1. **Slow queries**: Database indexes are automatically created
2. **Memory leaks**: Connection pooling is configured
3. **Timeout errors**: Query timeouts are set to prevent hangs---
## π **Monitoring & Health Checks**
### **Health Endpoints**
- `/api/health` - Overall system health
- `/api/socket` - Socket service status
- `/api/products` - Database connectivity
- `/api/orders` - Order system status### **Performance Monitoring**
- **Vercel Analytics** for frontend performance
- **MongoDB Atlas** for database metrics
- **Stripe Dashboard** for payment analytics
- **Render Dashboard** for socket server status---
## π€ **Contributing & Development**
### **Development Workflow**
1. **Fork** the repository
2. **Create** a feature branch
3. **Make** your changes
4. **Test** thoroughly
5. **Submit** a pull request### **Code Quality**
- **ESLint** configuration for code standards
- **TypeScript** for type safety
- **Prettier** for code formatting
- **Git hooks** for pre-commit checks---
## π **License & Legal**
This project is licensed under the **MIT License** - see the [LICENSE](LICENSE) file for details.
---
## π **Acknowledgments & Credits**
- **Next.js team** for the amazing framework
- **Vercel** for seamless deployment and hosting
- **Render** for free socket server hosting
- **MongoDB Atlas** for database hosting
- **Clerk** for authentication services
- **Stripe** for payment processing
- **Tailwind CSS** for the design system
- **Open source community** for various libraries---
## π **Support & Contact**
- **GitHub Issues**: [Report bugs or request features](https://github.com/debabrataghoosh/AgroTrade-fullstack-project/issues)
- **Email**: Contact through GitHub profile
- **Documentation**: Check the code comments and API routes
- **Deployment Guide**: See [DEPLOYMENT.md](DEPLOYMENT.md) for detailed deployment instructions---
## π **Quick Start Commands**
```bash
# Development
npm run dev # Frontend only
npm run socket # Socket server only
npm run dev:all # Both services# Production
npm run build # Build for production
npm run start # Start production server# Utilities
npm run lint # Lint code
npm run type-check # TypeScript check
```---
**AgroTrade** - Empowering Indian agriculture through technology! πΎπ
*Built with Next.js, Deployed on Vercel, Powered by Render, Secured by Clerk, and Enhanced with Stripe*