# huaweicloud/spring-cloud-huawei architecture

> Architecture diagram of the GitHub repository huaweicloud/spring-cloud-huawei, 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/huaweicloud/spring-cloud-huawei
- Repository: https://github.com/huaweicloud/spring-cloud-huawei

## Overview

##### Main Components
- Core Framework Modules: These include the “spring-cloud-huawei-common” for shared utilities and core configurations.
- Governance & Discovery Modules: Separate modules exist for service discovery/registration and configuration management. For example, the “spring-cloud-huawei-governance” and the discovery modules organized around ServiceComb (CSE) and Nacos. Also, modules like “spring-cloud-huawei-nacos” and “spring-cloud-huawei-service-engine” have their own responsibilities.
- Mesh and Routing Support: Modules like “spring-cloud-huawei-mesh” and “spring-cloud-huawei-router” handle different aspects of service mesh, load balancing, and dynamic routing.
- Starter/Auto-configuration Modules: The “spring-cloud-starter-huawei” set of modules simplify application integration by providing auto-configuration and dependency management.
- Documentation/Swagger Support: “spring-cloud-huawei-swagger” helps in generating API documentation (with a noted switch from springfox to springdoc on newer versions).

##### Relationships and Interactions
- Dependency and Auto-Configuration: The starter modules depend on the core modules. They automatically wire in the necessary beans (from governance, discovery, common utilities, etc.) into a Spring Boot environment.

##### Architectural Patterns and Design Principles
- Modular Architecture: The project is organized into many small, purpose-specific modules. Emphasize how these modules encapsulate functionality (for example, common utilities, governance, service engine, mesh) and how they are assembled together in the auto-configuration process.
- Spring Boot Auto-Configuration: Several modules work as starters that rely on Spring Boot’s auto-configuration mechanism, reducing the need for manual configuration.

##### Relevant Technologies and Frameworks
- Maven multi-module project structure
- Spring Boot and Spring Cloud underlying the auto-configuration
- Integration with Apache ServiceComb and Nacos for discovery/registration and configuration
- Tools for governance (circuit breakers, load balancers) and Swagger support for API documentation
- Supporting testing infrastructure (integration-tests directory) which reinforces modular unit testing and end-to-end test flows

- Decompose the Core Framework into its key modules (common, governance, mesh, starters, discovery – divided into ServiceComb and Nacos paths).

- The a multi-layer design (client, framework core, external services).
- The modular subcomponents (common, governance, mesh, configuration, discovery, auto-config/starter, swagger).
- The choices and integrations for using ServiceComb (CSE) versus Nacos.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Client/Integration Layer
    subgraph "Client/Integration Layer"
        Client("Client Applications"):::client
    end

    %% Core Framework
    subgraph "Core Framework"
        %% Auto-configuration & Starter Modules
        subgraph "Auto-configuration & Starters"
            Starter("spring-cloud-starter-huawei"):::starter
        end
        %% Core Modules
        subgraph "Core Modules"
            Common("spring-cloud-huawei-common"):::core
            Governance("spring-cloud-huawei-governance"):::core
            Mesh("spring-cloud-huawei-mesh"):::core
            Router("spring-cloud-huawei-router"):::core
            Swagger("spring-cloud-huawei-swagger"):::core
        end
        %% Discovery & Configuration Modules
        subgraph "Discovery & Configuration"
            Nacos("spring-cloud-huawei-nacos"):::discovery
            CSE("spring-cloud-huawei-service-engine"):::discovery
        end
    end

    %% External Services
    subgraph "External Services"
        ServiceComb("Apache ServiceComb"):::external
        NacosExt("Nacos"):::external
    end

    %% Relationships / Data Flow
    Client -->|"usesAutoConfig"| Starter
    Client -->|"callsAPI"| Swagger
    Starter -->|"integrates"| Common
    Starter -->|"integrates"| Governance
    Starter -->|"integrates"| Mesh
    Starter -->|"integrates"| Router
    Starter -->|"integrates"| Swagger
    Common -->|"wiresBeansTo"| Nacos
    Common -->|"wiresBeansTo"| CSE
    Governance -->|"manages"| Nacos
    Governance -->|"manages"| CSE
    Nacos -->|"registersConfig"| NacosExt
    CSE -->|"registersDiscovers"| ServiceComb

    %% Styles
    classDef client fill:#C5E1A5,stroke:#33691E,stroke-width:2px;
    classDef starter fill:#B3E5FC,stroke:#01579B,stroke-width:2px;
    classDef core fill:#FFF9C4,stroke:#F57F17,stroke-width:2px;
    classDef discovery fill:#FFCCBC,stroke:#D84315,stroke-width:2px;
    classDef external fill:#E1BEE7,stroke:#6A1B9A,stroke-width:2px;

    %% Click Events
    click Common "https://github.com/huaweicloud/spring-cloud-huawei/tree/master/spring-cloud-huawei-common"
    click Governance "https://github.com/huaweicloud/spring-cloud-huawei/tree/master/spring-cloud-huawei-governance"
    click Nacos "https://github.com/huaweicloud/spring-cloud-huawei/tree/master/spring-cloud-huawei-nacos"
    click CSE "https://github.com/huaweicloud/spring-cloud-huawei/tree/master/spring-cloud-huawei-service-engine"
    click Mesh "https://github.com/huaweicloud/spring-cloud-huawei/tree/master/spring-cloud-huawei-mesh"
    click Router "https://github.com/huaweicloud/spring-cloud-huawei/tree/master/spring-cloud-huawei-router"
    click Starter "https://github.com/huaweicloud/spring-cloud-huawei/tree/master/spring-cloud-starter-huawei"
    click Swagger "https://github.com/huaweicloud/spring-cloud-huawei/tree/master/spring-cloud-huawei-swagger"
```
