Skip to content

Kg1511/ShopSphere

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

53 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ›’ ShopSphere β€” MERN E-Commerce Platform

A full-stack e-commerce platform built with MongoDB, Express.js, React, and Node.js featuring JWT-based authentication, product catalog management, dynamic cart logic, and a premium dark-themed UI.

Live Demo API MERN Stack Node.js MongoDB License

🌐 Live at: https://shop-sphere-three-pi.vercel.app


✨ Features

Authentication & Security

  • πŸ” JWT-based Authentication β€” Secure token-based login/register
  • πŸ”‘ bcrypt Password Hashing β€” Salted password encryption (10 rounds)
  • πŸ›‘οΈ Protected Routes β€” Role-based access control (User/Admin)
  • πŸ”’ Secure API β€” Bearer token authorization middleware

Product Management

  • πŸ“¦ Product Catalog β€” Browse, search, and filter products
  • πŸ” Search & Filter β€” By category, price range, and keywords
  • ⭐ Ratings & Reviews β€” Star ratings with review counts
  • πŸ“Š Sort Options β€” Price (asc/desc), rating, newest

Shopping Experience

  • πŸ›’ Dynamic Cart β€” Add, remove, update quantities with real-time totals
  • πŸ’° Order Summary β€” Subtotal, tax, shipping (free over $100)
  • πŸ“‹ Checkout Flow β€” Shipping address form β†’ order placement
  • πŸ“¦ Order History β€” Track past orders with status badges

Admin Dashboard

  • πŸ“Š Statistics β€” Product count, total stock, average price
  • βž• CRUD Operations β€” Create, edit, delete products
  • πŸ“‹ Product Table β€” Overview of all products with quick actions

UI/UX

  • πŸŒ™ Premium Dark Theme β€” Glassmorphism, gradient accents
  • ✨ Micro-Animations β€” Smooth hover effects, transitions
  • πŸ“± Responsive Design β€” Mobile-first, works on all devices
  • πŸ”” Toast Notifications β€” Real-time feedback on actions

πŸ—οΈ Tech Stack

Layer Technology
Frontend React 19, Vite, React Router v7, Axios
Backend Node.js, Express.js
Database MongoDB, Mongoose ODM
Auth JSON Web Tokens (JWT), bcryptjs
Styling Custom CSS (Glassmorphism, CSS Variables)
Fonts Google Fonts (Inter, Outfit)

πŸ“ Project Structure

ShopSphere/
β”œβ”€β”€ client/                   # React Frontend
β”‚   β”œβ”€β”€ src/
β”‚   β”‚   β”œβ”€β”€ components/       # Navbar, Footer, ProductCard, ProtectedRoute
β”‚   β”‚   β”œβ”€β”€ context/          # AuthContext, CartContext, ToastContext
β”‚   β”‚   β”œβ”€β”€ pages/            # All page components
β”‚   β”‚   β”œβ”€β”€ api.js            # Axios instance with JWT interceptor
β”‚   β”‚   β”œβ”€β”€ App.jsx           # Router setup
β”‚   β”‚   β”œβ”€β”€ main.jsx          # Entry point
β”‚   β”‚   └── index.css         # Design system
β”‚   β”œβ”€β”€ index.html
β”‚   └── package.json
β”‚
β”œβ”€β”€ server/                   # Express Backend
β”‚   β”œβ”€β”€ config/
β”‚   β”‚   └── db.js             # MongoDB connection
β”‚   β”œβ”€β”€ controllers/          # Auth, Product, Cart, Order controllers
β”‚   β”œβ”€β”€ middleware/
β”‚   β”‚   └── authMiddleware.js # JWT verify + Admin check
β”‚   β”œβ”€β”€ models/               # User, Product, Cart, Order schemas
β”‚   β”œβ”€β”€ routes/               # API route definitions
β”‚   β”œβ”€β”€ utils/
β”‚   β”‚   └── generateToken.js  # JWT token generator
β”‚   β”œβ”€β”€ seed.js               # Database seeder
β”‚   β”œβ”€β”€ server.js             # Express app entry
β”‚   └── package.json
β”‚
β”œβ”€β”€ .gitignore
β”œβ”€β”€ package.json              # Root scripts
└── README.md

πŸš€ Getting Started

Prerequisites

1. Clone the Repository

git clone https://github.com/Kg1511/ShopSphere.git
cd ShopSphere

2. Install Dependencies

# Install all dependencies (server + client)
cd server && npm install
cd ../client && npm install

3. Configure Environment

Create server/.env from the example:

cp server/.env.example server/.env

Then fill in your values:

