Skip to content

Enterprise-grade product comparison system built with Java microservices based in Clean Architecture, deployed on AWS EKS with complete CI/CD pipeline.

License

Notifications You must be signed in to change notification settings

vynnydev/product-comparison-platform

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

43 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Product Comparison Platform

Core Technologies

Java Spring Boot Maven PostgreSQL RabbitMQ Docker

AWS Cloud Services

AWS Amazon EKS Amazon RDS Amazon MQ AWS Bedrock Amazon ECR CloudWatch

DevSecOps & Infrastructure

Terraform Kubernetes ArgoCD GitHub Actions Trivy SonarQube

Architecture & Patterns

Clean Architecture Event Driven Microservices DDD SOLID

Status & Metrics

Build Coverage Version License

Enterprise-grade Event-Driven Microservices Platform with AI Integration

Clean Architecture β€’ SOLID Principles β€’ Domain-Driven Design β€’ Event-Driven Architecture

Features β€’ Architecture β€’ Quick Start β€’ Documentation β€’ Deployment


πŸ“‹ Table of Contents


🎯 Overview

Product Comparison Platform is a production-ready, event-driven microservices platform designed for e-commerce product analysis and comparison. Built with Clean Architecture principles, the system leverages AI-powered insights using AWS Bedrock (Claude 4.5) to deliver intelligent product recommendations.

🌟 Key Highlights

βœ… Event-Driven Architecture    β†’ RabbitMQ message broker with async processing
βœ… Clean Architecture           β†’ Domain-centric design, framework-independent
βœ… Microservices Pattern        β†’ 2 independent services with clear boundaries
βœ… AI Integration               β†’ AWS Bedrock Claude 4.5 for product analysis
βœ… DevSecOps Ready              β†’ GitHub Actions, Trivy, SonarQube, ArgoCD
βœ… Cloud Native                 β†’ Kubernetes/EKS deployment with Terraform IaC
βœ… Production Ready             β†’ Multi-AZ, auto-scaling, monitoring, backup

✨ Features

Core Capabilities

Feature Description
πŸ›οΈ Product Management Full CRUD operations with REST API
πŸ€– AI-Powered Analysis Automatic product insights via AWS Bedrock
πŸ” Advanced Search Filter by category, price range, ratings
πŸ“Š Product Comparison Side-by-side comparison with AI recommendations
πŸ“¨ Event-Driven Async processing with RabbitMQ messaging
πŸ”„ Real-time Updates Product changes trigger automatic AI analysis

Technical Features

πŸ—οΈ  Clean Architecture        πŸ“¦ Value Objects (Money, Rating)
🎯  SOLID Principles          πŸ”Œ Repository Pattern
πŸ“‘  Event-Driven Messaging    🐳 Docker Compose support
☸️  Kubernetes Ready          πŸ§ͺ Comprehensive test coverage
πŸ”  Input Validation          πŸ“– OpenAPI/Swagger docs

AWS Cloud Architecture

Production Environment - Scalable, highly available deployment on AWS

AWS Cloud Architecture

Infrastructure:

  • Amazon EKS - Kubernetes cluster (v1.28) across 2 AZs
  • Amazon MQ - Managed RabbitMQ (Multi-AZ)
  • Amazon RDS - PostgreSQL 15 (Multi-AZ, Read Replicas)
  • Amazon ECR - Container image registry
  • AWS Bedrock - Claude 4.5 Sonnet for AI analysis
  • Application Load Balancer - Traffic distribution
  • CloudWatch - Logs, metrics, and monitoring

High Availability:

βœ… Multi-AZ deployment (1a, 1b)
βœ… Auto-scaling: Product Service (3 replicas), AI Service (2 replicas)
βœ… RDS automated backups + read replicas
βœ… Health checks + graceful shutdown

DevSecOps Pipeline

CI/CD & Infrastructure as Code

DevSecOps Pipeline

Tools:

