# b20dcat186trandangthuc/learforwork-java-spring-mvc architecture

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

- Interactive diagram: https://gitdiagram.com/b20dcat186trandangthuc/learforwork-java-spring-mvc
- Repository: https://github.com/b20dcat186trandangthuc/learforwork-java-spring-mvc

## Overview

##### Main Components
- Bootstrapping & Configuration:
- LaptopshopApplication.java serves as the main entry point.
- The config package (with classes such as SecurityConfiguration.java, WebMvcConfig.java, and CustomSuccessHandler.java) encapsulates the application’s security, MVC, and any custom behaviors.
- Controller Layer:
- Separated into “admin” and “client” controllers.
- Under “src/main/java/org/example/laptopshop/controller”, you have packages for admin (DashboardController, OrderController, ProductController, UserController) and client (HomePageController, ItemController) which handle requests from the respective segments of the application.
- Service Layer:
- Contains business logic (OrderService, ProductService, UserService, UploadService, and a CustomUserDetailsService for authentication details).
- Validation services under the “validator” subpackage enforce domain-specific rules.
- Data (Repository/Domain) Layer:
- Domain models (such as Cart, Order, Product, User, etc.) interpret data.
- Repository interfaces handle persistence (like CartRepository, OrderRepository, ProductRepository, and UserRepository).
- Presentation Layer (View & Assets):
- JSP files under “src/main/webapp/WEB-INF/view” offer the UI for both admin and client interfaces.
- Static resources—CSS, JavaScript, images, and external libraries—are stored in subdirectories beneath “src/main/webapp/resources” and “src/main/webapp/resources/client”.

##### Relationships and Interactions
- Repository layer and Domain models below the service layer as the data persistence mechanism.
- Lastly, include the configuration/bootstrapping element (LaptopshopApplication and configuration classes) as the foundation that initializes all these components.

