A Spring Boot microservice that integrates with the DummyJSON API to provide product listings, search, and category features. This service simulates a real-world product module for an e-commerce system and demonstrates clean API client abstraction, centralized exception handling, and DTO-layered communication.
- ✅ Retrieve all products from DummyJSON
- 🔍 Search products by keyword
- 🛍️ Fetch products by category
- 📦 Get individual product by ID
- 🗂️ List all product categories
- ❌ Centralized error handling with
@ControllerAdvice
- 🛡️ Null-safe defensive programming in the service layer
- 🧼 Clean, layered architecture using DTOs and RestTemplate
Layer | Technology |
---|---|
Language | Java 17 |
Framework | Spring Boot 3.x |
HTTP Client | RestTemplate |
Build Tool | Maven |
IDE | IntelliJ IDEA |
Source API | DummyJSON REST API |
-
Clone the repository
git clone https://github.com/ChandraSekhar-VCS/product-service.git cd product-service
-
Configure Base URL
Add the following line in yourapplication.properties
:dummyjson.base-url=https://dummyjson.com
-
Run the application
./mvnw spring-boot:run
-
Test health check
GET http://localhost:8080/products/health
product-service/
├── controller/ # REST endpoints
├── service/ # Business logic
├── client/ # External API client
├── dto/ # Data Transfer Objects
├── exception/ # Custom and global exception handling
├── application.properties
└── pom.xml
Endpoint | Description |
---|---|
GET /products |
List all products |
GET /products/{id} |
Get product by ID |
GET /products/search?q=phone |
Search products |
GET /products/category/{name} |
Filter by category |
GET /products/categories |
List available categories |
GET /products/health |
Health check endpoint |
{
"products": [
{
"id": 1,
"title": "iPhone 9",
"price": 549,
"category": "smartphones"
},
...
]
}
- Switch to
WebClient
for reactive support - Integrate caching using Redis
- Add Swagger/OpenAPI docs
- Add service-level unit tests using JUnit & Mockito
Chandra Sekhar Vipparla
GitHub Profile
This project is open-source and available under the MIT License.