Stage Tool Purpose
πŸ”§ Source Control GitHub Version control, triggers
⚑ CI/CD GitHub Actions Build, test, deploy automation
πŸ›‘οΈ Security Scan Trivy Container vulnerability scanning
πŸ“Š Code Quality SonarQube Static analysis, code coverage
πŸ—οΈ Infrastructure Terraform IaC for AWS resources
πŸ”„ GitOps Deploy ArgoCD Kubernetes deployment sync
πŸ“¦ Registry Amazon ECR Docker image storage

Pipelines:

  1. Infrastructure Pipeline (Terraform)

    • Init β†’ Validate β†’ Plan β†’ Apply β†’ Provision AWS resources
  2. Application Pipeline (Microservices)

    • Build β†’ Security Scan β†’ Docker Build β†’ Push ECR β†’ Deploy via ArgoCD

πŸ—οΈ System Architecture

Docker Compose Architecture

Development Environment - Run locally with Docker Compose

Docker Compose Architecture

Components:

  • Product Service (Port 8080) - REST API, Event Publisher
  • AI Service (Port 8081) - Event Consumer, AI Analysis
  • RabbitMQ (Ports 5672, 15672) - Message Broker
  • PostgreSQL - Databases: productdb, aidb
# Start all services
docker-compose up -d

# View logs
docker-compose logs -f

# Access services
http://localhost:8080  # Product Service API
http://localhost:8081  # AI Service API
http://localhost:15672 # RabbitMQ Management (guest/guest)

πŸ”¬ Microservices Architecture

Product Service Architecture

Request Flow - HTTP REST API with Clean Architecture

Product Service Architecture

Flow:

1️⃣ Client sends HTTP POST request
2️⃣ ProductController receives and validates input
3️⃣ ProductMapper converts DTO β†’ Domain
4️⃣ CreateProductUseCase executes business logic
5️⃣ Product Entity validates itself (Value Objects)
6️⃣ ProductRepository saves to database
7️⃣ ProductRepositoryAdapter converts Domain β†’ JPA Entity
8️⃣ JPA persists to PostgreSQL (productdb)
9️⃣ **Publishes event** to RabbitMQ (product.created)

Endpoints:

  • POST /api/products - Create product
  • GET /api/products - List products
  • GET /api/products/{id} - Get product by ID
  • PUT /api/products/{id} - Update product
  • DELETE /api/products/{id} - Delete product
  • GET /api/products/category/{category} - Filter by category
  • GET /api/products/search?keyword=x - Search products

AI Service Architecture

Event-Driven Flow - Async AI analysis via RabbitMQ

AI Service Architecture

Flow:

1️⃣ Product-Service publishes event to RabbitMQ
2️⃣ RabbitMQ routes to product.ai.analysis.queue
3️⃣ ProductEventListener consumes message
4️⃣ Routes to AnalyzeProductUseCase
5️⃣ UseCase calls AIService (port)
6️⃣ LambdaAIAdapter calls AWS Bedrock Claude 4.5
7️⃣ AI generates analysis & insights (strengths, weaknesses, score)
8️⃣ Creates ProductAnalysis entity
9️⃣ AnalysisRepository saves to PostgreSQL (aidb)
πŸ”Ÿ Analysis available via REST API

AI Providers:

  • Production: AWS Bedrock Claude 4.5 (@Profile("cloud"))
  • Development: Mock AI Adapter (@Profile("mock"))

Analysis Output:

{
  "productId": 1,
  "analysisText": "High-quality flagship smartphone...",
  "aiScore": 92,
  "insights": ["Premium build quality", "Excellent camera"],
  "strengths": ["Performance", "Design"],
  "weaknesses": ["Price premium"],
  "recommendations": ["Best for power users"]
}

πŸ› οΈ Tech Stack

Backend Services

Technology Version Purpose
β˜• Java 21 LTS Programming language
πŸƒ Spring Boot 3.2.0 Application framework
πŸ—„οΈ Spring Data JPA 3.2.0 Data access layer
🐰 RabbitMQ 3.12 Message broker
🐘 PostgreSQL 15 Relational database
🧠 AWS Bedrock Claude 4.5 AI analysis (production)
πŸ”¨ Maven 3.9+ Build tool

DevOps & Cloud