##### Architectural Patterns and Technologies
- Separation of Concerns: Emphasize how controllers delegate to services, which in turn interact with repositories.
- Web Security: Include the security configuration as a critical cross-cutting concern.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Presentation Layer
    subgraph "Presentation Layer (View & Assets)"
        JSP_Admin["JSP Views (Admin)"]:::ui
        JSP_Client["JSP Views (Client)"]:::ui
        RES["Static Resources"]:::ui
    end

    %% Controller Layer
    subgraph "Controller Layer"
        subgraph "Admin Controllers"
            DC["DashboardController"]:::controller
            OC["OrderController"]:::controller
            PC["ProductController"]:::controller
            UC["UserController"]:::controller
        end
        subgraph "Client Controllers"
            HPC["HomePageController"]:::controller
            IC["ItemController"]:::controller
        end
    end

    %% Security / Auth Component
    SA["Security Interceptors"]:::security

    %% Service Layer
    subgraph "Service Layer"
        OS["OrderService"]:::service
        PS["ProductService"]:::service
        US["UserService"]:::service
        UP["UploadService"]:::service
        CUDS["CustomUserDetailsService"]:::service
        VS["Validation Services"]:::service
    end

    %% Data (Repository/Domain) Layer
    subgraph "Data (Repository/Domain) Layer"
        DM["Domain Models & DTOs"]:::data
        RI["Repository Interfaces"]:::data
    end

    %% Bootstrapping & Configuration
    subgraph "Bootstrapping & Configuration"
        LSA["LaptopshopApplication"]:::configuration
        SEC_CONF["Security/MVC Configurations"]:::configuration
    end

    %% Flow of Request handling (vertical flow)
    JSP_Admin ---|"request"| DC
    JSP_Client ---|"request"| HPC
    RES ---|"request"| DC

    DC ---|"auth"| SA
    OC ---|"auth"| SA
    PC ---|"auth"| SA
    UC ---|"auth"| SA
    HPC ---|"auth"| SA
    IC ---|"auth"| SA

    SA ---|"calls"| OS
    SA ---|"calls"| PS
    SA ---|"calls"| US
    SA ---|"calls"| UP
    SA ---|"calls"| CUDS
    SA ---|"triggers"| VS

    OS ---|"calls"| RI
    PS ---|"calls"| RI
    US ---|"calls"| RI
    UP ---|"calls"| RI
    CUDS ---|"calls"| RI
    VS ---|"validates"| DM

    %% Bootstrapping & Configuration influences all layers (dashed lines)
    LSA -.-> JSP_Admin
    LSA -.-> HPC
    LSA -.-> DC
    LSA -.-> OS
    LSA -.-> DM

    SEC_CONF -.-> SA
    SEC_CONF -.-> HPC
    SEC_CONF -.-> DC
    SEC_CONF -.-> OS
    SEC_CONF -.-> RI

    %% Styles
    classDef ui fill:#cce5ff,stroke:#004085,stroke-width:2px;
    classDef controller fill:#d4edda,stroke:#155724,stroke-width:2px;
    classDef service fill:#fff3cd,stroke:#856404,stroke-width:2px;
    classDef data fill:#f8d7da,stroke:#721c24,stroke-width:2px;
    classDef configuration fill:#d1ecf1,stroke:#0c5460,stroke-width:2px;
    classDef security fill:#e2e3e5,stroke:#383d41,stroke-width:2px;

    %% Click Events
    click LSA "https://github.com/b20dcat186trandangthuc/learforwork-java-spring-mvc/blob/master/src/main/java/org/example/laptopshop/LaptopshopApplication.java"
    click SEC_CONF "https://github.com/b20dcat186trandangthuc/learforwork-java-spring-mvc/tree/master/src/main/java/org/example/laptopshop/config"
    click DC "https://github.com/b20dcat186trandangthuc/learforwork-java-spring-mvc/blob/master/src/main/java/org/example/laptopshop/controller/admin/DashboardController.java"
    click OC "https://github.com/b20dcat186trandangthuc/learforwork-java-spring-mvc/blob/master/src/main/java/org/example/laptopshop/controller/admin/OrderController.java"
    click PC "https://github.com/b20dcat186trandangthuc/learforwork-java-spring-mvc/blob/master/src/main/java/org/example/laptopshop/controller/admin/ProductController.java"
    click UC "https://github.com/b20dcat186trandangthuc/learforwork-java-spring-mvc/blob/master/src/main/java/org/example/laptopshop/controller/admin/UserController.java"
    click HPC "https://github.com/b20dcat186trandangthuc/learforwork-java-spring-mvc/blob/master/src/main/java/org/example/laptopshop/controller/client/HomePageController.java"
    click IC "https://github.com/b20dcat186trandangthuc/learforwork-java-spring-mvc/blob/master/src/main/java/org/example/laptopshop/controller/client/ItemController.java"
    click OS "https://github.com/b20dcat186trandangthuc/learforwork-java-spring-mvc/blob/master/src/main/java/org/example/laptopshop/service/OrderService.java"
    click PS "https://github.com/b20dcat186trandangthuc/learforwork-java-spring-mvc/blob/master/src/main/java/org/example/laptopshop/service/ProductService.java"
    click US "https://github.com/b20dcat186trandangthuc/learforwork-java-spring-mvc/blob/master/src/main/java/org/example/laptopshop/service/UserService.java"
    click UP "https://github.com/b20dcat186trandangthuc/learforwork-java-spring-mvc/blob/master/src/main/java/org/example/laptopshop/service/UploadService.java"
    click CUDS "https://github.com/b20dcat186trandangthuc/learforwork-java-spring-mvc/blob/master/src/main/java/org/example/laptopshop/service/CustomUserDetailsService.java"
    click VS "https://github.com/b20dcat186trandangthuc/learforwork-java-spring-mvc/tree/master/src/main/java/org/example/laptopshop/service/validator"
    click DM "https://github.com/b20dcat186trandangthuc/learforwork-java-spring-mvc/tree/master/src/main/java/org/example/laptopshop/domain"
    click RI "https://github.com/b20dcat186trandangthuc/learforwork-java-spring-mvc/tree/master/src/main/java/org/example/laptopshop/repository"
    click JSP_Admin "https://github.com/b20dcat186trandangthuc/learforwork-java-spring-mvc/tree/master/src/main/webapp/WEB-INF/view/admin"
    click JSP_Client "https://github.com/b20dcat186trandangthuc/learforwork-java-spring-mvc/tree/master/src/main/webapp/WEB-INF/view/client"
    click RES "https://github.com/b20dcat186trandangthuc/learforwork-java-spring-mvc/tree/master/src/main/webapp/resources"
```
