# dromara/ruoyi-cloud-plus architecture

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

- Interactive diagram: https://gitdiagram.com/dromara/ruoyi-cloud-plus
- Repository: https://github.com/dromara/ruoyi-cloud-plus

## Overview

##### Major layers and components
a. External Client and Frontend Applications:
– Although the core backend source code is here, note that there is an associated front‑end project (plus‑ui, ruoyi‑plus‑vben5) as mentioned in the README. Represent front‑end clients (web, mobile, and admin dashboards) as separate entry points.
b. API Gateway:
– The “ruoyi‑gateway” module implements the gateway using Spring Cloud Gateway. This component is responsible for routing, cross-cutting concerns (authentication, logging, CORS, etc.), and possibly internal request filtering.
c. Authentication Service:
d. Core API-Layer and Common Libraries:
– The “ruoyi‑api” module and “ruoyi‑common” modules provide common API definitions (including remote API interfaces for resource, system, and workflow functionalities) along with shared utility classes, validations, and exception constants.
e. Business Microservices (Modules):
– Under “ruoyi‑modules” you have multiple business services such as:
- ruoyi‑gen (code generation),
- ruoyi‑job (distributed job scheduling),
- ruoyi‑resource (file, email, SMS, OSS management),
- ruoyi‑system (user, role, department, menu management),
- ruoyi‑workflow (workflow and process management).
Each module offers specific business functionality. They use common building blocks and APIs as defined in the common and API modules.
f. Messaging & Test Components:
g. Visual and Monitoring Components:
– The “ruoyi‑visual” grouping includes several components for monitoring and platform management (ruoyi‑monitor, ruoyi‑nacos, ruoyi‑seata‑server, ruoyi‑sentinel‑dashboard, ruoyi‑snailjob‑server). These modules handle system visualization, distributed configuration, transaction management, and service protection (sentinel, skywalking tracing).

##### Infrastructure and External Services
– Distributed Configuration and Service Registry: Highlight that the system integrates with Alibaba Nacos (for configuration and service discovery).
– RPC and Service Communication: Note that the system uses Apache Dubbo 3.x for high-performance RPC calls between microservices.
– Distributed Transaction Management: The project integrates Alibaba Seata for distributed transaction support.
– Distributed Caching & Messaging: Redis (with Redisson) is used extensively for caching, rate limiting, and session management. External message queues such as Kafka, RocketMQ, and RabbitMQ form the backbone for asynchronous communication.
– Additional elements include distributed security (Sa‑Token and JWT), file storage (Minio or cloud storage via S3 protocols), and built‑in support for code generation, Excel processing, and data permission filtering.

##### How to visually represent the architecture
– Group common libraries (ruoyi‑common, ruoyi‑api) in a shared “Common Infrastructure” section that all microservices depend on.
b. Interconnections and Data Flow:
– The API Gateway routes authentication requests to the Auth Service and business requests to the corresponding microservices.
– Illustrate inter-service communication – for example, the business services call each other’s remote APIs (via Dubbo) as needed.
– Indicate connections to infrastructure components like the database, Redis cache, message queues, and the Nacos configuration center.
– Optionally, mention external monitoring systems (Spring Boot Admin, Prometheus/Grafana, SkyWalking) that subscribe to logs and traces from various services.
d. Annotations and Legends:
– Include annotations for key frameworks (e.g., Spring Cloud Gateway, Apache Dubbo, MyBatis-Plus, Sa‑Token) next to the component they support.

a. Sketching out the core modules (Gateway, Auth, Business Services) in a rough layout.
b. External clients to the gateway, then cascade to individual services.
c. Insert infrastructure services at the base (configuration, registry, databases, caches, messaging, monitoring).
d. Verify directional flows (for example, API Gateway login requests to Auth Service, business requests routed to ruoyi‑system or ruoyi‑workflow, etc.).

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% External Clients
    subgraph "External Clients"
        ClientWeb("Web Client"):::frontend
        ClientMobile("Mobile Client"):::frontend
        ClientAdmin("Admin Dashboard"):::frontend
    end

    %% Gateway & Security Layer
    subgraph "Gateway & Security"
        APIGW("RuoYi-Gateway (Spring Cloud Gateway, Sentinel, Dubbo)"):::gateway
        Auth("RuoYi-Auth (Sa-Token, Captcha, JWT)"):::auth
    end

    %% Common Infrastructure (API & Common Libraries)
    subgraph "Common Infrastructure"
        API("RuoYi-API (Remote API Definitions)"):::common
        Common("RuoYi-Common (Utilities, Validations, Exceptions)"):::common
    end

    %% Business Microservices
    subgraph "Business Microservices"
        Gen("Code Generation Service"):::service
        Job("Distributed Job Scheduling"):::service
        Resource("Resource Management (File, Email, SMS, OSS)"):::service
        System("System Management (User, Role, Dept, etc.)"):::service
        Workflow("Workflow Management"):::service
    end

    %% Messaging & Testing Components
    subgraph "Messaging & Testing"
        TestMQ("Messaging/Test Component"):::messaging
    end

    %% Visual & Monitoring Components
    subgraph "Visual & Monitoring"
        Monitor("Monitoring"):::visual
        NacosVis("Nacos Visualization"):::visual
        SeataServ("Seata Server"):::visual
        Sentinel("Sentinel Dashboard"):::visual
        Snailjob("Snailjob Server"):::visual
    end

    %% Infrastructure Services
    subgraph "Infrastructure Services"
        Nacos("Nacos (Configuration & Service Discovery)"):::infrastructure
        Redis("Redis (Caching & Session Management)"):::infrastructure
        DB("Databases (MySQL/Oracle/PostgreSQL/SQLServer)"):::infrastructure
        MessageQueue("Message Brokers (Kafka/RocketMQ/RabbitMQ)"):::infrastructure
    end

    %% Connections from External Clients to Gateway
    ClientWeb -->|"HTTP"| APIGW
    ClientMobile -->|"HTTP"| APIGW
    ClientAdmin -->|"HTTP"| APIGW

    %% Gateway Routing
    APIGW -->|"Auth_Request"| Auth
    APIGW -->|"Business_Request"| Gen
    APIGW -->|"Business_Request"| Job
    APIGW -->|"Business_Request"| Resource
    APIGW -->|"Business_Request"| System
    APIGW -->|"Business_Request"| Workflow

    %% Auth Service Integration with Common Libraries
    Auth -->|"Uses"| API
    Auth -->|"Uses"| Common

    %% Business Microservices Integration with Common Infrastructure
    Gen -->|"API_Call"| API
    Gen -->|"Utilizes"| Common
    Job -->|"API_Call"| API
    Job -->|"Utilizes"| Common
    Resource -->|"API_Call"| API
    Resource -->|"Utilizes"| Common
    System -->|"API_Call"| API
    System -->|"Utilizes"| Common
    Workflow -->|"API_Call"| API
    Workflow -->|"Utilizes"| Common

    %% Infrastructure Dependencies for Business Services
    Gen -->|"DB_Access"| DB
    Job -->|"DB_Access"| DB
    Resource -->|"DB_Access"| DB
    System -->|"DB_Access"| DB
    Workflow -->|"DB_Access"| DB

    Gen -->|"Cache/MQ"| Redis
    Job -->|"Cache/MQ"| Redis
    Resource -->|"Cache/MQ"| Redis
    System -->|"Cache/MQ"| Redis
    Workflow -->|"Cache/MQ"| Redis

    %% All services use Nacos for configuration and discovery
    APIGW -->|"Config_Discovery"| Nacos
    Auth -->|"Config_Discovery"| Nacos
    Gen -->|"Config_Discovery"| Nacos
    Job -->|"Config_Discovery"| Nacos
    Resource -->|"Config_Discovery"| Nacos
    System -->|"Config_Discovery"| Nacos
    Workflow -->|"Config_Discovery"| Nacos

    %% Messaging Component
    TestMQ -->|"Test_Messaging"| MessageQueue

    %% Visual & Monitoring Data Collection
    Monitor -->|"Monitors"| APIGW
    Monitor -->|"Monitors"| Auth
    Monitor -->|"Monitors"| Gen
    Monitor -->|"Monitors"| Job
    Monitor -->|"Monitors"| Resource
    Monitor -->|"Monitors"| System
    Monitor -->|"Monitors"| Workflow

    Sentinel -->|"Protects"| APIGW
    Snailjob -->|"Job_Monitoring"| Job

    NacosVis -->|"Visualizes"| Nacos
    SeataServ -->|"Tx_Management"| DB
    SeataServ -->|"Tx_Control"| Gen
    SeataServ -->|"Tx_Control"| Job
    SeataServ -->|"Tx_Control"| Resource
    SeataServ -->|"Tx_Control"| System
    SeataServ -->|"Tx_Control"| Workflow

    %% Optional Infrastructure Link
    DB ---|"Persistence"| Redis

    %% Click Events for Component Mapping
    click APIGW "https://github.com/dromara/ruoyi-cloud-plus/tree/2.X/ruoyi-gateway"
    click Auth "https://github.com/dromara/ruoyi-cloud-plus/tree/2.X/ruoyi-auth"
    click API "https://github.com/dromara/ruoyi-cloud-plus/tree/2.X/ruoyi-api"
    click Common "https://github.com/dromara/ruoyi-cloud-plus/tree/2.X/ruoyi-common"
    click Gen "https://github.com/dromara/ruoyi-cloud-plus/tree/2.X/ruoyi-modules/ruoyi-gen"
    click Job "https://github.com/dromara/ruoyi-cloud-plus/tree/2.X/ruoyi-modules/ruoyi-job"
    click Resource "https://github.com/dromara/ruoyi-cloud-plus/tree/2.X/ruoyi-modules/ruoyi-resource"
    click System "https://github.com/dromara/ruoyi-cloud-plus/tree/2.X/ruoyi-modules/ruoyi-system"
    click Workflow "https://github.com/dromara/ruoyi-cloud-plus/tree/2.X/ruoyi-modules/ruoyi-workflow"
    click TestMQ "https://github.com/dromara/ruoyi-cloud-plus/tree/2.X/ruoyi-example/ruoyi-test-mq"
    click Monitor "https://github.com/dromara/ruoyi-cloud-plus/tree/2.X/ruoyi-visual/ruoyi-monitor"
    click NacosVis "https://github.com/dromara/ruoyi-cloud-plus/tree/2.X/ruoyi-visual/ruoyi-nacos"
    click SeataServ "https://github.com/dromara/ruoyi-cloud-plus/tree/2.X/ruoyi-visual/ruoyi-seata-server"
    click Sentinel "https://github.com/dromara/ruoyi-cloud-plus/tree/2.X/ruoyi-visual/ruoyi-sentinel-dashboard"
    click Snailjob "https://github.com/dromara/ruoyi-cloud-plus/tree/2.X/ruoyi-visual/ruoyi-snailjob-server"

    %% Styles
    classDef frontend fill:#f9c,stroke:#333,stroke-width:2px;
    classDef gateway fill:#ff9,stroke:#333,stroke-width:2px;
    classDef auth fill:#fc9,stroke:#333,stroke-width:2px;
    classDef common fill:#cff,stroke:#333,stroke-width:2px;
    classDef service fill:#9f9,stroke:#333,stroke-width:2px;
    classDef messaging fill:#9ff,stroke:#333,stroke-width:2px;
    classDef visual fill:#ff9,stroke:#333,stroke-width:2px;
    classDef infrastructure fill:#f99,stroke:#333,stroke-width:2px;
```
