Skip to content

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.

Notifications You must be signed in to change notification settings

debabrataghoosh/AgroTrade-fullstack-project

Repository files navigation

🌾 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


✨ 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

git clone https://github.com/debabrataghoosh/AgroTrade-fullstack-project.git
cd AgroTrade-fullstack-project

2. Install Dependencies

# 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:

# 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

# 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


πŸ”§ 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 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


πŸš€ Quick Start Commands

# 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

About

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.

Topics

Resources

Stars

Watchers

Forks

Packages

No packages published