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.
- Main Application: https://agrotrade-ebrbvlkmi-debabrata-ghoshs-projects.vercel.app
- Socket Server: https://agrotrade-fullstack-project.onrender.com
- GitHub Repository: https://github.com/debabrataghoosh/AgroTrade-fullstack-project
- 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
- 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
- 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
- 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
- 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
- @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
- @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)
- @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
- 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
- cloudinary 2.7.0 - Cloud image storage
- formidable 3.5.4 - File upload handling
- react-hook-form 7.59.0 - Form management
- dotenv 17.1.0 - Environment variables
- 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
- 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
- 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
- Platform: MongoDB Atlas
- Type: Cloud-hosted MongoDB
- Features:
- Automatic backups
- Global distribution
- Built-in security
- Performance monitoring
- Connection pooling
- Platform: Clerk.dev
- Features:
- Multi-factor authentication
- Social logins
- User management
- Webhook support
- Role-based access
- Platform: Stripe
- Features:
- Secure checkout
- Webhook processing
- Multiple payment methods
- Fraud protection
- Analytics dashboard
git clone https://github.com/debabrataghoosh/AgroTrade-fullstack-project.git
cd AgroTrade-fullstack-project# Install main dependencies
npm install
# Install socket server dependencies
cd socket-server
npm install
cd ..Create a .env.local file in the root folder:
# 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- MongoDB Atlas: Create a cluster and get your connection string
- Collections: The app will automatically create required collections
- Indexes: Database indexes are automatically created for performance
# 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:allOpen your browser at: http://localhost:3000
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
- Connect GitHub repository to Vercel
- Set environment variables in Vercel dashboard
- Configure build settings:
- Build Command:
npm run build - Output Directory:
.next - Install Command:
npm install
- Build Command:
- Automatic deployment on every push to main branch
- Create Render account (100% FREE FOREVER)
- Connect GitHub repository
- Set root directory to
socket-server - Configure environment:
- Build Command:
npm install - Start Command:
npm start
- Build Command:
- Deploy with automatic HTTPS
- Create cluster in MongoDB Atlas
- Set up network access (IP whitelist or 0.0.0.0/0)
- Create database user with read/write permissions
- Get connection string and add to environment variables
- Clerk: Set up authentication and webhooks
- Stripe: Configure webhook endpoints
- Cloudinary: Set up image upload credentials
- 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
- Live chat between buyers and sellers
- Instant notifications for new messages
- Socket.IO integration with Render hosting
- Message persistence in MongoDB
- Connection status monitoring
- Product catalog with advanced filtering
- Secure checkout via Stripe
- Order management system
- Wishlist functionality
- User role management
- Payment processing
- Multi-factor authentication via Clerk
- Role-based access control
- Protected API routes
- Secure payment processing
- Data validation
- MissingSchemaError: Ensure all models are imported via
@/lib/models - Socket connection failed: Check Render socket server status
- MongoDB timeout: Verify connection string and network access
- Build errors: Check TypeScript compilation and dependencies
- Vercel build failures: Check for TypeScript errors locally
- Render socket server down: Monitor Render dashboard
- MongoDB connection issues: Verify Atlas network access
- Stripe webhook failures: Check webhook endpoint configuration
- Slow queries: Database indexes are automatically created
- Memory leaks: Connection pooling is configured
- Timeout errors: Query timeouts are set to prevent hangs
/api/health- Overall system health/api/socket- Socket service status/api/products- Database connectivity/api/orders- Order system status
- Vercel Analytics for frontend performance
- MongoDB Atlas for database metrics
- Stripe Dashboard for payment analytics
- Render Dashboard for socket server status
- Fork the repository
- Create a feature branch
- Make your changes
- Test thoroughly
- Submit a pull request
- ESLint configuration for code standards
- TypeScript for type safety
- Prettier for code formatting
- Git hooks for pre-commit checks
This project is licensed under the MIT License - see the LICENSE file for details.
- 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
- GitHub Issues: Report bugs or request features
- Email: Contact through GitHub profile
- Documentation: Check the code comments and API routes
- Deployment Guide: See DEPLOYMENT.md for detailed deployment instructions
# 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 checkAgroTrade - Empowering Indian agriculture through technology! πΎπ
Built with Next.js, Deployed on Vercel, Powered by Render, Secured by Clerk, and Enhanced with Stripe