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.
β
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.
- 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.
π¦ 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
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 |
git clone https://github.com/chinmaywali/SpringBoot-Ecommerce_Application.git
cd SpringBoot-Ecommerce_Application
mvn spring-boot:run
- Base URL:
http://localhost:8080/api/public/categories
- Example POST Request:
{
"categoryName": "Clothing & Fashion"
}
Here's a screenshot of the H2 database connection and the data stored in the categories table.
H2 DataBase | Test Connection Successful |
---|---|
![]() |
![]() |
View Tables | Initial Query; Empty Table |
---|---|
![]() |
![]() |
- EndPoint:
http://localhost:8080/api/public/categories
- Response: initially empty
[]
Initially Empty |
---|
![]() |
- 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 |
---|---|
![]() |
![]() |
Adding Fresh Fruits & Vegetables Category | Adding Footwear Category |
---|---|
![]() |
![]() |
Response:
[
{
"id": 1,
"categoryName": "Clothing & Fashion"
},
{
"id": 2,
"categoryName": "Electronics"
},
{
"id": 3,
"categoryName": "Fresh Fruits & Vegetables"
},
{
"id": 4,
"categoryName": "Footwear"
}
]
Categories are Added |
---|
![]() |
- 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 |
---|---|
![]() |
![]() |
- 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 |
---|---|
![]() |
![]() |
Before API Calls | After API Calls |
---|---|
![]() |
![]() |
β
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! π