Skip to content

Mandar123454/MERN-E-Commerce-Store

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

MERN E-Commerce Store

Overview

A functional E-Commerce website built with MongoDB, ExpressJS, ReactJS, and Node.js. Features include product listing, cart management, and dynamic price updates.

Features

  • Product listing with images, names, prices, and descriptions
  • Add to Cart functionality
  • Cart management: update quantity, remove items
  • Dynamic total price calculation
  • Responsive, modern UI (custom CSS + Bootstrap)
  • Backend API for products and cart

Setup Guide

Prerequisites

  • Node.js & npm
  • MongoDB (local or Atlas)

Backend Setup

  1. cd server
  2. Install dependencies: npm install
  3. Start MongoDB locally (or update connection string for Atlas)
  4. Seed products: node seed.js
  5. Start server: node index.js (runs on http://localhost:5000)

Frontend Setup

  1. cd client
  2. Install dependencies: npm install
  3. Start React app: npm start (runs on http://localhost:3000)

Deployment

Frontend on Netlify

  1. Build command: npm run build
  2. Publish directory: build
  3. Base directory: client
  4. Environment variable (Site settings → Build & deploy → Environment):
    • REACT_APP_API_BASE_URL = https://
  5. Ensure _redirects exists at client/public/_redirects with: /* /index.html 200

Backend on Render/Railway

  1. Root directory: server
  2. Build command: npm install
  3. Start command: npm run start
  4. Environment variables:
    • MONGO_URI = your MongoDB connection string (Atlas recommended)
    • Optional PORT (defaults to 5000)
  5. (Optional) Seed: npm run seed (with MONGO_URI set)

After deploying backend, set the Netlify REACT_APP_API_BASE_URL to the backend URL.

API Endpoints

  • GET /items - Fetch all products
  • POST /cart - Add item to cart
  • DELETE /cart/:id - Remove item from cart
  • GET /cart - Get all cart items
  • PUT /cart/:id - Update item quantity

Database Schema

Items Collection

  • name: String
  • price: Number
  • image: String
  • stock: Number
  • description: String

Cart Collection

  • items: [{ productId, quantity }]

Screenshots

See /public/Dashboard.png, /public/Cart.png, /public/Results.png for UI examples.

Author

  • Mandar Kajbaje

MIT License

This Project is under MIT License.

About

A functional E-Commerce website built with MongoDB, ExpressJS, ReactJS, and Node.js. Features include product listing, cart management, and dynamic price updates.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors