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 at: https://shop-sphere-three-pi.vercel.app
- π 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 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
- π 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
- π Statistics β Product count, total stock, average price
- β CRUD Operations β Create, edit, delete products
- π Product Table β Overview of all products with quick actions
- π 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
| 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) |
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
- Node.js v18+ (download)
- MongoDB running locally or a MongoDB Atlas connection string
git clone https://github.com/Kg1511/ShopSphere.git
cd ShopSphere# Install all dependencies (server + client)
cd server && npm install
cd ../client && npm installCreate server/.env from the example:
cp server/.env.example server/.envThen 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.appcd server
npm run seedThis creates:
- Admin user:
admin@shopsphere.com/admin123 - Test user:
john@example.com/password123 - 12 sample products across all categories
# Terminal 1 β Start the backend
cd server
npm run dev
# Terminal 2 β Start the frontend
cd client
npm run dev- Frontend: http://localhost:5173
- Backend API: http://localhost:5000
- Health Check: http://localhost:5000/api/health
| 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 |
| 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=
| 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 |
| 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 |
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
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) |
- Create a new Web Service on render.com
- Connect your GitHub repo, set Root Directory to
server - Build command:
npm installΒ· Start command:node server.js - Add environment variables:
MONGO_URI=<your-atlas-uri> JWT_SECRET=<your-secret> CLIENT_URL=<your-vercel-url> NODE_ENV=production PORT=5000
- Import repo on vercel.com, set Root Directory to
client - Framework preset: Vite Β· Output:
dist - Add environment variable:
VITE_API_URL=<your-render-url>/api - Deploy β SPA routing is handled by
client/vercel.json
- Create a free M0 cluster at mongodb.com/atlas
- Add
0.0.0.0/0to Network Access (allows Render IPs) - Grab the connection string and set it as
MONGO_URIon Render - 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.
- Fork the repository
- Create a feature branch:
git checkout -b feature/your-feature - Commit your changes:
git commit -m "feat: add your feature" - Push to the branch:
git push origin feature/your-feature - Open a Pull Request
This project is licensed under the ISC License.
Built with β€οΈ using the MERN Stack