# stylefeng/guns architecture

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

- Interactive diagram: https://gitdiagram.com/stylefeng/guns
- Repository: https://github.com/stylefeng/guns

## Overview

##### Main Components
- Backend Server – located under “src/main/java/cn/stylefeng/guns” and related directories. This is a Spring Boot-based service that handles the business logic including user management, security, configuration, logging, file management, scheduled tasks, and more.
- Persistence/Database – the project relies on a MySQL database, where connection configurations are defined in the various “application*.yml” files. Flyway (or a similar migration tool) is integrated via SQL scripts in src/main/resources/db/migration.
- External Services and Plugins – additional integration points include plugins for caching (in-memory and Redis), file storage (local, minio, cloud providers), email, JWT for authentication, websockets, and other extension points as documented in the README.
- DevOps & Build Tools – elements like the “pom.xml” (for Maven builds), Vite configuration for the front end, and deployment scripts located in _devops. These handle building, testing, and deploying the application.

##### Architectural Relationships and Interactions
- The Frontend (Vue3 UI) communicates with the Backend via RESTful API calls. The API calls are designed in the “src/api” folders (both globally and within specific components).
- The Backend exposes various API endpoints implementing modules such as system authorization, logging, and configuration – all managed with Spring Boot’s controller, service, and repository layers.
- The security layer in the backend includes interceptors for token-based and permission-based checks, error handling components, and exception management.
- Database operations are abstracted via Mybatis-plus, with schema migration handled automatically through Flyway-initialized scripts.

##### Important Architectural Patterns and Principles
- Separation of concerns – Frontend (presentation layer) is separated from the Backend (business logic and API layer) and from the Data Persistence tier.
- Modular design – The backend’s package structure indicates distinct modules (system/auth, system/backend, system/structure, etc.), following a plug-in architecture.
- Configuration-over-code – Numerous config files (YAML, environment settings, ESLint, Prettier) emphasize a flexible system configuration.
- Plugin extensibility – The README lists a range of optional plugins that make the system highly extensible.

## Diagram (Mermaid)

```mermaid
graph TD
    subgraph "Client Layer"
        A["Vue3 Frontend"]:::client
        B["API Communication"]:::client
    end

    subgraph "Application Server Layer"
        C["Spring Boot Application"]:::server
        F["Controllers"]:::server
        G["Service & Security Layer"]:::server
        D["Business Modules & Plugin Architecture"]:::server
        E["Core Plugins & External Services"]:::server
    end

    subgraph "Data Persistence Layer"
        H["MySQL Database"]:::database
        I["Configuration & Migrations"]:::data
    end

    subgraph "DevOps & Build Tools"
        J["pom.xml"]:::devops
        K["_devops"]:::devops
        L["Vite Config"]:::devops
    end

    A -->|"calls"| B
    B -->|"APICalls"| F
    F -->|"processes"| G
    G -->|"invokes"| D
    D -->|"integrates"| E
    D -->|"CRUDOperations"| H
    D -->|"usesConfig"| I
    C -->|"initializes"| F
    C -->|"manages"| G
    A -->|"RESTAPI"| C

    J -->|"buildsDeploys"| C
    K -->|"deploysViaScripts"| C
    L -->|"buildsDeploys"| A

    classDef client fill:#C3E88D,stroke:#000,stroke-width:2px;
    classDef server fill:#82AAFF,stroke:#000,stroke-width:2px;
    classDef data fill:#FFCB6B,stroke:#000,stroke-width:2px;
    classDef devops fill:#C792EA,stroke:#000,stroke-width:2px;
    classDef database fill:#F07178,stroke:#000,stroke-width:2px;

    click A "https://github.com/stylefeng/guns/tree/master/guns-front-project"
    click B "https://github.com/stylefeng/guns/tree/master/guns-front-project/src/api"
    click C "https://github.com/stylefeng/guns/tree/master/src/main/java/cn/stylefeng/guns"
    click D "https://github.com/stylefeng/guns/tree/master/src/main/java/cn/stylefeng/guns/modular"
    click E "https://github.com/stylefeng/guns/tree/master/src/main/java/cn/stylefeng/guns/core"
    click I "https://github.com/stylefeng/guns/tree/master/src/main/resources/application*.yml and src/main/resources/db/migration"
    click J "https://github.com/stylefeng/guns/blob/master/pom.xml"
    click K "https://github.com/stylefeng/guns/tree/master/_devops"
    click L "https://github.com/stylefeng/guns/blob/master/guns-front-project/vite.config.js"
```