Technology Version Purpose
🐳 Docker 24.0+ Containerization
☸️ Kubernetes 1.28 Container orchestration
πŸ—οΈ Terraform 1.6+ Infrastructure as Code
⚑ GitHub Actions - CI/CD pipeline
πŸ”„ ArgoCD 2.9+ GitOps deployment
πŸ›‘οΈ Trivy Latest Security scanning
πŸ“Š SonarQube 10.3+ Code quality
☁️ AWS - Cloud provider (EKS, RDS, MQ, Bedrock)

Testing & Documentation

πŸ§ͺ JUnit 5             πŸ“– Springdoc OpenAPI
🎭 Mockito             πŸ“ Swagger UI
βœ… REST Assured         πŸ” Jacoco (Coverage)

πŸš€ Quick Start

Prerequisites

# Required
Java 21+
Maven 3.9+
Docker & Docker Compose

# Check versions
java --version
mvn --version
docker --version
docker-compose --version

Local Development (Docker Compose)

# 1. Clone repository
git clone https://github.com/vynnydev/product-comparison-platform.git
cd product-comparison-platform

# 2. Start all services
docker-compose up -d

# 3. Verify services are running
docker-compose ps

# 4. View logs
docker-compose logs -f product-service
docker-compose logs -f ai-service

# 5. Test the API
curl http://localhost:8080/api/products

Service Endpoints

Service URL Credentials
πŸ“¦ Product Service http://localhost:8080 -
πŸ€– AI Service http://localhost:8081 -
πŸ“– Swagger (Product) http://localhost:8080/swagger-ui.html -
πŸ“– Swagger (AI) http://localhost:8081/swagger-ui.html -
🐰 RabbitMQ Management http://localhost:15672 guest / guest

πŸ“‘ API Documentation

Product Service API

Base URL: http://localhost:8080/api

Create Product

curl -X POST http://localhost:8080/api/products \
  -H "Content-Type: application/json" \
  -d '{
    "name": "MacBook Pro 16 M3 Max",
    "description": "Powerful laptop for developers",
    "imageUrl": "https://example.com/macbook.jpg",
    "price": 3499.99,
    "rating": 4.9,
    "category": "Laptops",
    "inStock": true,
    "specifications": {
      "processor": "M3 Max",
      "ram": "64GB",
      "storage": "2TB SSD"
    }
  }'

Response: 201 Created

{
  "id": 1,
  "name": "MacBook Pro 16 M3 Max",
  "price": 3499.99,
  "rating": 4.9,
  "createdAt": "2024-11-27T19:00:00"
}

🎯 This triggers an event β†’ AI Service automatically analyzes the product

Get AI Analysis

curl http://localhost:8081/api/ai/product/1

Response: 200 OK

{
  "productId": 1,
  "aiScore": 95,
  "analysisText": "Premium professional laptop with exceptional performance...",
  "insights": [
    "Top-tier M3 Max processor delivers outstanding performance",
    "64GB RAM ideal for heavy multitasking",
    "Excellent build quality and design"
  ],
  "strengths": ["Performance", "Display", "Build Quality"],
  "weaknesses": ["High price point", "Limited upgradeability"],
  "recommendations": ["Best for professional developers and content creators"]
}

Interactive API Documentation

Access Swagger UI for complete API documentation:

Swagger UI


πŸ§ͺ Testing

Run All Tests

# Product Service tests
cd backend/services/product-service
mvn clean test

# AI Service tests
cd backend/services/ai-service
mvn clean test

# Integration tests
cd backend/scripts/integrated-tests/product-service
./integrated-tests.sh

Test Coverage

# Generate coverage report
mvn clean test jacoco:report

# View report
open target/site/jacoco/index.html

Current Coverage: 85%

Test Results

Test Event Flow

# Test complete event-driven flow
cd backend/scripts/messaging
./demo-events.sh

# Monitor RabbitMQ
./monitor-rabbitmq.sh

RabbitMQ Events


🚒 Deployment

Local Development

Requirements: Docker & Docker Compose

# Start services
docker-compose up -d