# Local development
MONGO_URI=mongodb://localhost:27017/shopsphere
JWT_SECRET=your_secret_key_here
PORT=5000

# Optional: set when deploying (see Deployment section)
# CLIENT_URL=https://your-vercel-app.vercel.app

4. Seed the Database

cd server
npm run seed

This creates:

  • Admin user: admin@shopsphere.com / admin123
  • Test user: john@example.com / password123
  • 12 sample products across all categories

5. Run the Application

# Terminal 1 β€” Start the backend
cd server
npm run dev

# Terminal 2 β€” Start the frontend
cd client
npm run dev

πŸ”— API Endpoints

Auth

Method Endpoint Description Access
POST /api/auth/register Register new user Public
POST /api/auth/login Login user Public
GET /api/auth/profile Get user profile Protected

Products

Method Endpoint Description Access
GET /api/products List all products Public
GET /api/products/:id Get single product Public
POST /api/products Create product Admin
PUT /api/products/:id Update product Admin
DELETE /api/products/:id Delete product Admin

Query Parameters: ?search=, ?category=, ?sort=price_asc|price_desc|rating|newest, ?minPrice=, ?maxPrice=

Cart

Method Endpoint Description Access
GET /api/cart Get user's cart Protected
POST /api/cart Add/update item Protected
DELETE /api/cart/:itemId Remove item Protected
DELETE /api/cart Clear cart Protected

Orders

Method Endpoint Description Access
POST /api/orders Place order Protected
GET /api/orders Get my orders Protected
GET /api/orders/:id Get order details Protected

πŸ”€ Git Branching Strategy

This project was built using a feature-branch workflow:

main
β”œβ”€β”€ feature/backend-setup     β†’  Merged βœ“
β”‚   β”œβ”€β”€ Express + MongoDB setup
β”‚   β”œβ”€β”€ User model + JWT auth + bcrypt
β”‚   β”œβ”€β”€ Product & Order models + CRUD APIs
β”‚   └── Cart & Order APIs + seed script
β”‚
β”œβ”€β”€ feature/frontend-setup    β†’  Merged βœ“
β”‚   β”œβ”€β”€ React + Vite scaffold
β”‚   β”œβ”€β”€ Design system + Navbar + Footer
β”‚   β”œβ”€β”€ Auth pages + AuthContext
β”‚   β”œβ”€β”€ Product pages + CartContext
β”‚   β”œβ”€β”€ Cart, Checkout, Orders pages
β”‚   └── Admin Dashboard
β”‚
└── feature/integration       β†’  Merged βœ“
    β”œβ”€β”€ Root package.json + README
    └── Final polish

🚒 Deployment

ShopSphere is deployed across three free-tier services:

Service Purpose URL
Vercel React frontend shop-sphere-three-pi.vercel.app
Render Express API shopsphere-api-ld2e.onrender.com
MongoDB Atlas Database (M0 Free) Atlas cluster (cloud-hosted)

Deploy Your Own

Backend β€” Render

  1. Create a new Web Service on render.com
  2. Connect your GitHub repo, set Root Directory to server
  3. Build command: npm install Β· Start command: node server.js
  4. Add environment variables:
    MONGO_URI=<your-atlas-uri>
    JWT_SECRET=<your-secret>
    CLIENT_URL=<your-vercel-url>
    NODE_ENV=production
    PORT=5000
    

Frontend β€” Vercel

  1. Import repo on vercel.com, set Root Directory to client
  2. Framework preset: Vite Β· Output: dist
  3. Add environment variable:
    VITE_API_URL=<your-render-url>/api
    
  4. Deploy β€” SPA routing is handled by client/vercel.json

Database β€” MongoDB Atlas

  1. Create a free M0 cluster at mongodb.com/atlas
  2. Add 0.0.0.0/0 to Network Access (allows Render IPs)
  3. Grab the connection string and set it as MONGO_URI on Render
  4. Run the seed script locally (pointed at Atlas) to populate products:
    cd server && node seed.js

⚠️ Note: Render's free tier spins down after 15 min of inactivity. The first request after idle may take ~30s to wake up.


🀝 Contributing

  1. Fork the repository
  2. Create a feature branch: git checkout -b feature/your-feature
  3. Commit your changes: git commit -m "feat: add your feature"
  4. Push to the branch: git push origin feature/your-feature
  5. Open a Pull Request

πŸ“„ License

This project is licensed under the ISC License.


Built with ❀️ using the MERN Stack

About

Full-stack MERN e-commerce platform with JWT auth, product catalog, cart, orders & admin dashboard. Built with React 19, Vite, Express.js & MongoDB Atlas.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors