# winterchens/my-site architecture

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

- Interactive diagram: https://gitdiagram.com/winterchens/my-site
- Repository: https://github.com/winterchens/my-site

## Overview

##### Main Components
- Client Side (Browser/User Interface)
– Two entry-points: the public website and the administration backend.
– Serve static assets (HTML, CSS, JavaScript) from both the “file/avana” folder (for certain front-end pages) and the “src/main/resources/static” directories (for admin, error, site).
- Web Server / Application Layer
– The Spring Boot application (MySiteApplication.java) acting as the central controller.
– Controllers: Organized into public (HomeController) and administration (admin controllers) to handle user interactions.
– Service Layer: Business logic is split across services (e.g., ContentService, CommentService, UserService, etc.).
– Data Access Layer: DAOs and MyBatis mappers (in “src/main/resources/mapper”) for persistence operations.
– Utilities, interceptors, aspects (like WebLogAspect) are used for cross-cutting concerns such as logging, exception handling, and security.
- Data Storage
– A SQL database as indicated by the “lu_tale.sql” file, which holds the site data (articles, comments, user info, etc.).
– Caching (e.g., EhCache as mentioned in the README history).
- External Services
– A cloud storage/component (e.g., QiniuCloudService) for handling file uploads or images.
– Docker environment and associated tools (Dockerfile, docker-compose.yml, docker-build.sh) for containerization and deployment.

- Client Browser:
– Two types: Public users and Admin users.
- Web Server / Application Container:
– Represent the Spring Boot container and mark it as running within Docker.
– Within this container, show layers: Controller layer → Service layer → DAO layer → Database.
– Include a separate “view/rendering” indicator showing Thymeleaf templates that process and deliver the final HTML pages.
▫ Controllers depend on the Service layer.
▫ Services call the DAO layer and external APIs (like Qiniu Cloud).
▫ Interceptors and Aspects wrap around controllers for logging and error handling.
- Database Layer:
– Show an RDBMS component that stores the persistent data.
- External Service(s):
– Represent external dependencies like Qiniu Cloud for file storage.
– Optionally, represent logging or monitoring systems if applicable.

##### Architectural Patterns and Design Principles
- MVC Pattern: Clearly indicate separation between Model (data and domain objects), View (Thymeleaf templates, static resources), and Controller layers.
- Layered Architecture: Separate controllers, service, DAO, and utility components.
- Containerization: Note the Docker container environment which encapsulates the entire Spring Boot app.
- Modular Separation: There is clear division between front-end (static assets in “file/avana” and “src/main/resources/static”) and back-end (core Java code in “src/main/java/cn/luischen”).

##### Technologies and Frameworks to Highlight
- Spring Boot 2.0, Spring MVC
- MyBatis as the ORM (with XML mappers under “src/main/resources/mapper”)
- Thymeleaf for view rendering
- Docker for container management
- (Optional) Swagger for API documentation (Swagger2.java file present)

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Client Browsers
    PB["Client Browser (Public)"]:::client
    AB["Client Browser (Admin)"]:::client

    %% Docker Setup and Spring Boot Application
    Docker["Docker Setup"]:::docker
    DockerBuild["Docker Build Script"]:::docker
    Docker --> DockerBuild
    App["Spring Boot Application (Docker Container)"]:::app

    %% Connect clients and Docker to the Application
    PB --> App
    AB --> App
    Docker --> App

    %% Application Layers Subgraph
    subgraph "Application Layers"
        direction TB
        CtrlPub["Public Controllers"]:::controller
        CtrlAdmin["Admin Controllers"]:::controller
        Service["Service Layer"]:::service
        DAO["DAO Layer"]:::dao
        Mappers["MyBatis Mappers"]:::dao
        Thyme["Thymeleaf Rendering"]:::template
    end

    App --> CtrlPub
    App --> CtrlAdmin
    CtrlPub --> Service
    CtrlAdmin --> Service
    Service --> DAO
    DAO --> Mappers
    DAO --> DB["SQL Database"]:::db
    Service --> Qiniu["Qiniu Cloud Service"]:::external
    CtrlPub --> Thyme

    %% Cross-Cutting Utilities Subgraph
    subgraph "Cross-Cutting Concerns"
        direction TB
        Utility["Utility Classes"]:::utility
        Aspect["Aspects"]:::utility
        Interceptor["Interceptors"]:::utility
    end
    App --> Utility
    App --> Aspect
    App --> Interceptor

    %% Public Resources Subgraph
    subgraph "Public Resources"
        direction TB
        PS1["Static Assets (Public)"]:::template
        PS2["Templates (Public)"]:::template
    end

    %% Admin Resources Subgraph
    subgraph "Admin Resources"
        direction TB
        AS1["Static Assets (Admin)"]:::template
        AS2["Templates (Admin)"]:::template
    end

    %% Thymeleaf uses templates from resources
    Thyme --> PS2
    Thyme --> AS2

    %% Thymeleaf sends rendered views back to clients
    Thyme --> PB
    Thyme --> AB

    %% Click Events
    click App "https://github.com/winterchens/my-site/blob/master/src/main/java/cn/luischen/MySiteApplication.java"
    click CtrlPub "https://github.com/winterchens/my-site/tree/master/src/main/java/cn/luischen/controller"
    click CtrlAdmin "https://github.com/winterchens/my-site/tree/master/src/main/java/cn/luischen/controller/admin"
    click Service "https://github.com/winterchens/my-site/tree/master/src/main/java/cn/luischen/service"
    click DAO "https://github.com/winterchens/my-site/tree/master/src/main/java/cn/luischen/dao"
    click Mappers "https://github.com/winterchens/my-site/tree/master/src/main/resources/mapper"
    click PS1 "https://github.com/winterchens/my-site/tree/master/file/avana"
    click PS2 "https://github.com/winterchens/my-site/tree/master/src/main/resources/templates/site"
    click AS1 "https://github.com/winterchens/my-site/tree/master/src/main/resources/static/admin"
    click AS2 "https://github.com/winterchens/my-site/tree/master/src/main/resources/templates/admin"
    click Utility "https://github.com/winterchens/my-site/tree/master/src/main/java/cn/luischen/utils"
    click Aspect "https://github.com/winterchens/my-site/tree/master/src/main/java/cn/luischen/aspect"
    click Interceptor "https://github.com/winterchens/my-site/tree/master/src/main/java/cn/luischen/interceptor"
    click Qiniu "https://github.com/winterchens/my-site/blob/master/src/main/java/cn/luischen/api/QiniuCloudService.java"
    click DB "https://github.com/winterchens/my-site/blob/master/lu_tale.sql"
    click Docker "https://github.com/winterchens/my-site/tree/master/src/main/docker"
    click DockerBuild "https://github.com/winterchens/my-site/blob/master/docker-build.sh"

    %% Class Definitions for Styling
    classDef client fill:#ADD8E6,stroke:#000,stroke-width:1px;
    classDef app fill:#90EE90,stroke:#000,stroke-width:1px;
    classDef controller fill:#FFD700,stroke:#000,stroke-width:1px;
    classDef service fill:#FFB6C1,stroke:#000,stroke-width:1px;
    classDef dao fill:#FFA07A,stroke:#000,stroke-width:1px;
    classDef db fill:#FF6347,stroke:#000,stroke-width:1px;
    classDef external fill:#DDA0DD,stroke:#000,stroke-width:1px;
    classDef template fill:#E6E6FA,stroke:#000,stroke-width:1px;
    classDef utility fill:#AFEEEE,stroke:#000,stroke-width:1px;
    classDef docker fill:#F0E68C,stroke:#000,stroke-width:1px;
```
