# npv2k1/ktltweb architecture

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

- Interactive diagram: https://gitdiagram.com/npv2k1/ktltweb
- Repository: https://github.com/npv2k1/ktltweb

## Overview

##### High-Level Components

a) Frontend Layer:
- Static web application (HTML, CSS, JS)
- Key modules: Authentication, Shopping Cart, Orders, Products, Payment

b) Backend Layer (Spring Boot):
- REST API Services
- Security & JWT Authentication
- Domain Services
- Data Access Layer
- As green rectangles

c) Database Layer:
- MySQL 5.7

##### Detailed Component Breakdown

- Public Pages (index.html, lienhe.html)
- Auth Module (dangnhap.html)
- Shopping Module (giohang.html, thanhtoan.html)
- Order Management (donhang.html, orders.html)
- Shared Components (header.html)
- Service Layer (service.js, config.js)

Backend Components (Show as layered architecture):
- REST Controllers Layer (AuthResource, ProductResource, etc.)
- Service Layer (AuthService, ProductService, etc.)
- Repository Layer (ProductRepository, UserRepository, etc.)
- Domain Model Layer (Product, User, Order, etc.)
- Security Layer (JWT Configuration, WebSecurity)

##### Interactions and Flows

- Frontend to Backend communication via REST APIs
- Backend service interactions
- Data flow between layers
- Authentication flow with JWT
- Database operations

##### Key Technical Elements to Highlight

Security:
- JWT Authentication flow
- Security configurations
- Authentication entry points

Data Flow:
- DTO transformations (model package)
- Domain object mappings
- Repository interactions

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Styles
    classDef frontend fill:#e6f3ff,stroke:#666
    classDef backend fill:#e6ffe6,stroke:#666
    classDef database fill:#fff3e6,stroke:#666
    classDef security fill:#ffe6e6,stroke:#666
    classDef infrastructure fill:#f0f0f0,stroke:#666

    %% Frontend Layer
    subgraph Frontend
        FE_Public["Public Pages"]
        FE_Auth["Auth Module"]
        FE_Shop["Shopping Module"]
        FE_Order["Order Management"]
        FE_Shared["Shared Components"]
        FE_Service["Service Layer"]
        FE_Style["Styling"]
        FE_JS["JavaScript"]
    end

    %% Backend Layer
    subgraph Backend
        BE_REST["REST Controllers"]
        BE_Service["Service Layer"]
        BE_Repo["Repository Layer"]
        BE_Domain["Domain Model"]
        BE_Security["Security/JWT"]
        BE_Config["Configuration"]
        BE_DTO["DTOs"]
    end

    %% Database Layer
    DB[(MySQL Database)]:::database

    %% Frontend Component Relationships
    FE_Public --> FE_Service
    FE_Auth --> FE_Service
    FE_Shop --> FE_Service
    FE_Order --> FE_Service
    FE_Service --> BE_REST

    %% Backend Component Relationships
    BE_REST --> BE_Service
    BE_Service --> BE_Repo
    BE_Service --> BE_DTO
    BE_Repo --> BE_Domain
    BE_Domain --> DB
    BE_Security --> BE_REST

    %% Component Styling
    class FE_Public,FE_Auth,FE_Shop,FE_Order,FE_Shared,FE_Service,FE_Style,FE_JS frontend
    class BE_REST,BE_Service,BE_Repo,BE_Domain,BE_Config,BE_DTO backend
    class BE_Security security

    %% Click Events
    click FE_Public "https://github.com/npv2k1/ktltweb/blob/master/frontend/index.html"
    click FE_Auth "https://github.com/npv2k1/ktltweb/blob/master/frontend/dangnhap.html"
    click FE_Shop "https://github.com/npv2k1/ktltweb/blob/master/frontend/giohang.html"
    click FE_Order "https://github.com/npv2k1/ktltweb/blob/master/frontend/donhang.html"
    click FE_Shared "https://github.com/npv2k1/ktltweb/blob/master/frontend/components/header.html"
    click FE_Service "https://github.com/npv2k1/ktltweb/blob/master/frontend/js/service.js"
    click BE_REST "https://github.com/npv2k1/ktltweb/tree/master/backend/src/main/java/com/app/my_app/rest"
    click BE_Service "https://github.com/npv2k1/ktltweb/tree/master/backend/src/main/java/com/app/my_app/service"
    click BE_Repo "https://github.com/npv2k1/ktltweb/tree/master/backend/src/main/java/com/app/my_app/repos"
    click BE_Domain "https://github.com/npv2k1/ktltweb/tree/master/backend/src/main/java/com/app/my_app/domain"
    click BE_Security "https://github.com/npv2k1/ktltweb/tree/master/backend/src/main/java/com/app/my_app/config/jwt"
    click BE_Config "https://github.com/npv2k1/ktltweb/tree/master/backend/src/main/java/com/app/my_app/config"
    click BE_DTO "https://github.com/npv2k1/ktltweb/tree/master/backend/src/main/java/com/app/my_app/model"
    click FE_Style "https://github.com/npv2k1/ktltweb/tree/master/frontend/css"
    click FE_JS "https://github.com/npv2k1/ktltweb/tree/master/frontend/js"
```
