# baka-world/zhoubao architecture

> Architecture diagram of the GitHub repository baka-world/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/baka-world/zhoubao
- Repository: https://github.com/baka-world/zhoubao

## Overview

##### Main Components
- Backend Application (Spring Boot)
- Main entry point: ZhoubaoBootApplication.java.
- Packages responsible for configuration, security (e.g., MyAuthenticationSuccessHandler, SecurityByJdbcConfig), controllers (for HTML, image, user, and weekly report management), data access (repositories and exception handling), domain models, and modules (especially the OSS module for file storage).
- Frontend Application (Vue.js)
- Located under the “vue” directory; includes components for login, markdown editing, admin views, PDF viewing, file uploads, etc.
- Database (MySQL)
- The application expects a database (with “zhoubao.sql” provided to create the schema). This is used by Spring Boot for persisting user data and weekly reports.
- File Storage / OSS Module
- In the backend under modules/oss, includes LocalStorageService, MinioStorageService, and a factory to choose the storage implementation.
- Static Resource Management
- Static content already generated by the build process are served from src/main/resources/static for the Spring Boot context.

##### Relationships and Interactions
- The Frontend (Vue.js) communicates with the backend via REST APIs. Controllers such as HtmlRESTController, ImgRESTController, UserRESTController, and ZhouBaoRESTController expose endpoints for report creation, image uploads, and user management.
- The Backend connects to a MySQL Database. All repositories in the data package (e.g., ZhouBaoRepository, SpitterRepository) abstract CRUD operations on domain entities.
- The backend handles authentication and authorization (with custom configurations like MyUserDetailsService and SecurityByJdbcConfig) to manage different user roles (including a special “阅览” account as noted in the README).
- The OSS module abstracts file storage operations, interfacing with either a local storage solution or Minio – this is crucial for handling uploads (e.g., images, PDFs).
- Static resources (front-end bundled files and supplementary markdown templates) are served directly by the Spring Boot application.

##### Architectural Patterns and Design Principles
- MVC (Model-View-Controller): The backend cleanly separates domain models (inside “domain”), data access layers (inside “data”), and controllers (inside “controller”).
- Modular Design: The OSS functionality is abstracted into its own module, underlining separation of concerns.
- RESTful API Layer: Well-defined REST controllers provide API endpoints for the frontend.
- Security and Configuration are managed using Spring Boot’s profile mechanism (e.g., “prod” profile) and external configuration through application.yml.

##### Key Technologies and Frameworks
- Spring Boot (Backend Application Framework)
- Maven (Build tool, as indicated by pom.xml and .mvn directory)
- MySQL (Relational Database for persistence)
- Vue.js (Frontend Framework, with a separate configuration and build system)
- Minio or local file storage for handling uploads (via OSS module)
- Standard security frameworks integrated within Spring Boot

##### Elements
- From Vue.js to REST Controllers (indicating API requests/responses).
- From controllers to repositories (data access) and to the OSS module (file operations).
- From backend to the Database (CRUD operations).
- Annotations: Optionally, add notes or legends that briefly explain key configurations (such as the external configuration via application.yml) or security measures.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Frontend Layer
    subgraph "Frontend Layer"
        FE["Frontend (Vue.js)"]:::frontend
        FEViews["Login,MarkdownEditor,AdminViews,PDFViewer,FileUpload"]:::frontend
    end

    %% Backend Layer
    subgraph "Backend Layer"
        BE["Spring Boot Backend"]:::backend
        Entry["ZhoubaoBootApplication.java"]:::backend
        Config["Configuration & Security"]:::backend
        Ctrls["Controllers"]:::backend
        Repos["Repositories"]:::backend
        Domain["Domain Models"]:::backend
        OSS["OSS Module"]:::backend
        Static["Static Resources Loader"]:::backend
    end

    %% Persistence Layer
    subgraph "Persistence Layer"
        DB["MySQL Database"]:::database
    end

    %% Relationships
    FE -->|"RESTAPI"| Ctrls
    FEViews -->|"UI triggers"| Ctrls
    FE -->|"Static assets"| Static
    Ctrls -->|"CRUD calls"| Repos
    Repos -->|"Entity persistence"| Domain
    Ctrls -->|"FileOps"| OSS
    Config -->|"Secures access"| Ctrls
    BE -->|"Main Execution"| Entry
    BE -->|"Configuration"| Config
    BE -->|"Data handling"| Repos
    BE -->|"Serving Assets"| Static
    BE -->|"Database Ops"| DB

    %% Click Events
    click Entry "https://github.com/baka-world/zhoubao/blob/master/src/main/java/zhoubao/ZhoubaoBootApplication.java"
    click Config "https://github.com/baka-world/zhoubao/tree/master/src/main/java/zhoubao/configuration"
    click Ctrls "https://github.com/baka-world/zhoubao/tree/master/src/main/java/zhoubao/controller"
    click Repos "https://github.com/baka-world/zhoubao/tree/master/src/main/java/zhoubao/data"
    click Domain "https://github.com/baka-world/zhoubao/tree/master/src/main/java/zhoubao/domain"
    click FE "https://github.com/baka-world/zhoubao/tree/master/vue/"
    click DB "https://github.com/baka-world/zhoubao/blob/master/zhoubao.sql"
    click OSS "https://github.com/baka-world/zhoubao/tree/master/src/main/java/zhoubao/modules/oss"
    click Static "https://github.com/baka-world/zhoubao/tree/master/src/main/resources/static"

    %% Styles
    classDef frontend fill:#ADD8E6,stroke:#000,stroke-width:2px;
    classDef backend fill:#FFA07A,stroke:#000,stroke-width:2px;
    classDef database fill:#90EE90,stroke:#000,stroke-width:2px;
```
