# eduardosantana1313/gerenciamento-pedidos architecture

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

- Interactive diagram: https://gitdiagram.com/eduardosantana1313/gerenciamento-pedidos
- Repository: https://github.com/eduardosantana1313/gerenciamento-pedidos

## Overview

##### Main Components

a) External Interface Layer:
- Nginx Load Balancer (evident from docker-compose-lb.yaml)
- REST API endpoints (v1)

b) Application Core:
- Order Service (Spring Boot application)
- Use Cases Layer (CreateOrder, DetailOrders, ListOrders)
- Domain Layer (Order, Item, Status)
- Application Services Layer

c) Infrastructure:
- Amazon SQS Queue
- Database (with Flyway migrations)
- Scheduled Jobs (OrderJob)

##### Specific Components Detail

For each component, show:
- Order Controller: Entry point for REST operations
- Use Cases: Business logic implementation
- Domain Models: Core business entities
- Infrastructure Services: External integrations

##### Key Architectural Patterns to Highlight

- Clean Architecture (evident from the package structure)
- CQRS-like pattern (separate read/write operations)
- Event-driven architecture (SQS integration)
- Repository pattern (for data access)

##### Technical Elements

- Java 17 & Spring Boot
- Flyway Migrations
- Amazon SQS
- Nginx Load Balancer
- Test Containers
- Gatling Performance Tests

Create distinct sections for:
a) Runtime Flow:
- API requests through load balancer
- Message processing via SQS
- Database operations

b) Testing Infrastructure:
- Test Containers
- MVC Tests
- Performance Tests with Gatling

## Diagram (Mermaid)

```mermaid
graph TB
    %% Styles
    classDef external fill:#A0D8EF,stroke:#333
    classDef api fill:#90EE90,stroke:#333
    classDef usecase fill:#98FB98,stroke:#333
    classDef domain fill:#FFB6C1,stroke:#333
    classDef infra fill:#D3D3D3,stroke:#333
    classDef test fill:#FFE4B5,stroke:#333

    %% External Interface Layer
    LB["Nginx Load Balancer"]:::external
    click LB "https://github.com/EduardoSantAna1313/gerenciamento-pedidos/blob/main/nginx/nginx.conf"

    %% API Layer
    subgraph API
        CTRL["Order Controller"]:::api
        REQ["Order Request DTO"]:::api
        RESP["Order Response DTO"]:::api
        EH["Exception Handler"]:::api
    end
    click CTRL "https://github.com/EduardoSantAna1313/gerenciamento-pedidos/blob/main/order.service/src/main/java/br/com/edu/order/infra/rest/v1/OrderController.java"
    click REQ "https://github.com/EduardoSantAna1313/gerenciamento-pedidos/blob/main/order.service/src/main/java/br/com/edu/order/infra/rest/v1/request/OrderRequest.java"
    click RESP "https://github.com/EduardoSantAna1313/gerenciamento-pedidos/blob/main/order.service/src/main/java/br/com/edu/order/infra/rest/v1/response/OrderResponse.java"
    click EH "https://github.com/EduardoSantAna1313/gerenciamento-pedidos/blob/main/order.service/src/main/java/br/com/edu/order/infra/rest/v1/DefaultExceptionHandler.java"

    %% Use Cases Layer
    subgraph UseCases
        CREATE["Create Order UseCase"]:::usecase
        LIST["List Orders UseCase"]:::usecase
        DETAIL["Detail Orders UseCase"]:::usecase
    end
    click CREATE "https://github.com/EduardoSantAna1313/gerenciamento-pedidos/blob/main/order.service/src/main/java/br/com/edu/order/application/usecases/CreateOrderUseCase.java"
    click LIST "https://github.com/EduardoSantAna1313/gerenciamento-pedidos/blob/main/order.service/src/main/java/br/com/edu/order/application/usecases/ListOrdersUseCase.java"
    click DETAIL "https://github.com/EduardoSantAna1313/gerenciamento-pedidos/blob/main/order.service/src/main/java/br/com/edu/order/application/usecases/DetailOrdersUseCase.java"

    %% Domain Layer
    subgraph Domain
        ORDER["Order"]:::domain
        ITEM["Item"]:::domain
        STATUS["Status"]:::domain
        REPO["Order Repository Interface"]:::domain
        ERRORS["Domain Errors"]:::domain
    end
    click ORDER "https://github.com/EduardoSantAna1313/gerenciamento-pedidos/blob/main/order.service/src/main/java/br/com/edu/order/domain/Order.java"
    click ITEM "https://github.com/EduardoSantAna1313/gerenciamento-pedidos/blob/main/order.service/src/main/java/br/com/edu/order/domain/Item.java"
    click STATUS "https://github.com/EduardoSantAna1313/gerenciamento-pedidos/blob/main/order.service/src/main/java/br/com/edu/order/domain/Status.java"
    click REPO "https://github.com/EduardoSantAna1313/gerenciamento-pedidos/blob/main/order.service/src/main/java/br/com/edu/order/domain/repository/OrderRepository.java"
    click ERRORS "https://github.com/EduardoSantAna1313/gerenciamento-pedidos/tree/main/order.service/src/main/java/br/com/edu/order/domain/errors/"

    %% Infrastructure Layer
    subgraph Infrastructure
        SQS["SQS Configuration"]:::infra
        DB[(Database)]:::infra
        MIGRATIONS["Flyway Migrations"]:::infra
        JOB["Order Job"]:::infra
    end
    click SQS "https://github.com/EduardoSantAna1313/gerenciamento-pedidos/blob/main/order.service/src/main/java/br/com/edu/order/infra/aws/SqsConfig.java"
    click MIGRATIONS "https://github.com/EduardoSantAna1313/gerenciamento-pedidos/blob/main/order.service/src/main/resources/db/migration/V20241120_1000__create_tables.sql"
    click JOB "https://github.com/EduardoSantAna1313/gerenciamento-pedidos/blob/main/order.service/src/main/java/br/com/edu/order/infra/jobs/OrderJob.java"

    %% Testing Layer
    subgraph Testing
        MVC["MVC Tests"]:::test
        PERF["Gatling Performance Tests"]:::test
    end
    click MVC "https://github.com/EduardoSantAna1313/gerenciamento-pedidos/blob/main/order.service/src/test/java/br/com/edu/order/application/service/OrderServiceMvcTest.java"
    click PERF "https://github.com/EduardoSantAna1313/gerenciamento-pedidos/blob/main/tests/performance/src/test/kotlin/simulations/OrderSimulation.kt"

    %% Relationships
    LB --> CTRL
    CTRL --> REQ
    CTRL --> RESP
    CTRL --> EH
    CTRL --> CREATE
    CTRL --> LIST
    CTRL --> DETAIL
    CREATE --> ORDER
    LIST --> ORDER
    DETAIL --> ORDER
    ORDER --> ITEM
    ORDER --> STATUS
    ORDER --> REPO
    ORDER --> ERRORS
    REPO --> DB
    CREATE --> SQS
    SQS --> JOB
    JOB --> DB
    DB --> MIGRATIONS

    %% Legend
    subgraph Legend
        L1["External Services"]:::external
        L2["API Components"]:::api
        L3["Use Cases"]:::usecase
        L4["Domain Components"]:::domain
        L5["Infrastructure"]:::infra
        L6["Testing"]:::test
    end
```
