# usualheart/zhoubao architecture

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

- Interactive diagram: https://gitdiagram.com/usualheart/zhoubao
- Repository: https://github.com/usualheart/zhoubao

## Overview

##### Main Components
- Frontend Client: The Vue application (located in the “vue” directory) contains the user-facing components. It handles views like the login page, Markdown editor, table-based weekly reports, and image/PDF preview, with appropriate routing (vue/src/router) and components.
- Backend Server: The Spring Boot application (Java code under “src/main/java/zhoubao”) that implements controllers (e.g., HtmlRESTController, ImgRESTController, UserRESTController, ZhouBaoRESTController), security configurations (MyAuthenticationSuccessHandler, SecurityByJdbcConfig), and business logic.
- Database: MySQL is used to store user accounts, weekly report data, and configurations. The project provides a SQL file “zhoubao.sql” for database initialization.
- File and Object Storage: The “modules/oss” package includes different storage implementations (e.g., LocalStorageService, MinioStorageService, OSSFactory) that manage file uploads and persistent storage for weekly reports.
- Static Resources: The “src/main/resources/static” folder, along with the Vue/static folder, serves static assets including CSS, JavaScript (bundled Vue app), images, and markdown templates.

##### Relationships and Interactions
- The Backend communicates with the MySQL database using repository classes. Represent the data access layer explicitly.
- The Backend interacts with a file storage abstraction via the OSS module to handle file uploads and file persistence.
- Security flows exist (via Spring Security configured in MyAuthenticationSuccessHandler and SecurityByJdbcConfig) to handle login and session management.

##### Key Architectural Patterns and Design Principles
- Layered Architecture: Clearly separate presentation (Vue client), service/controller logic (Spring Boot REST controllers and business logic), data access (repository and domain layers), and configuration/security.
- MVC Pattern: The backend mostly follows a model–view–controller pattern where request-handling controllers coordinate with domain objects and repositories.
- Separation of Concerns: Notice the splitting between authentication/security, file storage (oss modules), and data repositories.
- RESTful API Design: The backend controllers are designed to expose REST endpoints for the Vue frontend.
- Configuration-Based Deployment: The application uses an external YAML configuration (application.yml) and Maven for dependency management and build lifecycle.

##### Relevant Technologies, Frameworks, and Libraries
- Spring Boot (for backend operations, dependency injection, and web functionality)
- Spring Security (for securing REST endpoints)
- Maven (for building and dependency management)
- MyBatis/JPA-style repositories (via the Repository classes for database interactions)
- Vue.js (for the client-side application)
- Webpack (as seen in the vue/build folder, used in the Vue project)
- MySQL (as the relational database, as indicated by the SQL file and configuration)
- File storage libraries or integrations (local file systems and possibly Minio)

##### Elements
- From “Vue Frontend” to “Spring Boot Controllers” for REST API calls.
- From “Spring Boot Controllers” to “Data Repositories” and “OSS Module”.
- From backend components to the “MySQL Database”.
- Security flows separately to show how authentication and authorization checks are handled before processing requests.

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "Frontend Layer"
        FE["Vue Frontend"]:::frontend
        FE_Router["Router (vue/src/router)"]:::frontend
        FE_Static["Static Assets (Vue)"]:::static
        FE --> FE_Router
        FE --> FE_Static
    end

    subgraph "Backend Layer"
        BootApp["Spring Boot Application"]:::backend
        subgraph "REST Controllers"
            Controller["REST Controllers"]:::backend
        end
        subgraph "Security Module"
            SecurityConfig["Security Configurations"]:::security
        end
        subgraph "Data Access Layer"
            Repositories["Data Repositories"]:::databaseaccess
        end
        subgraph "File Storage"
            OSS["OSS Module"]:::storage
        end
        BackendStatic["Static Assets (Backend)"]:::static
        BootApp --> Controller
        BootApp --> SecurityConfig
        BootApp --> Repositories
        BootApp --> OSS
        BootApp --> BackendStatic
        Controller -->|"APIcalls"| Repositories
        Controller -->|"FileUploads"| OSS
        Controller -->|"SecuredBy"| SecurityConfig
        SecurityConfig -->|"Authorizes"| Controller
        Repositories -->|"CRUDops"| MySQL["MySQL Database"]:::database
    end

    FE -->|"HTTPRequests"| Controller

    DatabaseSchema["Database Schema"]:::database
    MySQL -->|"InitializedBy"| DatabaseSchema

    classDef frontend fill:#d3e5ff,stroke:#246,stroke-width:2px;
    classDef backend fill:#ffd3b6,stroke:#d96b00,stroke-width:2px;
    classDef security fill:#e0bbff,stroke:#8a2be2,stroke-width:2px;
    classDef databaseaccess fill:#ffdfba,stroke:#ff7f50,stroke-width:2px;
    classDef storage fill:#baffc9,stroke:#43a047,stroke-width:2px;
    classDef database fill:#ffe0e0,stroke:#f44336,stroke-width:2px;
    classDef static fill:#f0f0f0,stroke:#a9a9a9,stroke-dasharray:5 5;

    click FE "https://github.com/usualheart/zhoubao/tree/master/vue/"
    click FE_Router "https://github.com/usualheart/zhoubao/tree/master/vue/src/router"
    click BootApp "https://github.com/usualheart/zhoubao/blob/master/src/main/java/zhoubao/ZhoubaoBootApplication.java"
    click Controller "https://github.com/usualheart/zhoubao/tree/master/src/main/java/zhoubao/controller/"
    click SecurityConfig "https://github.com/usualheart/zhoubao/tree/master/src/main/java/zhoubao/configuration/"
    click Repositories "https://github.com/usualheart/zhoubao/tree/master/src/main/java/zhoubao/data/"
    click OSS "https://github.com/usualheart/zhoubao/tree/master/src/main/java/zhoubao/modules/oss/"
    click BackendStatic "https://github.com/usualheart/zhoubao/tree/master/src/main/resources/static/"
    click FE_Static "https://github.com/usualheart/zhoubao/tree/master/vue/static/"
    click DatabaseSchema "https://github.com/usualheart/zhoubao/blob/master/zhoubao.sql"
```
