# selin-topcu/spring-boot-microservices-product-project architecture

> Architecture diagram of the GitHub repository selin-topcu/spring-boot-microservices-product-project, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-01-02). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/selin-topcu/spring-boot-microservices-product-project
- Repository: https://github.com/selin-topcu/spring-boot-microservices-product-project

## Overview

##### Main Components

a. API Gateway Layer:
- API Gateway service as the entry point
- Keycloak integration for security (evident from mysql_keycloak_data)
- Routing configuration (Routes.java)

b. Microservices:
- Product Service (MongoDB-based)
- Order Service (MySQL-based)
- Inventory Service (MySQL-based)

c. Databases:
- MongoDB for Product Service
- MySQL instances for Order and Inventory Services
- Keycloak MySQL database

##### Component Relationships

- Client requests → API Gateway
- API Gateway → Individual Microservices
- Order Service → Inventory Service (via InventoryClient)
- Services → Their respective databases

##### Architectural Patterns to Highlight

- API Gateway Pattern
- Microservices Pattern
- Database per Service Pattern
- OAuth2/OpenID Connect (via Keycloak)

**[Client Applications] → [API Gateway + Security]**
- ↓
**[Product Service] [Order Service] [Inventory Service]**
- ↓               ↓               ↓
- [MongoDB]        [MySQL]         [MySQL]

##### Additional Elements

Include:
- Service Discovery mechanism
- Database migration paths (Flyway present in services)
- Inter-service communication (REST)

##### Technical Details to Note

For each service, show:
- Spring Boot Framework
- Database Type
- Communication Protocols
- Security Integration Points

##### Specific Implementation Notes

- MVC pattern within each service:
- Controllers
- Services
- Repositories
- Models/DTOs

##### Infrastructure Elements

- Docker containers (evident from docker-compose files)
- Volume mounts for persistence
- Network segregation

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Style Definitions
    classDef frontend fill:#2196F3,stroke:#000,color:white
    classDef gateway fill:#4CAF50,stroke:#000,color:white
    classDef service fill:#FF9800,stroke:#000,color:white
    classDef database fill:#9C27B0,stroke:#000,color:white
    classDef security fill:#f44336,stroke:#000,color:white

    %% Client Layer
    Client["Angular Frontend"]:::frontend

    %% Gateway Layer
    subgraph Gateway
        APIGW["API Gateway"]
        KC["Keycloak Auth"]
        SEC["Security Config"]
    end

    %% Microservices Layer
    subgraph Services
        PS["Product Service"]
        IS["Inventory Service"]
        OS["Order Service"]
    end

    %% Database Layer
    MongoDB[(MongoDB)]:::database
    InventoryDB[(MySQL)]:::database
    OrderDB[(MySQL)]:::database

    %% Connections
    Client --> APIGW
    APIGW --> KC
    APIGW --> SEC
    APIGW --> PS
    APIGW --> IS
    APIGW --> OS
    PS --> MongoDB
    IS --> InventoryDB
    OS --> OrderDB
    OS --> IS

    %% Component Styling
    class APIGW gateway
    class KC security
    class SEC security
    class PS,IS,OS service

    %% Click Events
    click APIGW "https://github.com/selin-topcu/Spring-Boot-Microservices-Product-Project/blob/main/api-gateway/src/main/java/com/selintopcu/api_gateway/ApiGatewayApplication.java"
    click SEC "https://github.com/selin-topcu/Spring-Boot-Microservices-Product-Project/blob/main/api-gateway/src/main/java/com/selintopcu/api_gateway/config/SecurityConfig.java"
    click KC "https://github.com/selin-topcu/Spring-Boot-Microservices-Product-Project/tree/main/api-gateway/volume-data/mysql_keycloak_data"
    click PS "https://github.com/selin-topcu/Spring-Boot-Microservices-Product-Project/blob/main/product-service/src/main/java/com/selintopcu/microservices/product/ProductServiceApplication.java"
    click IS "https://github.com/selin-topcu/Spring-Boot-Microservices-Product-Project/blob/main/inventory-service/src/main/java/com/selintopcu/microservices/inventory_service/InventoryServiceApplication.java"
    click OS "https://github.com/selin-topcu/Spring-Boot-Microservices-Product-Project/blob/main/order-service/src/main/java/com/selintopcu/microservices/order/OrderServiceApplication.java"
    click MongoDB "https://github.com/selin-topcu/Spring-Boot-Microservices-Product-Project/tree/main/product-service/data"
    click InventoryDB "https://github.com/selin-topcu/Spring-Boot-Microservices-Product-Project/tree/main/inventory-service/docker/mysql/data"
    click OrderDB "https://github.com/selin-topcu/Spring-Boot-Microservices-Product-Project/tree/main/order-service/docker/mysql/data"

    %% Legend
    subgraph Legend
        Frontend["Frontend"]:::frontend
        GatewayLegend["Gateway"]:::gateway
        ServiceLegend["Microservice"]:::service
        DBLegend["Database"]:::database
        SecurityLegend["Security"]:::security
    end
```
