# chillzhuang/springblade architecture

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

- Interactive diagram: https://gitdiagram.com/chillzhuang/springblade
- Repository: https://github.com/chillzhuang/springblade

## Overview

##### Main Components
- Authorization Service (blade-auth): Handles OAuth2-like authentication, token granters, and is responsible for verifying and issuing security tokens.
- API Gateway (blade-gateway): Acts as the single entry point routing requests to downstream services. It includes filters, JWT configuration, and error handling.
- Common Library (blade-common): Contains shared utilities, configurations, cache management, and other factors that are common throughout the microservices.
- Operations Center (blade-ops): A set of modules that includes:
- blade-admin for backend management.
- blade-develop for code generation.
- blade-resource for resource management.
- blade-seata-order and blade-seata-storage demonstrating distributed transaction management using Seata.
- Business Modules (blade-service): These include:
- blade-desk for the workbench or dashboard.
- blade-log for logging.
- blade-system for system management covering the administration of users, departments, roles, and more.
- Service APIs (blade-service-api): This package defines and encapsulates the APIs for business modules (e.g., blade-desk-api, blade-dict-api, blade-system-api, blade-user-api) which decouples the service contracts from their implementations.

##### Relationships and Interactions
- Authentication is handled separately by blade-auth, and it interacts with the API gateway to secure service calls.
- The service API layer (blade-service-api) illustrates the contracts (interfaces, DTOs) that the business modules implement. Represent these as an abstraction layer between the client-facing components and the service implementations.
- Seata-based transactional demos (blade-seata-order and blade-seata-storage) are integrated to showcase distributed transaction management; these should be shown as specialized modules that interact with each other (and possibly with a shared database resource) using Feign clients or other RPC calls.

##### Architectural Patterns and Technologies
- Microservices Pattern: Break down the platform into individual services easily deployable and scalable.
- Gateway and API Layer: Illustrate how Spring Cloud Gateway (blade-gateway) routes to microservices.
- Shared Libraries: Use common code encapsulated in blade-common to reduce redundancy.
- Distributed Transaction Management: Show how blade-seata modules incorporate Seata to handle distributed transactions.
- Containerization & Deployment: Note the existence of Dockerfiles in several modules (blade-auth, blade-gateway, blade-ops modules, etc.) and the Kubernetes deployment scripts in the script/kuboard directory.
- Core Technologies: Annotate key tech choices – Java 17+, Spring Boot 3.2, Spring Cloud 2023, Nacos for configuration and service registry, etc.

## Diagram (Mermaid)