# Scale services
docker-compose up -d --scale product-service=3

# Stop services
docker-compose down

# Clean everything
docker-compose down -v

Production (AWS EKS)

Quick Overview:

# 1. Provision infrastructure with Terraform
cd infrastructure/terraform
terraform init
terraform plan
terraform apply

# 2. Deploy applications with ArgoCD
kubectl apply -f infrastructure/k8s/argocd/

# 3. Sync applications
argocd app sync product-service
argocd app sync ai-service

Infrastructure Components:

βœ… VPC (10.0.0.0/16)
βœ… EKS Cluster (2 AZs)
βœ… Amazon MQ (RabbitMQ Multi-AZ)
βœ… RDS PostgreSQL (Multi-AZ + Read Replicas)
βœ… Application Load Balancer
βœ… ECR Repositories
βœ… CloudWatch Logging

πŸ“‚ Project Structure

Monorepo Organization

product-comparison-platform/
β”œβ”€β”€ backend/
β”‚   β”œβ”€β”€ services/
β”‚   β”‚   β”œβ”€β”€ product-service/          # πŸ“¦ Product Management
β”‚   β”‚   β”‚   β”œβ”€β”€ src/
β”‚   β”‚   β”‚   β”‚   β”œβ”€β”€ main/java/.../
β”‚   β”‚   β”‚   β”‚   β”‚   β”œβ”€β”€ adapter/      # Controllers, DTOs
β”‚   β”‚   β”‚   β”‚   β”‚   β”œβ”€β”€ domain/       # Entities, Value Objects
β”‚   β”‚   β”‚   β”‚   β”‚   β”œβ”€β”€ usecase/      # Business Logic
β”‚   β”‚   β”‚   β”‚   β”‚   └── config/       # Spring Config
β”‚   β”‚   β”‚   β”‚   └── resources/
β”‚   β”‚   β”‚   β”œβ”€β”€ Dockerfile
β”‚   β”‚   β”‚   └── pom.xml
β”‚   β”‚   β”‚
β”‚   β”‚   └── ai-service/                # πŸ€– AI Analysis
β”‚   β”‚       β”œβ”€β”€ src/
β”‚   β”‚       β”‚   β”œβ”€β”€ main/java/.../
β”‚   β”‚       β”‚   β”‚   β”œβ”€β”€ adapter/
β”‚   β”‚       β”‚   β”‚   β”‚   β”œβ”€β”€ input/messaging/  # Event Listeners
β”‚   β”‚       β”‚   β”‚   β”‚   └── output/ai/        # Bedrock/Mock Adapters
β”‚   β”‚       β”‚   β”‚   β”œβ”€β”€ domain/
β”‚   β”‚       β”‚   β”‚   β”œβ”€β”€ usecase/
β”‚   β”‚       β”‚   β”‚   └── config/
β”‚   β”‚       β”‚   └── resources/
β”‚   β”‚       β”œβ”€β”€ Dockerfile
β”‚   β”‚       └── pom.xml
β”‚   β”‚
β”‚   β”œβ”€β”€ scripts/
β”‚   β”‚   β”œβ”€β”€ messaging/
β”‚   β”‚   β”‚   β”œβ”€β”€ demo-events.sh         # Test event flow
β”‚   β”‚   β”‚   └── monitor-rabbitmq.sh    # Monitor messages
β”‚   β”‚   └── integrated-tests/          # Integration tests
β”‚   β”‚
β”‚   └── docker-compose.yaml             # Local environment
β”‚
β”œβ”€β”€ infrastructure/                    
β”‚   β”œβ”€β”€ terraform/
β”‚   β”‚   β”œβ”€β”€ modules/
β”‚   β”‚   β”‚   β”œβ”€β”€ vpc/
β”‚   β”‚   β”‚   β”œβ”€β”€ eks/
β”‚   β”‚   β”‚   β”œβ”€β”€ rds/
β”‚   β”‚   β”‚   └── mq/
β”‚   β”‚   β”œβ”€β”€ main.tf
β”‚   β”‚   └── variables.tf
β”‚   └── scripts/
β”‚
β”œβ”€β”€ docs/
β”‚   β”œβ”€β”€ architecture/
β”‚   β”‚   └── images/                    # Architecture diagrams
β”‚   └── images/                        # Screenshots
β”‚
β”œβ”€β”€ .github/
β”‚   └── workflows/
β”‚       β”œβ”€β”€ ci-product-service.yml
β”‚       β”œβ”€β”€ ci-ai-service.yml
β”‚       └── terraform.yml
β”‚
└── README.md

