Skip to content

hrithik18k/Ecommerce-Follow-Along

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

228 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

LuxeMart β€” Premium E-Commerce Platform

A full-stack marketplace with glassmorphism UI, role-based access, real-time notifications, Razorpay payments, and a seller analytics dashboard.

Live Demo React Node.js MongoDB Redux Vite


✨ Features at a Glance

πŸ‘€ Authentication & Roles

  • JWT-based auth with bcrypt password hashing β€” 30-day token expiry
  • Three role types: Buyer, Seller, Admin (only one admin allowed per platform)
  • Profile management with avatar upload, editable email + name, address book (Home/Office/Other)

πŸ›οΈ Shopping Experience

  • Product discovery with category filter, price range filter, and 4-way sort (price, newest, top-rated)
  • Live search bar with debounced autocomplete, image previews, and highlighted matches
  • Full search results page with server-side pagination, sorting, and price filters
  • Product comparison β€” select up to 3 products and compare price, stock, category, description side-by-side
  • Recently viewed products persisted via localStorage on each product detail page
  • Wishlist toggle per product, viewable from profile
  • Multi-image product gallery with thumbnail selector

πŸ›’ Cart & Checkout

  • Add to cart with stock validation, quantity increase/decrease, item removal
  • Coupon system β€” admin creates discount codes with expiry, usage limits, and enable/disable toggle
  • Checkout flow: Cart β†’ Select Address β†’ Order Confirmation β†’ Payment
  • Razorpay integration for online payment with HMAC signature verification
  • COD (Cash on Delivery) as alternative payment method

πŸ“¦ Orders

  • Buyer order history with a 4-step progress stepper (Pending β†’ Processing β†’ Shipped β†’ Delivered)
  • Timestamped status history per step
  • Order cancellation by buyer (creates notification)
  • Seller order management with status update dropdown

πŸ“Š Seller Dashboard

  • Revenue, order count, product count, average rating stats
  • CSS bar chart of top-selling products (no chart library β€” pure CSS animations)
  • Recent orders list with status badges
  • Top products table with units sold and revenue generated per product

πŸ”” Notifications

  • In-app notification bell with unread badge counter
  • Auto-generated notifications on order status changes and cancellations
  • Mark individual or all notifications as read; click to navigate to relevant page
  • Polling every 60 seconds for fresh data

πŸ” Admin Panel

  • Platform-wide stats: users, products, orders, total revenue
  • User role management table (promote/demote any user)
  • Full coupon CRUD: create, list, enable/disable

🎨 UI/UX

  • Glassmorphism design system with dark/light theme toggle (persisted to localStorage)
  • CSS variable token system (--color-accent, --surface, --border, etc.)
  • Outfit display font + Inter body font
  • fadeInUp, spin, growUp keyframe animations throughout
  • Responsive down to 480px β€” mobile-first cart and navbar

πŸ—οΈ Architecture

Browser
   β”‚
   β”œβ”€β”€ React 18 + Vite (SWC)
   β”‚   β”œβ”€β”€ Redux Toolkit (user auth, compare state)
   β”‚   β”œβ”€β”€ React Router v7
   β”‚   β”œβ”€β”€ Axios (API calls)
   β”‚   └── react-hot-toast (notifications)
   β”‚
   └── Express.js Backend
       β”œβ”€β”€ JWT + Bcrypt (auth)
       β”œβ”€β”€ Multer (image uploads β†’ /uploads/)
       β”œβ”€β”€ Razorpay SDK (payments)
       β”œβ”€β”€ express-rate-limit (100 req/15min per IP)
       └── MongoDB + Mongoose ODM

πŸ“ Project Structure