```mermaid
flowchart TD
    C["Clients (Web/Mobile)"]:::client
    G["API Gateway (blade-gateway)"]:::gateway
    A["Auth Service (blade-auth)"]:::service
    CM["Common Library (blade-common)"]:::common

    subgraph "Operations Center"
        OP_ADMIN["Admin Console (blade-admin)"]:::ops
        OP_DEVELOP["Code Generator (blade-develop)"]:::ops
        OP_RESOURCE["Resource Management (blade-resource)"]:::ops
        OP_ORD["Seata Order (blade-seata-order)"]:::ops
        OP_STOR["Seata Storage (blade-seata-storage)"]:::ops
    end

    subgraph "Business Modules"
        BM_DESK["Workbench/Dashboard (blade-desk)"]:::business
        BM_LOG["Logging (blade-log)"]:::business
        BM_SYS["System Management (blade-system)"]:::business
    end

    subgraph "Service APIs"
        API_DEMO["Demo API (blade-demo-api)"]:::api
        API_DESK["Desk API (blade-desk-api)"]:::api
        API_DICT["Dict API (blade-dict-api)"]:::api
        API_SCOPE["Scope API (blade-scope-api)"]:::api
        API_SYSTEM["System API (blade-system-api)"]:::api
        API_USER["User API (blade-user-api)"]:::api
    end

    EX_NACOS["Nacos (Config&Registry)"]:::external
    EX_SENTINEL["Sentinel (FaultTolerance)"]:::external
    EX_DB["Database"]:::external

    %% Connections
    C -->|"requests"| G
    G -->|"authenticate"| A
    G -->|"route"| OP_ADMIN
    G -->|"route"| OP_DEVELOP
    G -->|"route"| OP_RESOURCE
    G -->|"route"| OP_ORD
    G -->|"route"| OP_STOR
    G -->|"route"| BM_DESK
    G -->|"route"| BM_LOG
    G -->|"route"| BM_SYS
    G -->|"serviceContracts"| API_DEMO
    G -->|"serviceContracts"| API_DESK
    G -->|"serviceContracts"| API_DICT
    G -->|"serviceContracts"| API_SCOPE
    G -->|"serviceContracts"| API_SYSTEM
    G -->|"serviceContracts"| API_USER

    %% Utility/Configuration dependencies
    OP_ADMIN ---|"utilities"| CM
    OP_DEVELOP ---|"utilities"| CM
    OP_RESOURCE ---|"utilities"| CM
    OP_ORD ---|"utilities"| CM
    OP_STOR ---|"utilities"| CM
    BM_DESK ---|"utilities"| CM
    BM_LOG ---|"utilities"| CM
    BM_SYS ---|"utilities"| CM

    %% Distributed Transaction between Seata modules
    OP_ORD ---|"distributedTxn"| OP_STOR

    %% External dependencies connections
    G ---|"config"| EX_NACOS
    A ---|"config"| EX_NACOS
    OP_ADMIN ---|"config"| EX_NACOS
    OP_DEVELOP ---|"config"| EX_NACOS
    BM_DESK ---|"config"| EX_NACOS

    G ---|"faultTolerance"| EX_SENTINEL
    A ---|"faultTolerance"| EX_SENTINEL

    BM_SYS ---|"DBAccess"| EX_DB
    BM_LOG ---|"DBAccess"| EX_DB
    OP_ADMIN ---|"DBAccess"| EX_DB

    %% Click Events
    click A "https://github.com/chillzhuang/springblade/tree/master/blade-auth"
    click G "https://github.com/chillzhuang/springblade/tree/master/blade-gateway"
    click CM "https://github.com/chillzhuang/springblade/tree/master/blade-common"
    click OP_ADMIN "https://github.com/chillzhuang/springblade/tree/master/blade-ops/blade-admin"
    click OP_DEVELOP "https://github.com/chillzhuang/springblade/tree/master/blade-ops/blade-develop"
    click OP_RESOURCE "https://github.com/chillzhuang/springblade/tree/master/blade-ops/blade-resource"
    click OP_ORD "https://github.com/chillzhuang/springblade/tree/master/blade-ops/blade-seata-order"
    click OP_STOR "https://github.com/chillzhuang/springblade/tree/master/blade-ops/blade-seata-storage"
    click BM_DESK "https://github.com/chillzhuang/springblade/tree/master/blade-service/blade-desk"
    click BM_LOG "https://github.com/chillzhuang/springblade/tree/master/blade-service/blade-log"
    click BM_SYS "https://github.com/chillzhuang/springblade/tree/master/blade-service/blade-system"
    click API_DEMO "https://github.com/chillzhuang/springblade/tree/master/blade-service-api/blade-demo-api"
    click API_DESK "https://github.com/chillzhuang/springblade/tree/master/blade-service-api/blade-desk-api"
    click API_DICT "https://github.com/chillzhuang/springblade/tree/master/blade-service-api/blade-dict-api"
    click API_SCOPE "https://github.com/chillzhuang/springblade/tree/master/blade-service-api/blade-scope-api"
    click API_SYSTEM "https://github.com/chillzhuang/springblade/tree/master/blade-service-api/blade-system-api"
    click API_USER "https://github.com/chillzhuang/springblade/tree/master/blade-service-api/blade-user-api"

    %% Styles
    classDef client fill:#f9c,stroke:#333,stroke-width:2px;
    classDef gateway fill:#bbf,stroke:#333,stroke-width:2px;
    classDef service fill:#bfb,stroke:#333,stroke-width:2px;
    classDef ops fill:#fbf,stroke:#333,stroke-width:2px;
    classDef business fill:#ffa,stroke:#333,stroke-width:2px;
    classDef api fill:#aff,stroke:#333,stroke-width:2px;
    classDef common fill:#ddd,stroke:#333,stroke-width:2px;
    classDef external fill:#fcc,stroke:#333,stroke-width:2px;
```
