# devxsb/spring-boot-microservices architecture

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

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

## Overview

##### Main Components Identified
- Config Server: Centralized configuration management (located in the “config-server” directory).
- Eureka Server: Service discovery/registry (located in the “eureka-server” directory).
- API Gateway: Acts as the entry point for client requests and routes them to the appropriate microservice (found in the “gateway” directory).
- Auth Service: Handles registration, login, and JWT-based authentication/authorization (in the “auth-service” directory).
- User Service: Manages user-related operations (in the “user-service” directory).
- Job Service: Manages job, advert, and offer related functionalities (in the “job-service” directory).
- Notification Service: Handles notifications using Kafka messaging (in the “notification-service” directory).
- File Storage: Manages file upload/download functionalities for file handling (in the “file-storage” directory).
- Additional supporting components such as Kafka, Redis, PostgreSQL, Docker Compose configuration (docker-compose.yml) and additional configuration files.

##### Relationships and Interactions
- The API Gateway routes incoming HTTP requests to the appropriate services (e.g., auth, user, job, etc.). All external calls pass through this gateway.
- Service Discovery is handled by the Eureka Server, allowing microservices to register on startup and discover each other dynamically.
- The Config Server provides services with a centralized configuration, ensuring consistency across all services.
- Authentication and Authorization are handled via JWT tokens — services check these tokens (e.g., auth-service, gateway, user-service) to secure endpoints.
- Messaging integration exists (e.g., Kafka in the Notification Service) to send and process asynchronous notifications.
- File Storage is a dedicated service that manages file/content-related operations and integrates with other services via Feign clients.

##### Architectural Patterns and Design Principles
- Microservices architecture: Each major domain function is isolated as its own service.
- API Gateway pattern: The gateway centralizes entry, authentication, and routing concerns.
- Service Discovery and Centralized Configuration: Eureka and Config Server manage service registrations and settings.
- Client-to-Server Communication: Use of Feign Clients (as seen in multiple service directories) to enable inter-service REST calls.
- Asynchronous Communication: Use of Kafka for messaging in the notification service.
- Security is implemented via Spring Security and JWT for both authentication and authorization.
- Containerization and orchestration: Docker Compose is used to launch services concurrently.

##### Technologies and Frameworks Impacting the Design
- Spring Boot and Spring Cloud technologies for building the microservices.
- Netflix Eureka for service discovery.
- Spring Cloud Gateway to act as the API Gateway.
- Spring Cloud Config for centralized configurations.
- PostgreSQL as the relational database.
- Kafka for message brokering (notification service).
- Redis for caching (as mentioned in the README).
- Docker for containerization.

- Clear labels for each microservice with its name (e.g., “Auth Service”, “User Service”, etc.).
- To include any relevant middleware (Kafka, Redis) alongside their connecting microservice(s).

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% External Client
    Clients["Clients"]:::external

    %% API Gateway
    APIGateway["API Gateway"]:::gateway

    %% Microservices Subgraph
    subgraph "Microservices"
        Auth["Auth Service"]:::microservice
        User["User Service"]:::microservice
        Job["Job Service"]:::microservice
        Notification["Notification Service"]:::microservice
        FileStorage["File Storage Service"]:::microservice
    end

    %% Centralized Services Subgraph
    subgraph "Centralized Services"
        Config["Config Server"]:::central
        Eureka["Eureka Server"]:::central
    end

    %% Supporting Infrastructure Subgraph
    subgraph "Supporting Infrastructure"
        Kafka["Kafka"]:::infrastructure
        PostgreSQL["PostgreSQL"]:::infrastructure
        Redis["Redis"]:::infrastructure
        Docker["Docker Compose"]:::infrastructure
    end

    %% Communication flows: Clients and Gateway
    Clients -->|"HTTPrequests"| APIGateway
    APIGateway -->|"routes"| Auth
    APIGateway -->|"routes"| User
    APIGateway -->|"routes"| Job
    APIGateway -->|"routes"| Notification
    APIGateway -->|"routes"| FileStorage

    %% API Gateway registers with centralized services
    APIGateway -->|"registers"| Eureka
    APIGateway -->|"config"| Config

    %% Microservices interactions with Centralized Services
    Auth -->|"registers"| Eureka
    Auth -->|"config"| Config

    User -->|"registers"| Eureka
    User -->|"config"| Config

    Job -->|"registers"| Eureka
    Job -->|"config"| Config

    Notification -->|"registers"| Eureka
    Notification -->|"config"| Config

    FileStorage -->|"registers"| Eureka
    FileStorage -->|"config"| Config

    %% Inter-service Communication via Feign Clients
    User -->|"Feign"| FileStorage
    Job -->|"Feign"| FileStorage

    %% Notification Service asynchronous messaging with Kafka
    Notification -->|"async"| Kafka

    %% Database and Cache connections for Microservices
    Auth -->|"db"| PostgreSQL
    User -->|"db"| PostgreSQL
    Job -->|"db"| PostgreSQL
    Notification -->|"db"| PostgreSQL
    FileStorage -->|"db"| PostgreSQL

    Auth -->|"cache"| Redis
    User -->|"cache"| Redis
    Job -->|"cache"| Redis
    Notification -->|"cache"| Redis
    FileStorage -->|"cache"| Redis

    %% Docker Compose deployment connections (dotted arrows)
    Docker ---|"deploys"| APIGateway
    Docker ---|"deploys"| Auth
    Docker ---|"deploys"| User
    Docker ---|"deploys"| Job
    Docker ---|"deploys"| Notification
    Docker ---|"deploys"| FileStorage
    Docker ---|"deploys"| Config
    Docker ---|"deploys"| Eureka

    %% Click Events
    click Config "https://github.com/devxsb/spring-boot-microservices/blob/main/config-server/src/main/java/com/safalifter/configserver/ConfigServerApplication.java"
    click Eureka "https://github.com/devxsb/spring-boot-microservices/blob/main/eureka-server/src/main/java/com/safalifter/eurekaserver/EurekaServerApplication.java"
    click APIGateway "https://github.com/devxsb/spring-boot-microservices/blob/main/gateway/src/main/java/com/safalifter/gateway/GatewayApplication.java"
    click Auth "https://github.com/devxsb/spring-boot-microservices/blob/main/auth-service/src/main/java/com/safalifter/authservice/AuthServiceApplication.java"
    click User "https://github.com/devxsb/spring-boot-microservices/blob/main/user-service/src/main/java/com/safalifter/userservice/UserServiceApplication.java"
    click Job "https://github.com/devxsb/spring-boot-microservices/blob/main/job-service/src/main/java/com/safalifter/jobservice/JobServiceApplication.java"
    click Notification "https://github.com/devxsb/spring-boot-microservices/blob/main/notification-service/src/main/java/com/safalifter/notificationservice/NotificationServiceApplication.java"
    click FileStorage "https://github.com/devxsb/spring-boot-microservices/blob/main/file-storage/src/main/java/com/safalifter/filestorage/FileStorageApplication.java"
    click Docker "https://github.com/devxsb/spring-boot-microservices/blob/main/docker-compose.yml"

    %% Styles
    classDef external fill:#f9c,stroke:#333,stroke-width:2px;
    classDef gateway fill:#bbf,stroke:#333,stroke-width:2px;
    classDef microservice fill:#cfc,stroke:#333,stroke-width:2px;
    classDef central fill:#fc9,stroke:#333,stroke-width:2px;
    classDef infrastructure fill:#cff,stroke:#333,stroke-width:2px;
```
