Skip to content

palmurugan/catalog-service

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Catalog Service

📌 Overview

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.

🛠 Technology Stack

Core Technologies

  • 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

Development Tools

  • Gradle - Build tool
  • Lombok - Boilerplate reduction
  • JUnit 5 - Testing framework
  • Spring Test - Integration testing

🏗 System Architecture

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

📊 Domain Model

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

🌐 API Endpoints

Category Management

  • POST /api/categories - Create a new category
  • GET /api/categories/{id} - Get category by ID
  • GET /api/categories - Get all categories (with optional filtering)
  • PUT /api/categories/{id} - Update a category
  • DELETE /api/categories/{id} - Delete a category

Category Hierarchy

  • POST /api/categories/{id}/subcategories - Add a subcategory
  • GET /api/categories/{id}/hierarchy - Get category hierarchy

🔄 Data Flow

  1. Request Handling: REST Controllers receive HTTP requests
  2. Validation: Input validation using Spring Validation
  3. Business Logic: Application services process requests
  4. Persistence: Data is stored in PostgreSQL
  5. Events: Domain events are published to Kafka for other services

🚀 Getting Started

Prerequisites

  • Java 21
  • Gradle 8.0+
  • PostgreSQL 13+
  • Kafka 3.0+

Local Development

  1. Clone the repository
  2. Configure database in application.yml
  3. Start Kafka and create required topics
  4. Run the application:
    ./gradlew bootRun

🧪 Testing

Run tests with:

./gradlew test

The test suite includes:

  • Unit tests
  • Integration tests
  • Service layer tests
  • Controller tests

🏗 Build & Deployment

Build the application:

./gradlew clean build

Create a Docker image:

./gradlew bootBuildImage

📊 Monitoring & Observability

The service includes:

  • Spring Boot Actuator endpoints for health checks and metrics
  • Prometheus metrics
  • Distributed tracing with OpenTelemetry

📄 License

This project is licensed under the terms of the LICENSE file.

About

Catalog Service for an e-commerce system

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages