The Catalog Service is a core microservice in the Smart Mart e-commerce platform, responsible for managing product categories and their hierarchical relationships. It provides a robust API for category management, including creation, retrieval, and hierarchical organization of product categories.
- Java 21 - Programming language
- Spring Boot 3.5.6 - Application framework
- Spring Data JPA - Data access
- PostgreSQL - Primary database
- Kafka - Event streaming
- Apache Avro - Data serialization
- Gradle - Build tool
- Lombok - Boilerplate reduction
- JUnit 5 - Testing framework
- Spring Test - Integration testing
The service follows a clean architecture pattern with clear separation of concerns:
com.smart.mart.catalog/
├── application/ # Application services and DTOs
├── domain/ # Domain model and business logic
└── infrastructure/ # Framework and external concerns
├── adapter/
│ ├── input/ # REST controllers
│ └── output/ # Persistence and external services
└── config/ # Configuration classes
The core domain model includes:
- Category: Represents a product category with properties like name, description, and hierarchical relationships
- CategoryHierarchy: Manages parent-child relationships between categories
POST /api/categories- Create a new categoryGET /api/categories/{id}- Get category by IDGET /api/categories- Get all categories (with optional filtering)PUT /api/categories/{id}- Update a categoryDELETE /api/categories/{id}- Delete a category
POST /api/categories/{id}/subcategories- Add a subcategoryGET /api/categories/{id}/hierarchy- Get category hierarchy
- Request Handling: REST Controllers receive HTTP requests
- Validation: Input validation using Spring Validation
- Business Logic: Application services process requests
- Persistence: Data is stored in PostgreSQL
- Events: Domain events are published to Kafka for other services
- Java 21
- Gradle 8.0+
- PostgreSQL 13+
- Kafka 3.0+
- Clone the repository
- Configure database in
application.yml - Start Kafka and create required topics
- Run the application:
./gradlew bootRun
Run tests with:
./gradlew testThe test suite includes:
- Unit tests
- Integration tests
- Service layer tests
- Controller tests
Build the application:
./gradlew clean buildCreate a Docker image:
./gradlew bootBuildImageThe service includes:
- Spring Boot Actuator endpoints for health checks and metrics
- Prometheus metrics
- Distributed tracing with OpenTelemetry
This project is licensed under the terms of the LICENSE file.