Java 8 · Spring Boot · MySQL · Hibernate

E-Commerce
Backend API

A comprehensive REST API powering a full-featured e-commerce platform. Handles products, customers, sellers, carts, and orders — with robust session-based authentication at every layer.

6
Core Modules
30+
REST Endpoints
28
Git Commits
100%
CRUD Coverage

Tech Stack

Built with a modern, production-ready Java ecosystem designed for scalability and maintainability.

Java 8
🍃 Spring Boot
🗄️ Spring Data JPA
🐬 MySQL
🔗 Hibernate ORM
📜 Swagger / OpenAPI
📮 Postman
🧩 Lombok

Architecture & Modules

The platform is designed around six domain-driven modules connected through a clean REST layer with session-based auth.

🔐

Auth Module

Session-based authentication with 1-hour token expiry. Separate login flows for Customers and Sellers with secure registration and logout.

👤

Customer Module

Full customer lifecycle — profile management, address handling, credit card updates, password resets, and order history tracking.

🏪

Seller Module

Administrator role with product catalog control. Sellers manage inventory, view customers, and track orders across the platform.

📦

Product Module

Complete product CRUD — category browsing, seller-specific listings, quantity management, and detail updates.

🛒

Cart Module

Persistent shopping cart with add, remove, view, and clear operations. Linked to authenticated customer sessions.

📋

Order Module

End-to-end order lifecycle — place from cart, update pending orders, cancel, and query by date. Full order history with details.

API Reference

30+ RESTful endpoints organized by module. Click any module to explore its routes.

🔐

Login & Logout

6 endpoints
POST /register/customer Register new customer
POST /login/customer Customer login
POST /logout/customer Customer logout
POST /register/seller Register new seller
POST /login/seller Seller login
POST /logout/seller Seller logout
👤

Customer

10 endpoints
GET /customer/current Current logged-in customer
GET /customer/orders Customer order history
GET /customers List all customers
PUT /customer Update customer profile
PUT /customer/update/password Change password
PUT /customer/update/card Update credit card
PUT /customer/update/address Update home address
PUT /customer/update/credentials Update email & mobile
DELETE /customer Delete account
DELETE /customer/delete/address Remove address
🏪

Seller

8 endpoints
GET /seller/{sellerid} Get seller by ID
GET /seller/current Current seller
GET /sellers List all sellers
POST /addseller Add new seller
PUT /seller Update seller details
PUT /seller/update/password Change password
PUT /seller/update/mobile Update mobile
DELETE /seller/{sellerid} Delete seller
📦

Product

8 endpoints
GET /product/{id} Get product by ID
GET /products List all products
GET /products/{category} Filter by category
GET /products/seller/{id} Products by seller
POST /products Add new product
PUT /products Update product
PUT /products/{id} Update quantity
DELETE /product/{id} Delete product
🛒

Cart

4 endpoints
GET /cart View cart items
POST /cart/add Add item to cart
DELETE /cart Remove item
DELETE /cart/clear Clear entire cart
📋

Order

6 endpoints
GET /orders/{id} Get order details
GET /orders List all orders
GET /orders/by/date Filter by date
POST /order/place Place order from cart
PUT /orders/{id} Update pending order
DELETE /orders/{id} Cancel order
Sample Response — POST /login/customer
// Request Body
{
  "mobileId": "9999999999",
  "password": "abhi8080"
}

// Response — 200 OK
{
  "sessionId": 23,
  "token": "customer_0ad57094",
  "userId": 19,
  "userType": "customer",
  "sessionStartTime": "2022-06-10T10:48:20",
  "sessionEndTime": "2022-06-10T11:48:20"
}

Security & Features

Enterprise-grade authentication and role-based access control baked into every endpoint.

🔑 Session-Based Auth

Every API call is validated against a session token with 1-hour expiry. No token = no access.

🛡️ Role Separation

Customers and Sellers have distinct auth flows, permissions, and data access scopes throughout the system.

✅ Input Validation

Robust request validation at every step — mobile number, email format, password strength, and required fields.

⚡ Hibernate ORM

JPA/Hibernate handles entity mapping, relationships, and auto schema generation with production-ready queries.

📊 Swagger Docs

Auto-generated interactive API documentation at /swagger-ui/index.html for easy testing and exploration.

🗂️ ER Diagram

Complete Entity-Relationship diagram included in the repository, documenting all table relationships visually.

Installation & Setup

Get the API running locally in under 5 minutes.

1

Clone the Repository

Pull the project from GitHub to your local machine.

git clone https://github.com/abhishek2k21/E-Commerce-Backend.git
cd E-Commerce-Backend
2

Configure Database

Update application.properties with your MySQL credentials.

server.port=8080
spring.datasource.url=jdbc:mysql://localhost:3306/ecommercedb
spring.datasource.username=root
spring.datasource.password=root
3

Run the Application

Start the Spring Boot server. The API will be available at localhost:8080 and Swagger docs at /swagger-ui/index.html.

mvn spring-boot:run
4

Test with Postman

Import the endpoints into Postman and start testing. Register a customer first, login to get a session token, then explore all modules.