# msomasun/demo-springconfig-repo architecture

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

- Interactive diagram: https://gitdiagram.com/msomasun/demo-springconfig-repo
- Repository: https://github.com/msomasun/demo-springconfig-repo

## Overview

##### Project type and purpose
- This is a Spring-based demo project illustrating a Config Server/Config Client pattern with automatic runtime refresh of configuration properties.
- Key functionality:
- A Config Server serves properties from an external repository (e.g., Git).
- One or more Config Clients fetch their configuration from the server and refresh when the config changes.

##### Infer the (implied) file structure and components
Even though the repo only contains a README, we know a typical Spring Cloud Config demo contains at least two subprojects (or modules):
– config-server (a Spring Boot app with @EnableConfigServer)
– config-client (a Spring Boot app annotated with @RefreshScope and using spring-cloud-config)
There may also be:
– an external configuration store (e.g., a Git repo or native filesystem)
– Spring Actuator endpoints for /refresh
– (optionally) Spring Cloud Bus with a message broker like RabbitMQ or Kafka to broadcast refresh events

##### Main components
a. External Config Store
- Git repository (or filesystem) containing application-name.properties/YAML
b. Config Server
- Spring Boot application annotated with @EnableConfigServer
- Exposes HTTP endpoints (/application/{profile}/{label})
- Reads from the external store and serves JSON/YAML payloads
c. Config Client(s)
- One or more Spring Boot microservices that:
– Use spring.cloud.config.uri to contact the Config Server at startup
– Have beans annotated with @RefreshScope
– Expose the Actuator /refresh endpoint
d. (Optional) Spring Cloud Bus and Message Broker
- Message broker (RabbitMQ/Kafka)
- Config Server or any client can POST to /actuator/bus-refresh to broadcast a refresh event

##### Relationships and interactions
1) On startup, each Config Client sends an HTTP GET to the Config Server to retrieve its configuration.
2) Config Server reads from the external store and returns the config payload.
3) When config files change in the external store (e.g., a Git commit), an operator or webhook triggers the Config Server to send a /refresh or /bus-refresh event.
4) If using Spring Cloud Bus: the event goes to the message broker, which fans out to all subscribed clients.
5) Each Config Client receives the event, refreshes its @RefreshScope beans, and applies new settings at runtime.

##### Architectural patterns and design principles
- “Externalized Configuration” (12-Factor App)
- “Configuration Server” as a centralized config store
- “Dynamic Refresh” using Actuator and Spring Cloud Bus
- Microservices style: each service is independently deployable and fetches its own config

##### Technologies, frameworks, and libraries
- Spring Boot (for both server and client)
- Spring Cloud Config Server / Client
- Spring Boot Actuator (/refresh, /env)
- (Optional) Spring Cloud Bus with RabbitMQ/Kafka
- Git (or filesystem) as the external config repository

## Diagram (Mermaid)

```mermaid
flowchart TB
    Documentation["Project Documentation\nREADME.md"]:::doc
    ExtStore["Git Repository\n(application-{profile}.yml)"]:::store
    ConfigServer["Config Server\n@EnableConfigServer"]:::server
    subgraph "Config Clients"
        Client1["Config Client 1\n@RefreshScope"]:::client
        Client2["Config Client 2\n@RefreshScope"]:::client
    end
    Broker["Message Broker\n(RabbitMQ/Kafka)"]:::broker
    Operator["Operator/Webhook"]:::external

    Documentation -->|“docs”| ConfigServer
    Client1 -->|"GET /{app}/{profile}/{label}"| ConfigServer
    Client2 -->|"GET /{app}/{profile}/{label}"| ConfigServer
    ConfigServer -->|"Reads config"| ExtStore
    Operator -->|"POST /actuator/refresh"| ConfigServer
    ConfigServer -->|"POST /actuator/bus-refresh"| Broker
    Broker -->|"AMQP/Kafka bus-refresh event"| Client1
    Broker -->|"AMQP/Kafka bus-refresh event"| Client2

    click Documentation "https://github.com/msomasun/demo-springconfig-repo/blob/main/README.md"

    classDef doc fill:#f9f,stroke:#333,stroke-width:1px;
    classDef store fill:#9f6,stroke:#333,stroke-width:1px;
    classDef server fill:#6cf,stroke:#333,stroke-width:1px;
    classDef client fill:#cf6,stroke:#333,stroke-width:1px;
    classDef broker fill:#f90,stroke:#333,stroke-width:1px;
    classDef external fill:#fff,stroke:#333,stroke-dasharray:5 5,stroke-width:1px;
```