β”œβ”€β”€ backend/
β”‚   β”œβ”€β”€ controllers/
β”‚   β”‚   β”œβ”€β”€ userControllers.js      # Auth, profile, wishlist, admin stats
β”‚   β”‚   β”œβ”€β”€ productControllers.js   # CRUD, reviews, search + filter
β”‚   β”‚   β”œβ”€β”€ cartControllers.js      # Add, update quantity, remove
β”‚   β”‚   β”œβ”€β”€ orderControllers.js     # Place order, seller stats, status updates
β”‚   β”‚   β”œβ”€β”€ couponControllers.js    # Create, apply, toggle coupons
β”‚   β”‚   β”œβ”€β”€ notificationControllers.js
β”‚   β”‚   └── razorpayController.js   # Create order + verify HMAC signature
β”‚   β”œβ”€β”€ models/                     # User, Product, Order, Coupon, Notification
β”‚   β”œβ”€β”€ routes/                     # userRoutes, productRoutes, orderRoutes...
β”‚   β”œβ”€β”€ middlewares/
β”‚   β”‚   β”œβ”€β”€ authMiddleware.js       # protect, adminOnly, sellerOrAdmin
β”‚   β”‚   └── multer.js               # diskStorage config
β”‚   └── server.js                   # Express entry, MongoDB connect, CORS
β”‚
β”œβ”€β”€ frontend/
β”‚   β”œβ”€β”€ src/
β”‚   β”‚   β”œβ”€β”€ components/             # 20+ feature components
β”‚   β”‚   β”œβ”€β”€ homepage/               # Home, Card, ProductForm
β”‚   β”‚   β”œβ”€β”€ store/
β”‚   β”‚   β”‚   β”œβ”€β”€ userSlice.js        # email, role, token (persisted to localStorage)
β”‚   β”‚   β”‚   β”œβ”€β”€ compareSlice.js     # Up to 3 products for comparison
β”‚   β”‚   β”‚   └── store.js
β”‚   β”‚   β”œβ”€β”€ index.css               # Design tokens, CSS variables, animations
β”‚   β”‚   └── App.css                 # Component-level styles
β”‚   └── vite.config.js

πŸš€ Getting Started

Prerequisites

  • Node.js 20+, npm
  • MongoDB (Atlas or local)
  • Razorpay account (test keys work)

Backend Setup

cd backend
npm install

Create .env:

MONGODB_URI=your_mongodb_connection_string
JWT_SECRET=your_jwt_secret_key
RAZORPAY_KEY_ID=rzp_test_xxxxxxxxxxxx
RAZORPAY_KEY_SECRET=your_razorpay_secret
PORT=3001
npm run dev   # nodemon
npm start     # production

Frontend Setup

cd frontend
npm install

Create .env:

VITE_BACKEND_URL=http://localhost:3001
VITE_RAZORPAY_KEY_ID=rzp_test_xxxxxxxxxxxx
npm run dev     # Vite dev server
npm run build   # Production build

πŸ”‘ API Overview

Resource Base Route Auth Required
Users /api/users Mixed
Products /api Public GET, protected POST/PUT/DELETE
Orders /api/orders protect
Cart /api/users/cart protect
Coupons /api/coupons protect + adminOnly (create/list/toggle)
Notifications /api/notifications protect

Key middleware: protect (validates JWT), adminOnly, sellerOrAdmin


πŸ’³ Payment Flow (Razorpay)

1. Frontend β†’ POST /api/orders/create-order  (amount in paise)
2. Razorpay Checkout opens in browser
3. User pays β†’ Razorpay calls handler with { razorpay_order_id, razorpay_payment_id, razorpay_signature }
4. Frontend β†’ POST /api/orders/verify-payment  (HMAC SHA256 verification)
5. On success β†’ POST /api/orders/place-order  (clears cart, decrements stock)

πŸ—„οΈ Data Models (Key Fields)

User β€” name, email, password (hashed), role (buyer/seller/admin), profilePicture, addresses[], cart[], wishlist[]

Product β€” name, description, price, stock, category, imageUrl[], userEmail, reviews[], rating, numReviews

Order β€” user, products[], address, totalPrice, status, couponCode, discountAmount, statusHistory[]

Coupon β€” code (uppercase), discountPercent, maxUses, usedCount, expiresAt, isActive

Notification β€” user, title, message, isRead, link


🌐 Deployment

Deployed on Render (both frontend static site and backend web service).

CORS is configured to allow:

  • https://luxemart-ayw6.onrender.com
  • https://luxemart-frontend-final.onrender.com
  • http://localhost:5173 (local dev)

React + Express + MongoDB Β· Razorpay Β· Redux Toolkit Β· Deployed on Render

About

Resources

License

Stars

9 stars

Watchers

1 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors