# namnguyen1409/assignment architecture

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

- Interactive diagram: https://gitdiagram.com/namnguyen1409/assignment
- Repository: https://github.com/namnguyen1409/assignment

## Overview

##### Project type and purpose
- This is a monolithic, full‐stack Java web application (packaged as a WAR) built with Spring MVC, Spring Security, Spring Data JPA/Hibernate, JSP views, and static resources.
- From the packages (`com.assignment.models.entities.shop`, `api`, `controllers/role/user`, `service`), it appears to be an “all-in-one” e-commerce assignment platform with user authentication (including OAuth2 and 2FA), buying, selling, and an e-wallet subsystem.

##### File structure
Top‐level directories:
- `python/` – utility scripts for enum/repo code generation and SQL loads (external preprocessing).
- `src/main/java/com/assignment/` – Java source split into subpackages:
– `api/` – REST‐style endpoints (CategoryAPI, UserAPI, etc.)
– `controllers/` – MVC controllers (AdminController, HomeController, auth, role/user sub‐controllers)
– `filter/` – servlet filters (AntiBotFilter, JwtAuthenticationFilter, etc.)
– `security/` – custom UserDetails, JWT providers, OAuth2 client config
– `service/` – business logic (EmailService, ImageUploadService, TOTPService, QRCodeService…)
– `models/entities` & `models/repositories` – JPA entities and Spring Data repositories organized by domain (auth, ewallet, shop, location).
– `validation/` – custom validation annotations and validators.
– `config/` – Spring configuration (DispatcherServlet initializer, Web MVC config, data initialization).
- `src/main/resources` – persistence config, properties, SQL DDL/data scripts.
- `src/main/webapp` – JSP view templates (under WEB‐INF/views), static assets (CSS, JS, images, TinyMCE editor, videos).

##### README
- Bare-bones description: “project for all in one service.” We infer it provides a unified platform for authentication (login, OAuth2, TOTP), catalog/category management, user roles (buyer, seller, admin), purchase workflow, e-wallet operations, and file uploads (images/videos).

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Client
    Client["Client (Browser/Mobile)"]:::presentation

    %% Server Box
    subgraph "Server (Tomcat + Spring)"
        direction TB

        %% Configuration
        subgraph "Configuration"
            direction TB
            Init["MainWebAppInitializer"]:::config
            MvcCfg["MvcConfig"]:::config
        end

        %% Filter Chain
        subgraph "Filter Chain"
            direction TB
            Filters["AntiBotFilter, JwtAuthenticationFilter, ResourcesFilter"]:::presentation
        end

        %% Dispatcher
        Dispatcher["DispatcherServlet"]:::presentation

        %% Controllers
        subgraph "Controllers"
            direction TB
            MVC["MVC Controllers"]:::presentation
            API["REST/API Controllers"]:::presentation
        end

        %% Service Layer
        subgraph "Service Layer"
            direction TB
            Services["Business Services (EmailService, TOTPService, ImageUploadService, etc.)"]:::business
        end

        %% Repository Layer
        subgraph "Repository Layer"
            direction TB
            Repos["Spring Data JPA Repositories"]:::persistence
        end

    end

    %% Database
    DB["Relational Database"]:::persistence

    %% External Services
    subgraph "External Services"
        direction TB
        OAuth["OAuth2 Identity Provider"]:::external
        SMTP["SMTP/Email Service"]:::external
        Storage["Media/Object Storage"]:::external
    end

    %% Flows
    Client -->|"HTTP/HTTPS"| Filters
    Init --> Filters
    Init --> Dispatcher
    MvcCfg --> Dispatcher
    Filters --> Dispatcher
    Dispatcher -->|"forward"| MVC
    Dispatcher -->|"forward"| API
    MVC -->|"calls"| Services
    API -->|"calls"| Services
    Services -->|"uses"| Repos
    Repos -->|"JDBC"| DB

    %% Auth & External
    MVC -->|"OAuth2 Token"| OAuth
    API -->|"OAuth2 Token"| OAuth
    Services -->|"send OTP/email"| SMTP

    %% File Upload
    API -->|"upload media"| Services
    Services -->|"store media"| Storage

    %% Click Events
    click Filters "https://github.com/namnguyen1409/assignment/tree/main/src/main/java/com/assignment/filter"
    click Init "https://github.com/namnguyen1409/assignment/blob/main/src/main/java/com/assignment/config/MainWebAppInitializer.java"
    click MvcCfg "https://github.com/namnguyen1409/assignment/blob/main/src/main/java/com/assignment/config/MvcConfig.java"
    click OAuth "https://github.com/namnguyen1409/assignment/blob/main/src/main/java/com/assignment/config/OAuth2ClientConfig.java"
    click JWTProv "https://github.com/namnguyen1409/assignment/blob/main/src/main/java/com/assignment/security/JwtTokenProvider.java"
    click RefreshProv "https://github.com/namnguyen1409/assignment/blob/main/src/main/java/com/assignment/security/RefreshTokenProvider.java"
    click CUDetails "https://github.com/namnguyen1409/assignment/blob/main/src/main/java/com/assignment/security/CustomUserDetails.java"
    click MVC "https://github.com/namnguyen1409/assignment/tree/main/src/main/java/com/assignment/controllers"
    click API "https://github.com/namnguyen1409/assignment/tree/main/src/main/java/com/assignment/api"
    click Services "https://github.com/namnguyen1409/assignment/tree/main/src/main/java/com/assignment/service"
    click Repos "https://github.com/namnguyen1409/assignment/tree/main/src/main/java/com/assignment/models/repositories"

    %% Styles
    classDef presentation fill:#AED6F1,stroke:#1F618D,color:#1B4F72
    classDef business fill:#A9DFBF,stroke:#27AE60,color:#196F3D
    classDef persistence fill:#F9E79F,stroke:#B7950B,color:#7D6608
    classDef external fill:#D5D8DC,stroke:#808B96,color:#1C2833
    classDef config fill:#F5B7B1,stroke:#C0392B,color:#641E16
```
