# thangtranitwork/api-clothes-shop architecture

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

- Interactive diagram: https://gitdiagram.com/thangtranitwork/api-clothes-shop
- Repository: https://github.com/thangtranitwork/api-clothes-shop

## Overview

##### Main Components
- Client / Browser – Represents the user’s web browser interacting with the site.
- Web Server / Application Entry Point – The main application launched by ShopApp.java.
- Services – The business logic layer where AuthenticationService, CartService, OrderService, ProductService, etc. reside. Note that separate administrative services (e.g., ProductManageService, ColorManageService) exist.
- Repositories – Data access layer interacting with the database via Spring Data (repositories such as UserRepository, ProductRepository, OrderRepository, etc.).
- Entities / Domain Models – Representing the key business objects (User, Product, Order, Cart, etc.) that form the core of business logic.
- DTOs (Data Transfer Objects) – Grouped into request and response DTOs to pass data between the client and server.
- External Integrations – Components such as CloudinaryConfiguration for image hosting, VNPayConfig and VNPayService for payment processing, EmailService for notifications, and external authentication (OAuth2-related handlers).
- Infrastructure & Configuration – Configurations such as SecurityConfig, JwtAuthenticationEntryPoint, PasswordEncoderConfig, AsyncConfig which are important to initiate and secure the application.
- Database – Although not explicit in the file tree, the repositories indicate that a persistence layer (likely relational via Spring Data JPA) is used.

##### Incorporate Relevant Technologies & Details
- That Maven is used for build management.
- Mention that Spring (Spring Boot likely) is the underlying framework given the file layout and configuration classes.
- That the project leverages external services (Cloudinary for media, VNPay for payments, EmailService for verification/order emails).

## Diagram (Mermaid)

```mermaid
flowchart TD

    %% Client Layer
    Client["Client / Browser"]:::client

    %% Web Server / Application Entry Point
    WS["WebServer Entry - ShopApp.java"]:::server

    %% Presentation Layer
    subgraph "Presentation Layer: Controllers"
        GC["General Controllers"]:::controller
        AC["Admin Controllers"]:::controller
    end

    %% Application Layer
    subgraph "Application Layer: Services"
        GS["General Services"]:::service
        AS["Admin Services"]:::service
        VNS["VNPay Service"]:::service
        ES["Email Service"]:::service
    end

    %% Persistence Layer
    subgraph "Persistence Layer: Data Access"
        Repo["Repositories"]:::repository
        Entities["Domain Entities"]:::entity
        DTOs["DTOs"]:::dto
        DB["Database"]:::database
    end

    %% External Integrations & Configurations
    subgraph "External Integrations & Configurations"
        Cloud["Cloudinary Config"]:::external
        VNC["VNPay Config"]:::external
        SecC["Security Config"]:::security
        JWT["JWT Auth Entry Point"]:::security
        PEC["Password Encoder Config"]:::security
        AsyncC["Async Processing Config"]:::async
    end

    %% Inter-layer Interactions
    Client -->|"request"| GC
    Client -->|"request"| AC

    WS -->|"initializes"| GC
    WS -->|"initializes"| AC
    WS -->|"initializes"| GS
    WS -->|"initializes"| AS

    GC -->|"delegates"| GS
    AC -->|"delegates"| AS

    GS -->|"calls"| Repo
    AS -->|"calls"| Repo

    Repo -->|"manages"| Entities
    Repo -->|"uses"| DTOs
    Repo -->|"read/write"| DB

    GS -->|"external"| ES
    GS -->|"external"| VNS
    GS -->|"integrates"| Cloud
    VNS -->|"configuredBy"| VNC

    GS -->|"secures"| SecC
    SecC -->|"handles"| JWT
    SecC -->|"encodes"| PEC
    ES -->|"async"| AsyncC

    %% Styling and Classes
    classDef client fill:#AED6F1,stroke:#1B4F72,stroke-width:2px;
    classDef server fill:#E8DAEF,stroke:#6C3483,stroke-width:2px;
    classDef controller fill:#F9E79F,stroke:#B7950B,stroke-width:2px;
    classDef service fill:#A9DFBF,stroke:#1D8348,stroke-width:2px;
    classDef repository fill:#F5CBA7,stroke:#B9770E,stroke-width:2px;
    classDef entity fill:#D2B4DE,stroke:#6C3483,stroke-width:2px;
    classDef dto fill:#D5F5E3,stroke:#1E8449,stroke-width:2px;
    classDef database fill:#85C1E9,stroke:#2E86C1,stroke-width:2px,stroke-dasharray: 5, 5;
    classDef external fill:#FAD7A0,stroke:#D35400,stroke-width:2px;
    classDef security fill:#F1948A,stroke:#922B21,stroke-width:2px;
    classDef async fill:#F6DDCC,stroke:#BA4A00,stroke-width:2px;

    %% Click Events
    click WS "https://github.com/thangtranitwork/api-clothes-shop/blob/main/src/main/java/com/clothes/ShopApp.java"
    click GC "https://github.com/thangtranitwork/api-clothes-shop/tree/main/src/main/java/com/clothes/noc/controller"
    click AC "https://github.com/thangtranitwork/api-clothes-shop/tree/main/src/main/java/com/clothes/noc/admin/controller"
    click GS "https://github.com/thangtranitwork/api-clothes-shop/tree/main/src/main/java/com/clothes/noc/service"
    click AS "https://github.com/thangtranitwork/api-clothes-shop/tree/main/src/main/java/com/clothes/noc/admin/service"
    click Repo "https://github.com/thangtranitwork/api-clothes-shop/tree/main/src/main/java/com/clothes/noc/repository"
    click Entities "https://github.com/thangtranitwork/api-clothes-shop/tree/main/src/main/java/com/clothes/noc/entity"
    click DTOs "https://github.com/thangtranitwork/api-clothes-shop/tree/main/src/main/java/com/clothes/noc/dto"
    click Cloud "https://github.com/thangtranitwork/api-clothes-shop/blob/main/src/main/java/com/clothes/noc/config/CloudinaryConfiguration.java"
    click VNC "https://github.com/thangtranitwork/api-clothes-shop/blob/main/src/main/java/com/clothes/noc/config/VNPayConfig.java"
    click VNS "https://github.com/thangtranitwork/api-clothes-shop/blob/main/src/main/java/com/clothes/noc/service/VNPayService.java"
    click ES "https://github.com/thangtranitwork/api-clothes-shop/blob/main/src/main/java/com/clothes/noc/service/EmailService.java"
    click SecC "https://github.com/thangtranitwork/api-clothes-shop/blob/main/src/main/java/com/clothes/noc/config/SecurityConfig.java"
    click JWT "https://github.com/thangtranitwork/api-clothes-shop/blob/main/src/main/java/com/clothes/noc/config/JwtAuthenticationEntryPoint.java"
    click PEC "https://github.com/thangtranitwork/api-clothes-shop/blob/main/src/main/java/com/clothes/noc/config/PasswordEncoderConfig.java"
    click AsyncC "https://github.com/thangtranitwork/api-clothes-shop/blob/main/src/main/java/com/clothes/noc/config/AsyncConfig.java"
```
