# juancursed/user_microservice architecture

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

- Interactive diagram: https://gitdiagram.com/juancursed/user_microservice
- Repository: https://github.com/juancursed/user_microservice

## Overview

##### Main Components
- UserMicroserviceApplication – The entry point for the Spring Boot application.
- Application Layer – Contains the use cases (e.g., SaveUserUseCase, GetUserByIdUseCase, UpdateUserUseCase, DeleteUserUseCase, GetUserByEmailUseCase) that encapsulate the business logic.
- Delivery Layer – Includes the RESTful controller (UserController) which handles incoming HTTP requests.
- Domain Layer – Consists of the core business models and logic (e.g., User and Role, along with the repository interface UserRepository).
- Infrastructure Layer – Provides persistence implementations (e.g., UserRepositorySpringData under persistence) that integrate with Spring Data and potentially a database.
- Security Component – The SecurityConfig class which configures security settings.
- CI/CD and Deployment Scripts – Not a logical component of the running system, but files like Dockerfile, .github/workflows config indicate containerization and continuous integration practices.

##### Relationships & Interactions
- The REST API (UserController) receives HTTP requests and directs them to the appropriate Use Case in the Application Layer.
- The Use Case classes interact with the Domain Layer to enforce business rules and then delegate data access tasks to the Infrastructure Layer.
- The Infrastructure Layer (UserRepositorySpringData) implements the domain repository interface (UserRepository) and communicates with the database.
- The SecurityConfig is globally applied to secure the endpoints, influencing the flow at the delivery layer.
- The main application class wires-up and bootstraps the application, integrating all layers.

##### Architectural Patterns and Principles
- Layered Architecture/Clean Architecture – The code is segmented into delivery, application, domain, and infrastructure layers.
- Domain-Driven Design – Clear separation of domain models and business logic.
- Use of Spring Boot and Spring Data – Indicating dependency injection and repository pattern usage.
- Containerization – The Dockerfile suggests that the microservice is built with containerization in mind.

## Diagram (Mermaid)

```mermaid
graph TD
    subgraph "Client"
        C1["Client Request"]:::client
    end

    subgraph "Entry Point"
        A["UserMicroserviceApplication"]:::entry
    end

    subgraph "Delivery Layer / REST"
        B["UserController"]:::delivery
        C["SecurityConfig"]:::security
    end

    subgraph "Application Layer / Use Cases"
        D["Use Cases"]:::application
    end

    subgraph "Domain Layer"
        E["Domain Models (User & Role)"]:::domain
        F["UserRepository (Interface)"]:::domain
    end

    subgraph "Infrastructure Layer / Persistence"
        G["UserRepositorySpringData"]:::infrastructure
        H["Database"]:::infrastructure
    end

    subgraph "CI/CD & Deployment"
        I["Dockerfile"]:::deployment
        J["GitHub Workflows"]:::deployment
    end

    C1 -->|"sendsHTTPCall"| B
    A -->|"wires"| B
    A -->|"configures"| C
    A -->|"wires"| D
    C -->|"secures"| B
    B -->|"delegatesTo"| D
    D -->|"appliesBusinessLogicTo"| E
    D -->|"delegatesTo"| F
    F -->|"implementedBy"| G
    G -->|"persistsDataIn"| H

    click A "https://github.com/juancursed/user_microservice/blob/main/src/main/java/com/example/user_microservice/UserMicroserviceApplication.java"
    click C "https://github.com/juancursed/user_microservice/blob/main/src/main/java/com/example/user_microservice/application/SecurityConfig.java"
    click B "https://github.com/juancursed/user_microservice/blob/main/src/main/java/com/example/user_microservice/delivery/rest/UserController.java"
    click D "https://github.com/juancursed/user_microservice/tree/main/src/main/java/com/example/user_microservice/application/usecase"
    click E "https://github.com/juancursed/user_microservice/tree/main/src/main/java/com/example/user_microservice/domain/model"
    click F "https://github.com/juancursed/user_microservice/blob/main/src/main/java/com/example/user_microservice/domain/repository/UserRepository.java"
    click G "https://github.com/juancursed/user_microservice/blob/main/src/main/java/com/example/user_microservice/infraestructure/persistence/UserRepositorySpringData.java"
    click I "https://github.com/juancursed/user_microservice/tree/main/Dockerfile"
    click J "https://github.com/juancursed/user_microservice/blob/main/.github/workflows/ci_user_service.yml"

    classDef client fill:#ccf,stroke:#333,stroke-width:2px;
    classDef entry fill:#f9c,stroke:#333,stroke-width:2px;
    classDef delivery fill:#bbf,stroke:#333,stroke-width:2px;
    classDef security fill:#f88,stroke:#333,stroke-width:2px;
    classDef application fill:#bfb,stroke:#333,stroke-width:2px;
    classDef domain fill:#ffb,stroke:#333,stroke-width:2px;
    classDef infrastructure fill:#ddd,stroke:#333,stroke-width:2px;
    classDef deployment fill:#fea,stroke:#333,stroke-width:2px;
```
