# jovijesc/ecom-product-catalog-admin architecture

> Architecture diagram of the GitHub repository jovijesc/ecom-product-catalog-admin, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-01-03). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/jovijesc/ecom-product-catalog-admin
- Repository: https://github.com/jovijesc/ecom-product-catalog-admin

## Overview

##### Main Components

a. API Layer (Controllers)
- CategoryController
- ProductController
- REST endpoints
- Exception handling

b. Application Layer (Use Cases)
- Category Management
- Create
- Update
- Retrieve
- List
- Product Management
- Create
- Update
- Retrieve
- List
- Product Image Management
- Upload
- Get

c. Domain Layer
- Aggregates:
- Category
- Product
- ProductImage
- Store
- Value Objects
- Domain Services
- Gateway Interfaces

d. Infrastructure Layer
- Database Access (MySQL)
- Storage Service (AWS S3)
- Gateway Implementations
- Configuration

##### Architecture Pattern Representation

- Outer circle: Infrastructure (REST API, MySQL, AWS S3)
- Middle circle: Application (Use Cases)
- Inner circle: Domain (Entities, Value Objects)

##### Component Relationships

- External clients accessing REST endpoints
- Controllers calling Use Cases
- Use Cases accessing Domain entities through Gateways
- Infrastructure implementations of Gateways
- Storage service interaction for product images

##### Specific Elements

a. External Systems:
- Client Applications
- MySQL Database
- AWS S3 Storage

b. Internal Components:
- REST Controllers
- Use Case implementations
- Domain Entities
- Gateway interfaces
- Repository implementations
- Storage service

##### Data Flow Indicators

Flow of:
- HTTP requests/responses
- Use Case commands/queries
- Database operations
- File storage operations

##### Additional Details

Annotations for:
- Authentication/Authorization (if present)
- Validation layers
- Error handling
- Database migrations
- Configuration properties

##### Separation of concerns between layers

Remember to maintain clean architecture principles in the visualization, showing how the dependencies point inward toward the domain layer, and how the infrastructure adapts to the domain rather than vice versa.

This will provide a clear understanding of the system's architecture while maintaining the appropriate level of detail for a principal software engineer to understand the complete system design.

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph External
        Client(["Client Applications"])
        S3[("AWS S3")]:::external
        MySQL[("MySQL Database")]:::database
    end

    subgraph API["API Layer"]
        direction TB
        Controllers["Controllers"]:::api
        ExHandler["Exception Handler"]:::api
        APIDefinitions["API Definitions"]:::api
    end

    subgraph Application["Application Layer"]
        direction TB
        CategoryUseCases["Category Use Cases"]:::usecase
        ProductUseCases["Product Use Cases"]:::usecase
        ImageUseCases["Product Image Use Cases"]:::usecase
    end

    subgraph Domain["Domain Layer"]
        direction TB
        CategoryAggregate["Category Aggregate"]:::domain
        ProductAggregate["Product Aggregate"]:::domain
        DomainExceptions["Domain Exceptions"]:::domain
        
        subgraph Gateways["Gateway Interfaces"]
            CategoryGateway["Category Gateway"]:::gateway
            ProductGateway["Product Gateway"]:::gateway
        end
    end

    subgraph Infrastructure["Infrastructure Layer"]
        direction TB
        CategoryMySQL["Category MySQL Gateway"]:::infra
        ProductMySQL["Product MySQL Gateway"]:::infra
        StorageService["Storage Service"]:::infra
        Config["Configuration"]:::infra
    end

    %% Relationships
    Client --> Controllers
    Controllers --> CategoryUseCases & ProductUseCases
    ExHandler --> Controllers
    
    CategoryUseCases --> CategoryAggregate
    ProductUseCases --> ProductAggregate
    ImageUseCases --> ProductAggregate
    
    CategoryUseCases --> CategoryGateway
    ProductUseCases --> ProductGateway
    
    CategoryMySQL --> CategoryGateway
    ProductMySQL --> ProductGateway
    CategoryMySQL --> MySQL
    ProductMySQL --> MySQL
    StorageService --> S3

    %% Click Events
    click Controllers "https://github.com/jovijesc/ecom-product-catalog-admin/tree/main/infrastructure/src/main/java/com/ecom/catalog/admin/infrastructure/api/controllers/"
    click ExHandler "https://github.com/jovijesc/ecom-product-catalog-admin/blob/main/infrastructure/src/main/java/com/ecom/catalog/admin/infrastructure/api/controllers/GlobalExceptionHandler.java"
    click APIDefinitions "https://github.com/jovijesc/ecom-product-catalog-admin/tree/main/infrastructure/src/main/java/com/ecom/catalog/admin/infrastructure/api/"
    
    click CategoryUseCases "https://github.com/jovijesc/ecom-product-catalog-admin/tree/main/application/src/main/java/com/ecom/catalog/admin/application/category/"
    click ProductUseCases "https://github.com/jovijesc/ecom-product-catalog-admin/tree/main/application/src/main/java/com/ecom/catalog/admin/application/product/"
    click ImageUseCases "https://github.com/jovijesc/ecom-product-catalog-admin/tree/main/application/src/main/java/com/ecom/catalog/admin/application/product/image/"
    
    click CategoryAggregate "https://github.com/jovijesc/ecom-product-catalog-admin/tree/main/domain/src/main/java/com/ecom/catalog/admin/domain/category/"
    click ProductAggregate "https://github.com/jovijesc/ecom-product-catalog-admin/tree/main/domain/src/main/java/com/ecom/catalog/admin/domain/product/"
    click DomainExceptions "https://github.com/jovijesc/ecom-product-catalog-admin/tree/main/domain/src/main/java/com/ecom/catalog/admin/domain/exceptions/"
    click CategoryGateway "https://github.com/jovijesc/ecom-product-catalog-admin/blob/main/domain/src/main/java/com/ecom/catalog/admin/domain/category/CategoryGateway.java"
    click ProductGateway "https://github.com/jovijesc/ecom-product-catalog-admin/blob/main/domain/src/main/java/com/ecom/catalog/admin/domain/product/ProductGateway.java"
    
    click CategoryMySQL "https://github.com/jovijesc/ecom-product-catalog-admin/blob/main/infrastructure/src/main/java/com/ecom/catalog/admin/infrastructure/category/CategoryMySQLGateway.java"
    click ProductMySQL "https://github.com/jovijesc/ecom-product-catalog-admin/blob/main/infrastructure/src/main/java/com/ecom/catalog/admin/infrastructure/product/DefaultProductGateway.java"
    click StorageService "https://github.com/jovijesc/ecom-product-catalog-admin/tree/main/infrastructure/src/main/java/com/ecom/catalog/admin/infrastructure/services/"
    click Config "https://github.com/jovijesc/ecom-product-catalog-admin/tree/main/infrastructure/src/main/java/com/ecom/catalog/admin/infrastructure/configuration/"

    %% Styles
    classDef api fill:#2196F3,stroke:#000,color:#fff
    classDef usecase fill:#4CAF50,stroke:#000,color:#fff
    classDef domain fill:#FFC107,stroke:#000
    classDef gateway fill:#FF9800,stroke:#000
    classDef infra fill:#9E9E9E,stroke:#000,color:#fff
    classDef database fill:#607D8B,stroke:#000,color:#fff
    classDef external fill:#F44336,stroke:#000,color:#fff
```
