# wenka/springcloud-demo architecture

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

- Interactive diagram: https://gitdiagram.com/wenka/springcloud-demo
- Repository: https://github.com/wenka/springcloud-demo

## Overview

##### Project type and purpose
- This is a Spring Cloud / Spring Boot microservices demo repository. It contains multiple independent Spring Boot modules illustrating core Spring Cloud patterns (service registry, discovery, API gateway, client-side load balancing, circuit breaker) plus demos of messaging (RabbitMQ), WebSocket, caching (Redis), security (JWT, OAuth2, Spring Security), custom starters (Thymeleaf), data access patterns (dynamic data sources, sub-databases, SQLite), configuration (Apollo, Nacos), and more.

##### File structure
- Top-level: one multi-module project.
- Modules:
- eureka-server-demo (service registry)
- eureka-client-demo (registered service)
- service-feign-demo, service-ribbon-demo (client-side load-balancing)
- service-zuul-demo, service-gateway-demo (API gateways)
- service-jwt-demo, springboot-security-demo, springboot-oauth2.0-demo (security)
- service-rabbitmq-demo, service-rabbit-exchange-demo (RabbitMQ)
- service-websocket-demo (WebSocket)
- springboot-redis-demo (Redis cache)
- springboot-dynamic-datasource-demo, springboot-subdatabase-demo, springboot-sqllite-demo (data access)
- springboot-elasticsearch-demo (Elasticsearch)
- springboot-ciphertext-demo (RSA encryption)
- springboot-lock-demo (distributed lock)
- springboot-apollo-demo, springboot-nacos-demo (config services)
- springboot-thymeleaf-demo (custom starter)

##### README for additional insights
- Confirms the ordering and purpose of the first 14 modules; the remaining are supplementary demos.

