Skip to content

fb312/Ecommerce-backend

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

1 Commit
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

๐Ÿ›๏ธ E-Commerce Backend API

A powerful, secure, and feature-rich Spring Boot-based e-commerce backend, built with modular architecture, role-based authentication, and complete RESTful APIs for managing products, carts, orders, payments, wishlist, users, and more.


๐Ÿ“‘ Table of Contents


๐Ÿ”‘ Features

  • โœ… User Registration & Login with JWT Authentication
  • ๐Ÿ‘ฅ Role-Based Access for USER and ADMIN
  • ๐Ÿ“ฆ Product Management (CRUD + filtering, sorting, pagination)
  • ๐Ÿ›’ Shopping Cart (Add, update, remove, clear cart items)
  • โค๏ธ Wishlist (Add/remove favorite products)
  • ๐Ÿ’ณ Payment Simulation (Fake payment with order creation)
  • ๐Ÿ“ฆ Order Placement & History
  • ๐Ÿ”„ Order Status Update by Admin (PROCESSING, SHIPPED, DELIVERED)
  • ๐Ÿง  Global Exception Handling

๐Ÿ› ๏ธ Tech Stack

  • Spring Boot (REST APIs)
  • Spring Security (JWT Auth)
  • Spring Data JPA (Hibernate ORM)
  • MySQL (Database)
  • Lombok (Boilerplate reduction)
  • Postman (API testing)
  • Maven (Build tool)

๐Ÿ” Authentication & Roles

  • JWT-based stateless authentication
  • Secure endpoints using Spring Security filters
  • @PreAuthorize for method-level security
  • Roles:
    • USER: Can manage cart, wishlist, orders
    • ADMIN: Can manage products and update order status

๐Ÿงฉ Project Structure

src โ”œโ”€โ”€ main โ”‚ โ”œโ”€โ”€ java โ”‚ โ”‚ โ””โ”€โ”€ org.ecommerce โ”‚ โ”‚ โ”œโ”€โ”€ config # JWT & Security config โ”‚ โ”‚ โ”œโ”€โ”€ controller # All REST controllers โ”‚ โ”‚ โ”œโ”€โ”€ entity # JPA Entities (User, Product, CartItem, etc.) โ”‚ โ”‚ โ”œโ”€โ”€ enums # Enum for OrderStatus โ”‚ โ”‚ โ”œโ”€โ”€ exception # GlobalExceptionHandler โ”‚ โ”‚ โ”œโ”€โ”€ repository # JPA Repositories โ”‚ โ”‚ โ”œโ”€โ”€ service # Business logic โ”‚ โ”‚ โ””โ”€โ”€ util # JWT utilities โ”‚ โ””โ”€โ”€ resources โ”‚ โ”œโ”€โ”€ application.properties โ”‚ โ””โ”€โ”€ data.sql


๐Ÿ”— API Overview

๐Ÿ‘ค User & Auth

Method Endpoint Description
POST /api/auth/register Register new user
POST /api/auth/login Login & receive JWT token

๐Ÿ“ฆ Products

Method Endpoint Description
GET /api/products List products with filters/sorting
GET /api/products/{id} Get product by ID
POST /api/products Create product (Admin)
PUT /api/products/{id} Update product (Admin)
DELETE /api/products/{id} Delete product (Admin)

๐Ÿ›’ Cart

Method Endpoint Description
GET /api/cart View cart items
POST /api/cart Add item to cart
PUT /api/cart/{itemId} Update item quantity
DELETE /api/cart/{itemId} Remove item from cart
DELETE /api/cart/clear Clear all cart items

โค๏ธ Wishlist

Method Endpoint Description
GET /api/wishlist Get wishlist items
POST /api/wishlist/{productId} Add product to wishlist
DELETE /api/wishlist/{productId} Remove product from wishlist

๐Ÿ›๏ธ Orders

Method Endpoint Description
POST /api/orders Place order (with fake payment)
GET /api/orders View userโ€™s order history
PUT /api/orders/{id} Update status (Admin)

๐Ÿš€ Getting Started

๐Ÿ”ง Prerequisites

  • Java 17+
  • MySQL
  • Maven

๐Ÿ“ฆ Setup Instructions

  1. Clone the repo bash git clone https://github.com/your-username/ecommerce-backend.git cd ecommerce-backend

Configure DB in application.properties properties

spring.datasource.url=jdbc:mysql://localhost:3306/ecommerce_db spring.datasource.username=root spring.datasource.password=yourpassword

Build and Run bash mvn clean install mvn spring-boot:run

๐Ÿ“ฌ Sample Credentials Role Email Password User user@example.com user123 Admin admin@example.com admin123

๐Ÿ‘ฉโ€๐Ÿ’ป Author Built by Farheen

About

๐Ÿ›๏ธ Full-featured Spring Boot backend for an E-Commerce platform with JWT, Cart, Wishlist, and Orders.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors