Skip to content

chinmaywali/SpringBoot-Ecommerce_Application

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

15 Commits
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ›’ Spring Boot E-Commerce Application Backend πŸš€

Welcome to the Spring Boot E-Commerce Application – a backend service for managing product categories in an e-commerce system. This project provides RESTful APIs to create, update, delete, and retrieve product categories efficiently.

It is built using Java Spring Boot, integrated with an H2 in-memory database, and rigorously tested with Postman for seamless API interactions. The architecture is designed to be modular, scalable, and easily extendable for building a full-fledged e-commerce platform.

πŸ“Œ Features

βœ… Spring Boot Framework – Fast and efficient backend development.
βœ… H2 Database – Lightweight and fast in-memory database for development and testing.
βœ… Spring Data JPA – Simplifies database operations.
βœ… RESTful APIs – Well-structured API endpoints for managing product categories.
βœ… Postman API Testing – Ensures seamless request handling.
βœ… Maven Dependency Management – Efficient project setup and build automation.
βœ… Lightweight & Extendable – Can be scaled for production-ready deployments.

πŸ› οΈ Technologies Used

  • Java 17 – Modern Java for high performance.
  • Spring Boot – Framework for enterprise-grade applications.
  • Spring Data JPA – ORM for database interactions.
  • H2 Database – In-memory storage for quick prototyping.
  • Lombok – Reduces boilerplate code for cleaner implementation.
  • Maven – Build and dependency management tool.
  • Postman – API testing and validation.

πŸ“‚ Project Structure

πŸ“¦ sb-ecom
 ┣ πŸ“‚ src/main/java/com/ecommerce/Project
 ┃ ┣ πŸ“œ SbEcomApplication.java    # Main Spring Boot application
 ┃ ┣ πŸ“œ Category.java             # Category entity class
 ┃ ┣ πŸ“œ CategoryController.java   # REST API Controller for category management
 ┃ ┣ πŸ“‚ repositories
 ┃ ┃ β”— πŸ“œ CategoryRepository.java # JPA repository interface
 ┃ ┣ πŸ“‚ service
 ┃ ┃ ┣ πŸ“œ CategoryService.java    # Service interface for business logic
 ┃ ┃ β”— πŸ“œ CategoryServiceImpt.java # Service implementation
 ┣ πŸ“‚ src/main/resources
 ┃ ┣ πŸ“œ application.properties    # Spring Boot configuration file
 ┣ πŸ“œ pom.xml                     # Project dependencies

πŸ”₯ API Endpoints

HTTP Method Endpoint Description
GET /api/public/categories Fetch all categories
POST /api/public/categories Create a new category
PUT /api/public/categories/{id} Update an existing category
DELETE /api/public/categories/{id} Delete a category

πŸš€ Getting Started

1️⃣ Clone the Repository

git clone https://github.com/chinmaywali/SpringBoot-Ecommerce_Application.git
cd SpringBoot-Ecommerce_Application

2️⃣ Build & Run the Application

mvn spring-boot:run

3️⃣ Access API via Postman

  • Base URL: http://localhost:8080/api/public/categories
  • Example POST Request:
{
    "categoryName": "Clothing & Fashion"
}

πŸ“Έ Screenshots & Demo

1️⃣ H2 Database Connection

Here's a screenshot of the H2 database connection and the data stored in the categories table.

H2 DataBase Test Connection Successful
Screenshot (463) Screenshot (464)
View Tables Initial Query; Empty Table
Screenshot (466) Screenshot (467)

2️⃣ API Calls in Postman

πŸ“₯ Fetch All Categories (GET Request)

  • EndPoint: http://localhost:8080/api/public/categories
  • Response: initially empty
[]
Initially Empty
Screenshot (474)

βž• Add Category (POST Request)

  • EndPoint: http://localhost:8080/api/public/categories
  • Request Payload: Add categories one by one by sending separate POST requests for each.
// First Request
{
    "categoryName": "Clothing & Fashion"
}

// Second Request
{
    "categoryName": "Electronics"
}

// Third Request
{
    "categoryName": "Fresh Fruits & Vegetables"
}

// Fourth Request
{
    "categoryName": "Footwear"
}

πŸ’‘ Important:

  • Each category must be added individually by sending a separate request for each payload.
  • Do not send all the categories in a single request.

πŸ› οΈ API Responses (Example Response for Each Request):

{
    "id": 1,
    "categoryName": "Clothing & Fashion"
}
{
    "id": 2,
    "categoryName": "Electronics"
}
{
    "id": 3,
    "categoryName": "Fresh Fruits & Vegetables"
}
{
    "id": 4,
    "categoryName": "Footwear"
}
Adding Clothing & Fashion Category Adding Electronics Category
Screenshot (475) Screenshot (477)
Adding Fresh Fruits & Vegetables Category Adding Footwear Category
Screenshot (478) Screenshot (479)

πŸ“₯ Fetch All Categories (GET Request)

Response:

[
     {
        "id": 1,
        "categoryName": "Clothing & Fashion"
     },

     {
        "id": 2,
        "categoryName": "Electronics"
     },

     {
         "id": 3,
         "categoryName": "Fresh Fruits & Vegetables"
     },

     {
        "id": 4,
        "categoryName": "Footwear"
     }

]
Categories are Added
Screenshot (480)

πŸ“ Update Category (PUT Request)

  • EndPoint: http://localhost:8080/api/public/categories/3
  • Request: Updating category name of the category with Category id 3.. i.e Fresh Fruits & Vegetables to Home & Kitchen
{
    "categoryName": "Home & Kitchen"
}

Response:

{
    "id": 3,
    "categoryName": "Home & Kitchen"
}
Updating the category with id 3 Updated
Screenshot (481) Screenshot (482)

πŸ—‘οΈ Delete Category (DELETE Request)

  • EndPoint: http://localhost:8080/api/public/categories/2
  • Response: Delete the category with CategoryId 2
{
    "message": "Category deleted successfully"
}
Delete the category with CategoryId 2 Deleted
Screenshot (483) Screenshot (485)

πŸ“Š H2 Database - Final State After API Calls

Before API Calls After API Calls
Screenshot (467) Screenshot (486)

🎯 Future Enhancements

βœ… JWT Authentication – Secure API access with user roles.
βœ… Database Migration – Replace H2 with MySQL/PostgreSQL for production.
βœ… Additional Features – Extend support for products, orders, and users.
βœ… Swagger Documentation – API documentation for better usability.


πŸ“Œ Contributions Welcome! Fork this repository, enhance features, and submit a pull request.
πŸ’‘ Have Suggestions? Open an issue and let's improve this together! πŸš€

About

A Spring Boot based E-Commerce Backend Application.πŸš€

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages