# eiselems/spring-boot-microservices architecture

> Architecture diagram of the GitHub repository eiselems/spring-boot-microservices, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-09-19). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/eiselems/spring-boot-microservices
- Repository: https://github.com/eiselems/spring-boot-microservices

## Overview

##### Project Type & Purpose
- This is a Spring Boot microservices reference app (used in a tutorial series “Microservices with Mo”).
- It demonstrates a classic microservices landscape: configuration server, service registry, API gateway, and domain services (counterservice, template-service, etc.) running in Docker containers orchestrated by docker-compose.

##### File Structure
- Top-level microservice modules:
- configservice (Spring Cloud Config Server)
- registryservice (Eureka service discovery)
- gatewayservice (Netflix Zuul API Gateway)
- counterservice (business logic microservice)
- template-service (scaffolded, deployable service)
- Root files:
- docker-compose.yml + runDockerized.sh (orchestrate containers & networks)
- pom.xml (parent aggregator)
- tools/architecture.dot (graphviz source of the architecture)
- Each module has its own Dockerfile and Spring Boot entrypoint.

##### Extract Key Insights from README
- Execution: `mvn clean package -DskipTests && docker-compose up --build`.
- After startup: gateway listens on port 9999; counterservice on port 8080; all services register with Eureka and fetch config from configservice.

##### Main Components & Their Responsibilities
a. Components:
- Client (Browser/REST client)
- GatewayService (Zuul)
- RegistryService (Eureka Server)
- ConfigService (Spring Cloud Config Server)
- CounterService (stateless microservice)
- Template-Service (placeholder microservice)
- (Optional/Extensible) AdminService (Spring Boot Admin)
- Docker-Compose Network (virtual LAN)
b. Relationships & Interactions:
- On startup each service → registers with RegistryService.
- On startup each service → fetches its configuration from ConfigService (using bootstrap.properties).
- Client → HTTP request → GatewayService (port 9999) → looks up CounterService URI in RegistryService → routes request.
- CounterService increments counter, returns JSON.
- Services communicate over internal Docker network (defined in docker-compose.yml).
c. Architectural Patterns & Principles:
- Microservices – independent deployable units, one Spring Boot project per service.
- Service Discovery – Eureka (RegistryService) for dynamic lookup.
- API Gateway – Zuul (GatewayService) to route and handle cross-cutting concerns (e.g., security via SecurityConfig.java).
- Externalized Configuration – Spring Cloud Config (ConfigService) serving properties.
- Containerization – Dockerfile per service, orchestrated by docker-compose.
- Scalability – each service can be scaled horizontally via multiple container instances.
d. Key Technologies & Frameworks:
- Spring Boot & Spring Web (REST controllers)
- Spring Cloud Config Server
- Netflix Eureka Server
- Netflix Zuul Proxy
- Docker & Docker-Compose
- Maven

##### Elements to Include in Your Canvas
- Clear, human-readable labels on every component (e.g., “configservice: Spring Cloud Config”, “registryservice: Eureka”).
- Infrastructure (registry, config server)
- API layer (gateway)
- Business services
- External actor (client)

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% External Client
    Client(("Client")):::client
    %% Docker Network Boundary
    subgraph "Docker Compose Network"
        direction TB
        GatewayService["gatewayservice: Zuul API Gateway\nport 9999"]:::gateway
        RegistryService["registryservice: Eureka Server\nport 8761"]:::registry
        ConfigService["configservice: Spring Cloud Config Server\nport 8888"]:::config
        CounterService["counterservice: Business Service\nport 8080"]:::service
        TemplateService["template-service: Placeholder Service"]:::service
    end

    %% Orchestration & Artifacts
    Compose["docker-compose.yml"]:::infra
    ParentPom["pom.xml"]:::infra
    ArchSrc["tools/architecture.dot"]:::infra
    CreateGraph["tools/createGraph.sh"]:::infra

    %% Connections
    Client -->|"HTTP API calls"| GatewayService
    GatewayService -->|"discover instances"| RegistryService
    GatewayService -->|"fetch config on startup"| ConfigService
    CounterService -->|"register / heartbeat"| RegistryService
    TemplateService -->|"register / heartbeat"| RegistryService
    CounterService -->|"fetch config on startup"| ConfigService
    TemplateService -->|"fetch config on startup"| ConfigService

    %% Click Events
    click ConfigService "https://github.com/eiselems/spring-boot-microservices/tree/master/configservice/"
    click RegistryService "https://github.com/eiselems/spring-boot-microservices/tree/master/registryservice/"
    click GatewayService "https://github.com/eiselems/spring-boot-microservices/tree/master/gatewayservice/"
    click CounterService "https://github.com/eiselems/spring-boot-microservices/tree/master/counterservice/"
    click TemplateService "https://github.com/eiselems/spring-boot-microservices/tree/master/template-service/"
    click Compose "https://github.com/eiselems/spring-boot-microservices/blob/master/docker-compose.yml"
    click ParentPom "https://github.com/eiselems/spring-boot-microservices/blob/master/pom.xml"
    click ArchSrc "https://github.com/eiselems/spring-boot-microservices/blob/master/tools/architecture.dot"
    click CreateGraph "https://github.com/eiselems/spring-boot-microservices/blob/master/tools/createGraph.sh"

    %% Styles
    classDef client fill:#f9f,stroke:#333,stroke-width:1px;
    classDef gateway fill:#cfc,stroke:#333,stroke-width:1px;
    classDef registry fill:#fc9,stroke:#333,stroke-width:1px;
    classDef config fill:#9f9,stroke:#333,stroke-width:1px;
    classDef service fill:#9cf,stroke:#333,stroke-width:1px;
    classDef infra fill:#ccc,stroke:#333,stroke-width:1px;
```
