# shabbirdwd53/springboot-3-microservices architecture

> Architecture diagram of the GitHub repository shabbirdwd53/springboot-3-microservices, 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/shabbirdwd53/springboot-3-microservices
- Repository: https://github.com/shabbirdwd53/springboot-3-microservices

## Overview

##### Project Type and Purpose
- This is a Spring Boot 3 microservices system demonstrating a typical cloud-native architecture.
- It consists of:
- Service Registry (Eureka) for discovery
- Config Server for centralized configuration
- API Gateway for request routing
- Two domain services: Department Service & Employee Service

##### Main Components
a. Service Registry (service-registry)
b. Config Server (config-server)
c. API Gateway (api-gateway)
d. Department Service (department-service)
e. Employee Service (employee-service)
f. Databases (one per domain service)
g. External Client (e.g., Web UI or Postman)

##### Relationships and Data Flows
- On startup, all microservices register themselves with Eureka (service-registry).
- Config Server fetches its YAML files from its local “config” repo and serves config over HTTP.
- The API Gateway exposes REST endpoints to external clients, discovers backends via Eureka, and forwards requests.
→ Client → API Gateway (Route) → Department or Employee Service.
- Department Service calls Employee Service using a WebClient-based client.
- Each domain service persists data to its own database (e.g., MySQL or H2).

##### Architectural Patterns and Design Principles
- Service Discovery pattern (Eureka)
- Externalized Configuration (Spring Cloud Config)
- API Gateway pattern (Spring Cloud Gateway)
- Client-side load balancing (via DiscoveryClient in gateway and WebClient in services)
- Single Responsibility per microservice
- Decentralized Data Management (one database per service)

##### Key Technologies and Frameworks
- Spring Boot 3
- Spring Cloud Netflix Eureka (Service Registry)
- Spring Cloud Config Server (Centralized Config)
- Spring Cloud Gateway (API Gateway)
- Spring WebFlux / WebClient (Inter-service calls)
- Spring Data JPA (Repository layer)
- YAML configuration files
- Maven for build

##### Layered View (optional)
- Top Layer: External Client
- Edge Layer: API Gateway
- Service Layer: Department Service, Employee Service
- Infrastructure Layer: Service Registry, Config Server
- Data Layer: Department DB, Employee DB

##### Detail to Capture
- Startup sequence: how services discover and fetch config
- Runtime request flow: client → gateway → service → service → database
- Configuration paths (e.g., “/department-service/default” from Config Server)
- Inter-service dependency: Department Service’s EmployeeClient

## Diagram (Mermaid)

