# kbastani/cloud-native-microservice-strangler-example architecture

> Architecture diagram of the GitHub repository kbastani/cloud-native-microservice-strangler-example, 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/kbastani/cloud-native-microservice-strangler-example
- Repository: https://github.com/kbastani/cloud-native-microservice-strangler-example

## Overview

##### Project type and purpose
- This is a reference implementation of the Cloud-Native Strangler Pattern using Spring Cloud microservices.
- It demonstrates how to introduce microservices into an existing SOA/legacy architecture, “strangling” monolithic data access over time.
- Key use cases:
– Legacy application integration (Customer Service, Legacy Edge)
– New cloud-native microservices (Config, Discovery, Edge/Gateway, User, Profile, Profile-Web, Hystrix Dashboard, Zipkin tracing)
– OAuth2 authentication, service discovery, circuit breakers, API gateway, distributed tracing.

##### File structure
Top-level directories
- legacy-applications
– customer-service: a SOAP/REST legacy WSDL-backed Customer service
– legacy-edge: a legacy gateway adapter routing calls to new services
- microservices
– config-service: Spring Cloud Config Server
– discovery-service: Eureka service registry
– edge-service: Zuul API gateway / proxy
– hystrix-dashboard: Hystrix monitoring UI
– zipkin-tracing: Zipkin server for distributed tracing
– user-service: OAuth2 authorization/resource server + user domain
– profile-service: profile/domain microservice, listens for legacy data events
– profile-web: Angular-based UI for profile
- root scripts/config
– docker-compose.yml, run.sh (Docker Compose orchestration)
– deploy.sh (Cloud Foundry deployment)

##### README for additional insights
- The README outlines a hybrid legacy + microservices architecture, highlighting the Strangler pattern, lazy data migration, durable event mirroring, and Spring Cloud Netflix components.

##### Detail
– Capture every Spring Boot application, its role, and dependencies.
– Show inter-service communication and fallback paths (Hystrix).
– Don’t over-aggregate: represent each microservice as its own node.

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Clients / UI
    subgraph "Clients / UI"
        Browser["Browser / External Client"]:::client
        ProfileWeb["Profile-Web UI"]:::micro
    end

    %% Legacy Zone
    subgraph "Legacy Zone"
        CustomerService["Customer Service (Legacy SOAP/REST)"]:::legacy
        LegacyEdge["Legacy-Edge Adapter"]:::legacy
    end

    %% Shared Infrastructure
    subgraph "Shared Infrastructure"
        ConfigServer["Config Server"]:::infra
        EurekaServer["Eureka Discovery Server"]:::infra
        ZuulGateway["Zuul API Gateway"]:::infra
        HystrixDashboard["Hystrix Dashboard"]:::infra
        ZipkinServer["Zipkin Tracing Server"]:::infra
    end

    %% Business Microservices
    subgraph "Business Microservices"
        UserService["OAuth2 User Service"]:::micro
        ProfileService["Profile Service"]:::micro
    end

    %% Data Stores & Event Bus
    subgraph "Data Stores & Event Bus"
        CustomerDB["Legacy Customer DB"]:::data
        UserDB["User Service DB"]:::data
        ProfileDB["Profile Service DB"]:::data
        EventBus["Event Bus / Message Broker"]:::data
    end

    %% Client to Gateway/UI
    Browser -->|"REST/UI"| ZuulGateway
    Browser -->|"Access UI"| ProfileWeb
    ProfileWeb -->|"REST Calls"| ZuulGateway

    %% Legacy interactions
    LegacyEdge -->|"API Calls"| ZuulGateway
    CustomerService -->|"Reads/Writes"| CustomerDB
    LegacyEdge -->|"Reads/Writes"| CustomerDB

    %% Gateway routing
    ZuulGateway -->|"Route to Legacy Edge"| LegacyEdge
    ZuulGateway -->|"Route to User Service"| UserService
    ZuulGateway -->|"Route to Profile Service"| ProfileService

    %% Microservices data
    UserService -->|"Reads/Writes"| UserDB
    ProfileService -->|"Reads/Writes"| ProfileDB

    %% Event flows
    LegacyEdge -->|"Publishes Events"| EventBus
    ProfileService -->|"Consumes Events"| EventBus

    %% Service Discovery and Config
    ZuulGateway -->|"Registers & Discovery"| EurekaServer
    UserService -->|"Registers & Discovery"| EurekaServer
    ProfileService -->|"Registers & Discovery"| EurekaServer
    LegacyEdge -->|"Registers & Discovery"| EurekaServer

    ZuulGateway -->|"Fetch Config"| ConfigServer
    UserService -->|"Fetch Config"| ConfigServer
    ProfileService -->|"Fetch Config"| ConfigServer
    LegacyEdge -->|"Fetch Config"| ConfigServer

    %% Distributed Tracing
    ZuulGateway -->|"Sends Traces"| ZipkinServer
    UserService -->|"Sends Traces"| ZipkinServer
    ProfileService -->|"Sends Traces"| ZipkinServer
    LegacyEdge -->|"Sends Traces"| ZipkinServer

    %% Circuit Breaker Monitoring
    ZuulGateway -->|"Metrics"| HystrixDashboard

    %% OAuth2 Token Flow
    UserService -->|"Issues Tokens"| ZuulGateway
    UserService -->|"Validates Tokens"| ProfileService

    %% Click Events
    click CustomerService "https://github.com/kbastani/cloud-native-microservice-strangler-example/blob/master/legacy-applications/customer-service/src/main/java/com/example/CustomerLegacyApplication.java"
    click LegacyEdge "https://github.com/kbastani/cloud-native-microservice-strangler-example/blob/master/legacy-applications/legacy-edge/src/main/java/com/example/LegacyEdgeApplication.java"
    click ConfigServer "https://github.com/kbastani/cloud-native-microservice-strangler-example/blob/master/microservices/config-service/src/main/java/demo/ConfigApplication.java"
    click EurekaServer "https://github.com/kbastani/cloud-native-microservice-strangler-example/blob/master/microservices/discovery-service/src/main/java/demo/Application.java"
    click ZuulGateway "https://github.com/kbastani/cloud-native-microservice-strangler-example/blob/master/microservices/edge-service/src/main/java/demo/EdgeApplication.java"
    click HystrixDashboard "https://github.com/kbastani/cloud-native-microservice-strangler-example/blob/master/microservices/hystrix-dashboard/src/main/java/demo/HystrixApplication.java"
    click ZipkinServer "https://github.com/kbastani/cloud-native-microservice-strangler-example/blob/master/microservices/zipkin-tracing/src/main/java/demo/ZipkinServerApplication.java"
    click UserService "https://github.com/kbastani/cloud-native-microservice-strangler-example/blob/master/microservices/user-service/src/main/java/demo/UserApplication.java"
    click ProfileService "https://github.com/kbastani/cloud-native-microservice-strangler-example/blob/master/microservices/profile-service/src/main/java/demo/ProfileApplication.java"
    click ProfileWeb "https://github.com/kbastani/cloud-native-microservice-strangler-example/blob/master/microservices/profile-web/src/main/java/demo/ProfileWebApplication.java"

    %% Styles
    classDef legacy fill:#ccc,stroke:#333,stroke-width:1px
    classDef infra fill:#aaf,stroke:#333,stroke-width:1px
    classDef micro fill:#afa,stroke:#333,stroke-width:1px
    classDef data fill:#ffa,stroke:#333,stroke-width:1px
    classDef client fill:#faf,stroke:#333,stroke-width:1px
```
