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! 🚀