```mermaid
flowchart TD
    CLIENT["External Client"]:::external
    GW["API Gateway"]:::gateway
    SR["Service Registry"]:::registry
    CS["Config Server"]:::config
    DS["Department Service"]:::service
    ES["Employee Service"]:::service
    DB1[(Department DB)]:::db
    DB2[(Employee DB)]:::db
    WCC["WebClientConfig"]:::service
    EC["EmployeeClient"]:::service
    DC["DepartmentController"]:::service
    DR["DepartmentRepository"]:::service
    EC2["EmployeeController"]:::service
    ER["EmployeeRepository"]:::service
    DeptYAML["Dept Service YAML"]:::service
    EmpYAML["Emp Service YAML"]:::service
    CSDept["Config: dept-service.yaml"]:::config
    CSEmp["Config: employee-service.yaml"]:::config
    GWY["Gateway YAML"]:::gateway
    SRY["Registry YAML"]:::registry

    CLIENT-->|"HTTP REST"| GW
    GW-->|"Register/Heartbeat"| SR
    DS-->|"Register/Heartbeat"| SR
    ES-->|"Register/Heartbeat"| SR

    CS-.->|"/actuator/env,/config"| GW
    CS-.->|"/actuator/env,/config"| DS
    CS-.->|"/actuator/env,/config"| ES
    CS-.->|"/actuator/env,/config"| SR

    GW-->|"Route /departments/**"| DS
    GW-->|"Route /employees/**"| ES

    DS-->|"WebClient /employees/{id}"| ES

    DS-->|"JPA Repository"| DB1
    ES-->|"JPA Repository"| DB2

    DS --> WCC
    DS --> EC
    DS --> DC
    DS --> DR
    DS --> DeptYAML

    ES --> EC2
    ES --> ER
    ES --> EmpYAML

    CS --> CSDept
    CS --> CSEmp

    GW --> GWY
    SR --> SRY

    click SR "https://github.com/shabbirdwd53/springboot-3-microservices/blob/main/service-registry/src/main/java/com/dailycodebuffer/serviceregistry/ServiceRegistryApplication.java"
    click SRY "https://github.com/shabbirdwd53/springboot-3-microservices/blob/main/service-registry/src/main/resources/application.yaml"
    click CS "https://github.com/shabbirdwd53/springboot-3-microservices/blob/main/config-server/src/main/java/com/dailycodebuffer/configserver/ConfigServerApplication.java"
    click CSDept "https://github.com/shabbirdwd53/springboot-3-microservices/blob/main/config-server/src/main/resources/config/department-service.yaml"
    click CSEmp "https://github.com/shabbirdwd53/springboot-3-microservices/blob/main/config-server/src/main/resources/config/employee-service.yaml"
    click GW "https://github.com/shabbirdwd53/springboot-3-microservices/blob/main/api-gateway/src/main/java/com/dailycodebuffer/apigateway/ApiGatewayApplication.java"
    click GWY "https://github.com/shabbirdwd53/springboot-3-microservices/blob/main/api-gateway/src/main/resources/application.yaml"
    click DS "https://github.com/shabbirdwd53/springboot-3-microservices/blob/main/department-service/src/main/java/com/dailycodebuffer/departmentservice/DepartmentServiceApplication.java"
    click WCC "https://github.com/shabbirdwd53/springboot-3-microservices/blob/main/department-service/src/main/java/com/dailycodebuffer/departmentservice/config/WebClientConfig.java"
    click EC "https://github.com/shabbirdwd53/springboot-3-microservices/blob/main/department-service/src/main/java/com/dailycodebuffer/departmentservice/client/EmployeeClient.java"
    click DC "https://github.com/shabbirdwd53/springboot-3-microservices/blob/main/department-service/src/main/java/com/dailycodebuffer/departmentservice/controller/DepartmentController.java"
    click DR "https://github.com/shabbirdwd53/springboot-3-microservices/blob/main/department-service/src/main/java/com/dailycodebuffer/departmentservice/repository/DepartmentRepository.java"
    click DeptYAML "https://github.com/shabbirdwd53/springboot-3-microservices/blob/main/department-service/src/main/resources/application.yaml"
    click ES "https://github.com/shabbirdwd53/springboot-3-microservices/blob/main/employee-service/src/main/java/com/dailycodebuffer/employeeservice/EmployeeServiceApplication.java"
    click EC2 "https://github.com/shabbirdwd53/springboot-3-microservices/blob/main/employee-service/src/main/java/com/dailycodebuffer/employeeservice/controller/EmployeeController.java"
    click ER "https://github.com/shabbirdwd53/springboot-3-microservices/blob/main/employee-service/src/main/java/com/dailycodebuffer/employeeservice/repository/EmployeeRepository.java"
    click EmpYAML "https://github.com/shabbirdwd53/springboot-3-microservices/blob/main/employee-service/src/main/resources/application.yaml"

    classDef external fill:#ffe4b5,stroke:#333,stroke-width:1px
    classDef registry fill:#ffcc80,stroke:#333,stroke-width:1px
    classDef config fill:#d1c4e9,stroke:#333,stroke-width:1px
    classDef gateway fill:#ff8a80,stroke:#333,stroke-width:1px
    classDef service fill:#90caf9,stroke:#333,stroke-width:1px
    classDef db fill:#a5d6a7,stroke:#333,stroke-width:1px
```
