Skip to content

MeetVora79/ecommerce-api

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🛒 E-commerce Backend API

A fully functional E-commerce Backend API built using Node.js, Express, and MongoDB. This project includes authentication, role-based access, product management, cart, orders, wishlist, and user profile.


🚀 Tech Stack

  • Node.js
  • Express.js
  • MongoDB
  • Mongoose
  • JWT Authentication
  • bcrypt (password hashing)
  • Helmet (security)

📁 Folder Structure

ecommerce-api/
│── config/
│── middleware/
│── models/
│── routes/
│── validators/
│── server.js
│── .env
│── package.json

🔐 Features

👤 Authentication

  • User Signup
  • User Login (JWT based)
  • Role-based access (User / Admin)

🛍️ Products

  • Create Product (Admin)
  • Get All Products
  • Get Product Details
  • Update Product (Admin)
  • Delete Product (Admin)

🛒 Cart

  • Add to Cart
  • Get Cart
  • Update Quantity
  • Remove Item
  • Clear Cart

📦 Orders

  • Create Order (Checkout)
  • Get My Orders
  • Get Order Details
  • Admin: Get All Orders
  • Admin: Update Order Status

❤️ Wishlist

  • Add to Wishlist
  • Get Wishlist
  • Remove Item
  • Clear Wishlist

👤 User Profile

  • Get Profile
  • Update Profile
  • Change Password

🔑 Environment Variables

Create a .env file in root:

MONGO_URI=mongodb://127.0.0.1:27017/ecommerce
JWT_SECRET=your_secret_key


⚙️ Installation & Setup

1️⃣ Clone the repository

git clone https://github.com/YOUR_USERNAME/ecommerce-api.git
cd ecommerce-api

2️⃣ Install dependencies

npm install

3️⃣ Run the server

npm run dev

Server will run on:

http://localhost:5000

🔐 API Authentication

All protected routes require JWT token in headers:

Authorization: Bearer <your_token>

📮 API Endpoints

Auth

POST   /api/auth/signup
POST   /api/auth/login

Products

GET    /api/products
GET    /api/products/:id
POST   /api/products        (Admin)
PUT    /api/products/:id    (Admin)
DELETE /api/products/:id    (Admin)

Cart

POST   /api/cart/add
GET    /api/cart
PUT    /api/cart/update
DELETE /api/cart/remove/:id
DELETE /api/cart/clear

Orders

POST   /api/orders/create
GET    /api/orders/my
GET    /api/orders/:id
GET    /api/orders          (Admin)
PUT    /api/orders/:id      (Admin)

Wishlist

POST   /api/wishlist/add
GET    /api/wishlist
DELETE /api/wishlist/remove/:id
DELETE /api/wishlist/clear

User

GET    /api/user/profile
PUT    /api/user/profile
PUT    /api/user/password

🧠 Project Flow

User → Signup/Login → JWT Token

↓
Browse Products

↓
Add to Cart

↓
Create Order (Checkout)

↓
Admin manages products & orders

🔒 Security

  • Password hashing using bcrypt
  • JWT authentication
  • Helmet for HTTP security headers

👨‍💻 Author

Meet Vora


⭐ Support

If you like this project, give it a ⭐ on GitHub!

About

A fully functional E-commerce Backend API built using Node.js, Express, and MongoDB. This project includes authentication, role-based access, product management, cart, orders, wishlist, and user profile.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors