# buianhtai1205/techstore architecture

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

- Interactive diagram: https://gitdiagram.com/buianhtai1205/techstore
- Repository: https://github.com/buianhtai1205/techstore

## Overview

##### Project type and purpose
- Type: A monolithic, Spring Boot-based e-commerce REST API with additional support for WebSocket chat, templated e-mail, and scheduled tasks.
- Purpose: Expose endpoints for product/catalog management, user authentication, orders, payment (VNPay), feedback, and real-time chat; persist data in a relational database; store files in S3; send emails via FreeMarker templates; run in Docker with CI/CD via Jenkins.

##### Break down the file structure into architectural layers
- Presentation Layer (Controllers):
– Packages: com.vn.TECHstore.controller.*
– Handles HTTP (REST), WebSocket connections (ChatController + WebSocketConfig), and serves FreeMarker email/order templates.
- Service Layer:
– com.vn.TECHstore.service.*
– Business logic for products, orders, users, feedback, payments, mail, scheduling (TaskSchedule).
- Data Access Layer (Repositories + Entities):
– com.vn.TECHstore.repository.* + com.vn.TECHstore.entity.*
– JPA Repositories (common, order, product, user, feedback) with some custom implementations; maps to underlying RDBMS tables.
- Configuration & Infrastructure:
– com.vn.TECHstore.config.*
– Security (JWT filter, CORS, custom auth handlers), Async, Swagger, S3 storage, payment (VNPay), WebSocket, FreeMarker, and environment-specific application-*.properties.
- Utilities & Validators:
– com.vn.TECHstore.util.* + com.vn.TECHstore.validator.*
– Shared constants, DateTimeUtils, FileUtils, validators.

##### External Systems & Resources
- Relational Database (MySQL/Postgres) holds all entities.
- Amazon S3 (or S3‐compatible) for file uploads (images, order attachments).
- VNPay payment gateway.
- SMTP/Email server for transactional emails (configured via FreeMarker templates).
- Clients (Web UI, Mobile apps) communicate over HTTPS.
- CI/CD pipeline: Jenkins server builds Docker image, pushes to Docker Hub, deploys via docker-compose.

