# dz-adman/ecom architecture

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

- Interactive diagram: https://gitdiagram.com/dz-adman/ecom
- Repository: https://github.com/dz-adman/ecom

## Overview

##### Main Components
- Boot Module – This is the entry point of the application (ECom-Boot) and contains the main application class plus configurations (e.g., OpenApiConfig). It essentially “boots” the application.
- Classes Module – Contains common DTOs, stubs, entities, and repository definitions. These shared classes facilitate data structures and business rules across the modules.
- Core Module – Holds core configuration and cross-cutting concerns: Spring Security setups, custom logging, user registration, login contexts, asynchronous job handling and more.
- Feature Modules:
– Orders – Implements order management (integrated with a state machine for order life-cycle management and persistence via JPA).
– Payments – Contains payment integration and related functionality.
– Products – Manages product inventory with filtering (using JPA and QueryDsl).
– Support – Provides customer support features such as ticket creation and processing.
– User – Handles user profile APIs and cart management.

##### Relationships and Interactions
- The Boot module is the application’s starting point that wires up all modules. It serves as the interface for incoming HTTP requests.
- The Core module offers shared configurations and services (security, logging, asynchronous processing) that are leveraged by all subsequent modules.
- The Classes module provides common data transfer objects (DTOs), persistence entities, and repository interfaces that are used by the individual feature modules (Orders, Products, Payments, Support, User).
- Each feature module has its controller, service, repository, and possibly additional utility layers. These modules interact with the persistence/database layer (JPA) and are exposed via API endpoints.
- External systems such as email services (triggered by email event listeners in Core, Orders, and User modules) and possibly payment gateways are also part of the ecosystem even if not directly visible in the file structure.

##### Architectural Patterns and Design Principles
- Modularization – The application is structured into distinct modules, each representing a bounded context (Orders, Products, etc.)
- Layered Architecture – Each module separates concerns: controllers (API layer), services (business logic), repositories (data access), and common/shared classes (DTOs/entities).
- Cross-cutting Concerns – The Core module abstracts security, logging, asynchronous processing, and exception handling.
- Use of State Machine – The Orders module specifically uses a Spring State Machine configuration for order processing flow.

##### Technologies, Frameworks, and Libraries
- Spring Boot (as the backbone) with a multi-module Maven structure.
- Spring Security for authentication/authorization (configured in Core).
- JPA for persistence across modules.
- QueryDsl used in Products for advanced query filtering.
- Spring State Machine used in the Orders module.
- Email Event handling for registration confirmation and status updates.
- OpenAPI (as seen in Boot’s OpenApiConfig) for API documentation.

##### Elements
- Components/Modules: Boot, Core, Classes, Orders, Payments, Products, Support, and User.
- Labels: Annotate each component with its primary responsibility (e.g., “Handles order state transitions using a Spring State Machine” in Orders).
- External Interfaces: Optionally include external systems (payment gateways, email providers) that interact with specific modules.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% External Client
    Client["Client (Web/Mobile)"]:::external
    
    %% Boot Module
    Boot["Boot Module (Entry point)"]:::bootcolor

    %% Core & Shared Modules
    subgraph "Core & Shared"
        Core["Core Module (Security, Logging, Async)"]:::corecolor
        Classes["Classes Module (Shared DTOs/Entities)"]:::corecolor
    end

    %% Feature Modules
    subgraph "Feature Modules"
        Orders["Orders Module (Order management, StateMachine)"]:::featurecolor
        Payments["Payments Module (Payment integration)"]:::featurecolor
        Products["Products Module (Product inventory, QueryDsl)"]:::featurecolor
        Support["Support Module (Customer support)"]:::featurecolor
        User["User Module (User profiles, Cart)"]:::featurecolor
    end

    %% Persistence Layer
    DB["Database (JPA Persistence)"]:::database

    %% External Systems
    PaymentGateway["Payment Gateway"]:::external
    EmailService["Email Service"]:::external

    %% Connections: Client to Boot
    Client -->|"sendsRequest"| Boot

    %% Boot wiring to Core & Shared
    Boot -->|"wiresCore"| Core
    Boot -->|"wiresShared"| Classes

    %% Boot routes requests to Feature Modules
    Boot -->|"routesRequest"| Orders
    Boot -->|"routesRequest"| Payments
    Boot -->|"routesRequest"| Products
    Boot -->|"routesRequest"| Support
    Boot -->|"routesRequest"| User

    %% Feature Modules use Core & Shared
    Orders -->|"uses"| Core
    Orders -->|"uses"| Classes
    Payments -->|"uses"| Core
    Payments -->|"uses"| Classes
    Products -->|"uses"| Core
    Products -->|"uses"| Classes
    Support -->|"uses"| Core
    Support -->|"uses"| Classes
    User -->|"uses"| Core
    User -->|"uses"| Classes

    %% Feature Modules persist to Database
    Orders -->|"persist"| DB
    Payments -->|"persist"| DB
    Products -->|"persist"| DB
    Support -->|"persist"| DB
    User -->|"persist"| DB

    %% External integrations
    Payments -->|"calls"| PaymentGateway
    Orders -->|"triggers"| EmailService
    User -->|"triggers"| EmailService
    Core -->|"sendsEmail"| EmailService

    %% Click Events
    click Boot "https://github.com/dz-adman/ecom/blob/main/ECom-Boot/src/main/java/com/ad/ecom/EComBootApplication.java"
    click Classes "https://github.com/dz-adman/ecom/tree/main/ECom-Classes/src/main/java/com/ad/ecom/"
    click Core "https://github.com/dz-adman/ecom/tree/main/ECom-Core/src/main/java/com/ad/ecom/core/"
    click Orders "https://github.com/dz-adman/ecom/blob/main/ECom-Orders/src/main/java/com/ad/ecom/config/EComOrdersSMConfig.java"
    click Payments "https://github.com/dz-adman/ecom/tree/main/ECom-Payments/"
    click Products "https://github.com/dz-adman/ecom/tree/main/ECom-Products/src/main/java/com/ad/ecom/products/"
    click Support "https://github.com/dz-adman/ecom/blob/main/ECom-Support/src/main/java/com/ad/ecom/controller/SupportController.java"
    click User "https://github.com/dz-adman/ecom/tree/main/ECom-User/src/main/java/com/ad/ecom/user/"

    %% Styles
    classDef bootcolor fill:#ADD8E6,stroke:#000,stroke-width:2px;
    classDef corecolor fill:#90EE90,stroke:#000,stroke-width:2px;
    classDef featurecolor fill:#FFA500,stroke:#000,stroke-width:2px;
    classDef external fill:#FF6347,stroke:#000,stroke-width:2px;
    classDef database fill:#D3D3D3,stroke:#000,stroke-width:2px;
```