##### Detail
- Multi-data-source routing for dynamic-datasource and subdatabase demos.
- Which modules use which external services or libraries (e.g., “Feign + Hystrix”, “RabbitMQ exchange”, “RSA encryption advice”, “Thymeleaf starter”).

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Client & UI Layer
    subgraph "Client & UI"
        direction TB
        Browser["Browser Web UI"]:::client
        RestClient["REST Client"]:::client
    end

    %% API Gateway Layer
    subgraph "API Gateway Layer"
        direction TB
        Zuul["Zuul Gateway\n(service-zuul-demo)"]:::gateway
        Gateway["Spring Cloud Gateway\n(service-gateway-demo)"]:::gateway
    end

    %% Service Layer
    subgraph "Microservices Layer"
        direction TB
        EurekaClient["Eureka Client\n(eureka-client-demo)"]:::service
        FeignService["Feign + Hystrix\n(service-feign-demo)"]:::service
        RibbonService["Ribbon Client\n(service-ribbon-demo)"]:::service
        JWTService["JWT Token Service\n(service-jwt-demo)"]:::security
        SecService["Spring Security Demo\n(springboot-security-demo)"]:::security
        OAuth2Service["OAuth2 Auth & Resource\n(springboot-oauth2.0-demo)"]:::security
        RabbitSimple["RabbitMQ Simple Demo\n(service-rabbitmq-demo)"]:::service
        RabbitExchange["RabbitMQ Exchange Demo\n(service-rabbit-exchange-demo)"]:::service
        WebSocket["WebSocket Endpoint\n(service-websocket-demo)"]:::service
        RedisDemo["Redis Cache Demo\n(springboot-redis-demo)"]:::datastore
        ESdemo["Elasticsearch Demo\n(springboot-elasticsearch-demo)"]:::datastore
        DynDS["Dynamic DataSource\n(springboot-dynamic-datasource-demo)"]:::service
        SubDB["Sub-DB Sharding\n(springboot-subdatabase-demo)"]:::service
        SQLite["SQLite Demo\n(springboot-sqllite-demo)"]:::service
        CipherDemo["RSA CipherText\n(springboot-ciphertext-demo)"]:::service
        LockDemo["Distributed Lock\n(springboot-lock-demo)"]:::service
        ApolloClient["Apollo Config Client\n(springboot-apollo-demo)"]:::infrastructure
        NacosClient["Nacos Config Client\n(springboot-nacos-demo)"]:::infrastructure
        ThymeleafDemo["Thymeleaf Starter Demo\n(springboot-thymeleaf-demo)"]:::service
    end

    %% Infrastructure Layer
    subgraph "Infrastructure"
        direction TB
        EurekaServer["Eureka Server\n(eureka-server-demo)"]:::infrastructure
        RabbitMQ["RabbitMQ Broker"]:::infrastructure
        RedisStore["Redis"]:::datastore
        Elasticsearch["Elasticsearch Cluster"]:::datastore
        ConfigApollo["Apollo Config Service"]:::infrastructure
        ConfigNacos["Nacos Config Service"]:::infrastructure
        RelationalDB["Relational DB"]:::datastore
    end

    %% Client to Gateway
    Browser -->|HTTP Requests| Zuul
    Browser -->|HTTP Requests| Gateway
    RestClient -->|API Calls| Zuul
    RestClient -->|API Calls| Gateway

    %% Gateway to Services
    Zuul -->|"Routes"| EurekaClient
    Zuul --> FeignService
    Zuul --> RibbonService
    Zuul --> JWTService
    Zuul --> SecService
    Zuul --> OAuth2Service
    Zuul --> RabbitSimple
    Zuul --> WebSocket
    Zuul --> DynDS
    Zuul --> SubDB
    Zuul --> SQLite
    Zuul --> CipherDemo
    Zuul --> LockDemo
    Zuul --> ThymeleafDemo

    Gateway --> EurekaClient
    Gateway --> FeignService
    Gateway --> RibbonService
    Gateway --> JWTService
    Gateway --> SecService
    Gateway --> OAuth2Service
    Gateway --> RabbitSimple
    Gateway --> WebSocket
    Gateway --> DynDS
    Gateway --> SubDB
    Gateway --> SQLite
    Gateway --> CipherDemo
    Gateway --> LockDemo
    Gateway --> ThymeleafDemo

    %% Service Registration
    EurekaClient --> EurekaServer
    FeignService --> EurekaServer
    RibbonService --> EurekaServer
    JWTService --> EurekaServer
    SecService --> EurekaServer
    OAuth2Service --> EurekaServer
    RabbitSimple --> EurekaServer
    RabbitExchange --> EurekaServer
    WebSocket --> EurekaServer
    DynDS --> EurekaServer
    SubDB --> EurekaServer
    SQLite --> EurekaServer
    CipherDemo --> EurekaServer
    LockDemo --> EurekaServer
    ThymeleafDemo --> EurekaServer

    %% Messaging Flows
    RabbitSimple -->|send/receive| RabbitMQ
    RabbitExchange -->|publish/subscribe| RabbitMQ

    %% Data Access
    DynDS --> RelationalDB
    SubDB --> RelationalDB
    SQLite --> RelationalDB
    RedisDemo --> RedisStore
    ESdemo --> Elasticsearch

    %% WebSocket
    Browser -->|WebSocket| WebSocket

    %% Security Flows
    Browser -->|Auth Request| OAuth2Service
    OAuth2Service -->|issue token| Browser
    Browser -->|JWT Token| JWTService
    JWTService -->|validate| SecService

    %% Config Services
    ApolloClient --> ConfigApollo
    NacosClient --> ConfigNacos

    %% Config clients used by others
    FeignService -.->|config| ApolloClient
    RibbonService -.->|config| ApolloClient
    JWTService -.->|config| NacosClient
    SecService -.->|config| NacosClient

    %% Click Events
    click EurekaServer "https://github.com/wenka/springcloud-demo/tree/master/eureka-server-demo/"
    click EurekaClient "https://github.com/wenka/springcloud-demo/tree/master/eureka-client-demo/"
    click FeignService "https://github.com/wenka/springcloud-demo/tree/master/service-feign-demo/"
    click RibbonService "https://github.com/wenka/springcloud-demo/tree/master/service-ribbon-demo/"
    click Zuul "https://github.com/wenka/springcloud-demo/tree/master/service-zuul-demo/"
    click Gateway "https://github.com/wenka/springcloud-demo/tree/master/service-gateway-demo/"
    click JWTService "https://github.com/wenka/springcloud-demo/tree/master/service-jwt-demo/"
    click SecService "https://github.com/wenka/springcloud-demo/tree/master/springboot-security-demo/"
    click OAuth2Service "https://github.com/wenka/springcloud-demo/tree/master/springboot-oauth2.0-demo/"
    click RabbitSimple "https://github.com/wenka/springcloud-demo/tree/master/service-rabbitmq-demo/"
    click RabbitExchange "https://github.com/wenka/springcloud-demo/tree/master/service-rabbit-exchange-demo/"
    click WebSocket "https://github.com/wenka/springcloud-demo/tree/master/service-websocket-demo/"
    click RedisDemo "https://github.com/wenka/springcloud-demo/tree/master/springboot-redis-demo/"
    click ESdemo "https://github.com/wenka/springcloud-demo/tree/master/springboot-elasticsearch-demo/"
    click DynDS "https://github.com/wenka/springcloud-demo/tree/master/springboot-dynamic-datasource-demo/"
    click SubDB "https://github.com/wenka/springcloud-demo/tree/master/springboot-subdatabase-demo/"
    click SQLite "https://github.com/wenka/springcloud-demo/tree/master/springboot-sqllite-demo/"
    click CipherDemo "https://github.com/wenka/springcloud-demo/tree/master/springboot-ciphertext-demo/"
    click LockDemo "https://github.com/wenka/springcloud-demo/tree/master/springboot-lock-demo/"
    click ApolloClient "https://github.com/wenka/springcloud-demo/tree/master/springboot-apollo-demo/"
    click NacosClient "https://github.com/wenka/springcloud-demo/tree/master/springboot-nacos-demo/"
    click ThymeleafDemo "https://github.com/wenka/springcloud-demo/tree/master/springboot-thymeleaf-demo/"

    %% Styles
    classDef client fill:#f9f,stroke:#333,stroke-width:1px
    classDef gateway fill:#9f9,stroke:#333,stroke-width:1px
    classDef service fill:#f96,stroke:#333,stroke-width:1px
    classDef infrastructure fill:#99f,stroke:#333,stroke-width:1px
    classDef datastore fill:#c9c,stroke:#333,stroke-width:1px
    classDef security fill:#f66,stroke:#333,stroke-width:1px
```