##### Capturing Essential Details
- At least one sample flow end-to-end (e.g., Order placement: Client → OrderController → OrderService → Payment → Repository → Email notification).
- JWT filter sits between clients and controllers.
- Scheduling component separately (cron jobs).

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Clients
    Clients["Clients (Web UI / Mobile Apps)"]:::client
    Clients -->|HTTPS| JwtAuthFilter

    %% Spring Boot Application
    subgraph "Spring Boot Application"
        direction TB

        %% Entry Point
        TECHstoreApplication["TECHstoreApplication"]:::entry
        click TECHstoreApplication "https://github.com/buianhtai1205/techstore/blob/develop_phase2/src/main/java/com/vn/TECHstore/TECHstoreApplication.java"

        %% Security Filter
        JwtAuthFilter["JwtAuthFilter"]:::security
        click JwtAuthFilter "https://github.com/buianhtai1205/techstore/blob/develop_phase2/src/main/java/com/vn/TECHstore/config/jwt/JwtAuthFilter.java"

        %% Presentation Layer
        subgraph "Presentation Layer (Controllers)"
            direction TB
            ControllersPkg["com.vn.TECHstore.controller"]:::controller
            click ControllersPkg "https://github.com/buianhtai1205/techstore/tree/develop_phase2/src/main/java/com/vn/TECHstore/controller"
            ChatController["ChatController (WebSocket)"]:::controller
            click ChatController "https://github.com/buianhtai1205/techstore/blob/develop_phase2/src/main/java/com/vn/TECHstore/controller/user/ChatController.java"
        end
        JwtAuthFilter --> ControllersPkg
        ControllersPkg --> ChatController

        %% Services
        subgraph "Service Layer"
            direction TB
            ServicePkg["com.vn.TECHstore.service"]:::service
            click ServicePkg "https://github.com/buianhtai1205/techstore/tree/develop_phase2/src/main/java/com/vn/TECHstore/service"
            MailService["MailService"]:::service
            click MailService "https://github.com/buianhtai1205/techstore/blob/develop_phase2/src/main/java/com/vn/TECHstore/service/common/MailService.java"
            MailServiceImpl["MailServiceImpl"]:::service
            click MailServiceImpl "https://github.com/buianhtai1205/techstore/blob/develop_phase2/src/main/java/com/vn/TECHstore/service/common/impl/MailServiceImpl.java"
            VNPayService["VNPayService"]:::service
            click VNPayService "https://github.com/buianhtai1205/techstore/blob/develop_phase2/src/main/java/com/vn/TECHstore/config/payment/vnpay/VNPayService.java"
            TaskSchedule["TaskSchedule"]:::service
            click TaskSchedule "https://github.com/buianhtai1205/techstore/blob/develop_phase2/src/main/java/com/vn/TECHstore/schedule/TaskSchedule.java"
        end
        ChatController --> ServicePkg
        ServicePkg --> MailService
        ServicePkg --> VNPayService
        ServicePkg --> TaskSchedule

        %% Data Access
        subgraph "Data Access Layer"
            direction TB
            RepoPkg["com.vn.TECHstore.repository"]:::repo
            click RepoPkg "https://github.com/buianhtai1205/techstore/tree/develop_phase2/src/main/java/com/vn/TECHstore/repository"
            EntityPkg["com.vn.TECHstore.entity"]:::repo
            click EntityPkg "https://github.com/buianhtai1205/techstore/tree/develop_phase2/src/main/java/com/vn/TECHstore/entity"
        end
        ServicePkg --> RepoPkg
        RepoPkg --> EntityPkg

        %% Configuration & Infrastructure
        subgraph "Config & Infrastructure"
            direction TB
            SecurityConfig["SecurityConfig"]:::config
            click SecurityConfig "https://github.com/buianhtai1205/techstore/blob/develop_phase2/src/main/java/com/vn/TECHstore/config/SecurityConfig.java"
            JwtService["JwtService"]:::config
            click JwtService "https://github.com/buianhtai1205/techstore/blob/develop_phase2/src/main/java/com/vn/TECHstore/config/jwt/JwtService.java"
            AsyncConfig["AsyncConfig"]:::config
            click AsyncConfig "https://github.com/buianhtai1205/techstore/blob/develop_phase2/src/main/java/com/vn/TECHstore/config/AsyncConfig.java"
            SwaggerConfig["SwaggerConfig"]:::config
            click SwaggerConfig "https://github.com/buianhtai1205/techstore/blob/develop_phase2/src/main/java/com/vn/TECHstore/config/SwaggerConfig.java"
            S3Config["S3StorageConfig"]:::config
            click S3Config "https://github.com/buianhtai1205/techstore/blob/develop_phase2/src/main/java/com/vn/TECHstore/config/S3StorageConfig.java"
            FreeMarkerConfig["FreeMarkerConfig"]:::config
            click FreeMarkerConfig "https://github.com/buianhtai1205/techstore/blob/develop_phase2/src/main/java/com/vn/TECHstore/config/FreeMarkerConfig.java"
            VNPayConfig["VNPayConfig"]:::config
            click VNPayConfig "https://github.com/buianhtai1205/techstore/blob/develop_phase2/src/main/java/com/vn/TECHstore/config/payment/vnpay/VNPayConfig.java"
            WebSocketConfig["WebSocketConfig"]:::config
            click WebSocketConfig "https://github.com/buianhtai1205/techstore/blob/develop_phase2/src/main/java/com/vn/TECHstore/config/WebSocketConfig.java"
        end
        ControllersPkg -->|uses| SecurityConfig
        ControllersPkg -->|uses| WebSocketConfig

        %% Utilities & Validators
        subgraph "Utilities & Validators"
            direction TB
            UtilPkg["com.vn.TECHstore.util"]:::util
            click UtilPkg "https://github.com/buianhtai1205/techstore/tree/develop_phase2/src/main/java/com/vn/TECHstore/util"
            ValPkg["com.vn.TECHstore.validator"]:::util
            click ValPkg "https://github.com/buianhtai1205/techstore/tree/develop_phase2/src/main/java/com/vn/TECHstore/validator"
        end
        ServicePkg --> UtilPkg
        ServicePkg --> ValPkg

    end

    %% External Systems
    subgraph "External Systems"
        direction TB
        Database[(Relational DB)]:::db
        S3[(Amazon S3 Storage)]:::storage
        VNPay[(VNPay Gateway)]:::external
        Email[(SMTP Email Server)]:::external
    end
    RepoPkg -->|JPA| Database
    ServicePkg -->|PUT/GET files| S3
    VNPayService -->|Payment API| VNPay
    MailService -->|SMTP| Email
    TaskSchedule -->|cron jobs| Database

    %% CI/CD Pipeline
    subgraph "CI/CD Pipeline"
        direction TB
        Jenkins([Jenkins]):::ci
        DockerBuild["Docker Build"]:::ci
        DockerHub([Docker Hub]):::ci
        DockerCompose([Docker Compose Deployment]):::ci
    end
    Jenkins --> DockerBuild --> DockerHub --> DockerCompose --> TECHstoreApplication

    %% Styles
    classDef client fill:#ADD8E6,stroke:#333,stroke-width:1px
    classDef entry fill:#FFFFFF,stroke:#333,stroke-width:1px
    classDef security fill:#FFC0CB,stroke:#333,stroke-width:1px
    classDef controller fill:#B0E0E6,stroke:#333,stroke-width:1px
    classDef service fill:#AFEEEE,stroke:#333,stroke-width:1px
    classDef repo fill:#E0FFFF,stroke:#333,stroke-width:1px
    classDef config fill:#F5F5DC,stroke:#333,stroke-width:1px
    classDef util fill:#FFFACD,stroke:#333,stroke-width:1px
    classDef db fill:#98FB98,stroke:#333,stroke-width:1px
    classDef storage fill:#FFA500,stroke:#333,stroke-width:1px
    classDef external fill:#D8BFD8,stroke:#333,stroke-width:1px
    classDef ci fill:#D3D3D3,stroke:#333,stroke-width:1px
```