Service Architecture (Clean Architecture)

Each service follows the same structure:

adapter/
  β”œβ”€β”€ input/          # REST Controllers, Event Listeners
  β”œβ”€β”€ output/         # Repositories, External APIs
  └── mapper/         # DTOs ↔ Domain conversion

domain/
  β”œβ”€β”€ model/          # Entities (Aggregate Roots)
  β”œβ”€β”€ valueobject/    # Money, Rating, etc.
  β”œβ”€β”€ repository/     # Ports (Interfaces)
  └── exception/      # Domain exceptions

usecase/              # Application business logic
  β”œβ”€β”€ CreateProductUseCase.java
  β”œβ”€β”€ AnalyzeProductUseCase.java
  └── ...

config/               # Spring configuration

πŸ’Ž Best Practices

Clean Architecture Principles

βœ… Domain Independence       β†’ Core logic has zero framework dependencies
βœ… Dependency Inversion      β†’ All dependencies point inward
βœ… Testability              β†’ Easy to test without mocking frameworks
βœ… Flexibility              β†’ Swap frameworks without changing business logic

SOLID Principles

Principle Implementation
Single Responsibility Each class has one reason to change
Open/Closed Open for extension, closed for modification
Liskov Substitution Implementations interchangeable via interfaces
Interface Segregation Focused, specific interfaces
Dependency Inversion Depend on abstractions, not concretions

Event-Driven Patterns

πŸ“¨ Async Communication     β†’ Services communicate via events
πŸ”„ Eventual Consistency   β†’ Data synchronized asynchronously
πŸ“Š Event Sourcing Ready   β†’ Events as source of truth
🎯 Decoupled Services     β†’ Services don't know about each other

🀝 Contributing

Contributions are welcome! Please follow these guidelines:

Workflow

# 1. Fork the repository
# 2. Create feature branch
git checkout -b feature/amazing-feature

# 3. Make changes and test
mvn clean test

# 4. Commit with conventional commits
git commit -m "feat: add amazing feature"

# 5. Push and create PR
git push origin feature/amazing-feature

Commit Convention

Follow Conventional Commits:

feat:      New feature
fix:       Bug fix
docs:      Documentation changes
refactor:  Code refactoring (no behavior change)
test:      Adding or updating tests
chore:     Maintenance tasks
ci:        CI/CD changes

Code Quality

# Run all checks before committing
mvn clean verify                    # Build + tests
mvn spotless:check                  # Code formatting
mvn checkstyle:check               # Style violations

πŸ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.


πŸ‘¨β€πŸ’» Author

Vinicius Prudencio (Vini)
Backend Developer & DevOps Engineer

  • πŸš€ Specialized in Clean Architecture & Cloud-Native Solutions
  • ☁️ AWS | Terraform | Kubernetes | ArgoCD | GitHub Actions
  • πŸ’Ό LinkedIn
  • πŸ™ GitHub

πŸ™ Acknowledgments

  • Uncle Bob - Clean Architecture principles
  • Eric Evans - Domain-Driven Design concepts
  • Spring Team - Excellent framework and documentation
  • AWS - Cloud infrastructure and AI services
  • Open Source Community - Amazing tools and libraries

🌟 Made with ❀️ using Clean Architecture, Event-Driven Design, and AI

Star this repo

If you found this helpful, please ⭐ star the repository!


Branches:

  • main / develop - Docker Compose (Local Development)
  • improvement - AWS EKS + Terraform (Production Ready)

About

Enterprise-grade product comparison system built with Java microservices based in Clean Architecture, deployed on AWS EKS with complete CI/CD pipeline.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published