# rveggab/auth-api-service architecture

> Architecture diagram of the GitHub repository rveggab/auth-api-service, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-04-15). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/rveggab/auth-api-service
- Repository: https://github.com/rveggab/auth-api-service

## Overview

1. **What this repository is**
   - A **Spring Boot authentication/user-management service** built with **Maven**.
   - The code is organized in a **hexagonal / ports-and-adapters style**, separating web, application, domain, and persistence concerns.

2. **Runtime entrypoint**
   - `AuthApplication.java` is the main bootstrap class.
   - The app is run with Spring profiles, specifically **`dev`** and **`prod`** as documented in the README.

3. **Inbound API boundary**
   - The main inbound adapter is the **REST web layer** under `infrastructure.adapter.in.web`.
   - `UserController` exposes user-related endpoints and speaks only in request/response DTOs, not domain objects.

4. **Request/response contract layer**
   - Incoming payloads are modeled as:
     - `UserRequest`
     - `UpdateUserRequest`
     - `UpdateUserAdminRequest`
   - Outgoing payloads are modeled as:
     - `UserDetailResponse`
     - `BaseApiResponse`
   - This indicates the API layer is intentionally decoupled from the internal user model.

5. **Application layer orchestration**
   - Use cases live in `application.useCase`:
     - `RegisterUserCase`
     - `FindUserCase`
     - `UpdateUserCase`
   - Input ports define the service contracts:
     - `LoginUserInPort`
     - `RegisterUserInPort`
     - `FindUserInPort`
     - `UpdateUserInPort`
   - This is the business orchestration layer that coordinates validation, lookup, and persistence.

6. **Domain model and business rules**
   - The core domain is centered on `domain.model.identity.User`.
   - User state/roles are represented with enums:
     - `UserRoles`
     - `UserStatus`
   - Domain-specific failures are expressed through:
     - `AuthException`
     - `EntityAlreadyExistsException`
     - `EntityNotFoundException`
     - `InvalidDataException`

7. **Outbound persistence boundary**
   - The application layer depends on `UserRepositoryOutPort`, an abstract persistence contract.
   - The infrastructure layer implements that contract through:
     - `UserPersistenceAdapter`
     - `JpaUserAdapter`
   - This means the domain/application code is insulated from the concrete database mechanism.

8. **Persistence model**
   - `UserEntity` in `infrastructure.adapter.out` is the persistence representation.
   - The presence of a JPA adapter strongly suggests **Spring Data JPA / ORM-backed storage**, with mapping between `UserEntity` and the domain `User`.

9. **Mapping between layers**
   - `UserMapper` and `UserResponseMapper` handle transformation across boundaries:
     - request DTOs → domain model
     - domain model → response DTOs
     - domain model ↔ persistence entity
   - This is a key architectural seam: controllers and repositories do not share internal models directly.

10. **Cross-cutting infrastructure**
   - `SecurityConfig` defines application security behavior.
   - `CorsConfig` controls cross-origin access.
   - `OpenApiConfig` indicates API documentation generation.
   - `PasswordConfig` suggests password hashing/encoding is centralized and injected rather than hardcoded.

11. **Error handling path**
   - `GlobalExceptionHandler` centralizes translation of domain/application exceptions into API responses.
   - This keeps controllers thin and ensures consistent error formatting for clients.

12. **Primary data flow**
   - A request enters `UserController` → mapped to a request DTO or domain input → passed to a use case via an input port → the use case calls `UserRepositoryOutPort` → persistence adapter uses JPA/entity mapping → result returns back through mappers → controller returns a response DTO.
   - Errors at any layer are normalized by `GlobalExceptionHandler`.

13. **Project boundaries to keep in the diagram**
   - **Web/API boundary**: controllers, DTOs, exception handler.
   - **Application boundary**: ports and use cases.
   - **Domain boundary**: user model, enums, exceptions.
   - **Infrastructure boundary**: security, CORS, OpenAPI, password config, JPA/persistence adapters.

14. **Testing surface**
   - There is a basic application test (`AuthApplicationTests`), indicating at least bootstrapping validation is covered.
   - No deeper test structure is visible from the tree, so the architecture is primarily described by package structure rather than a large test harness.

15. **How to draw it**
   - Draw the system as a Spring Boot service with one main API surface for user/auth operations, an application core of use cases and ports, a domain core with user identity and rules, and infrastructure adapters for JPA persistence and HTTP/security concerns.

Main entry points: [`src/main/java/io/github/rveggab/auth/infrastructure/adapter/in/web/controller/UserController.java`](https://github.com/rveggab/auth-api-service/blob/main/src/main/java/io/github/rveggab/auth/infrastructure/adapter/in/web/controller/UserController.java) (User controller), [`src/main/java/io/github/rveggab/auth/domain/model/identity/User.java`](https://github.com/rveggab/auth-api-service/blob/main/src/main/java/io/github/rveggab/auth/domain/model/identity/User.java) (User), [`src/main/java/io/github/rveggab/auth/infrastructure/adapter/in/web/handler/GlobalExceptionHandler.java`](https://github.com/rveggab/auth-api-service/blob/main/src/main/java/io/github/rveggab/auth/infrastructure/adapter/in/web/handler/GlobalExceptionHandler.java) (Error handler), [`src/main/java/io/github/rveggab/auth/infrastructure/config/ApplicationConfig.java`](https://github.com/rveggab/auth-api-service/blob/main/src/main/java/io/github/rveggab/auth/infrastructure/config/ApplicationConfig.java) (App config)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_bootstrap["Bootstrap"]
  node_auth_app(("Auth app<br/>Spring Boot main"))
  node_auth_test["Boot test<br/>Application test"]
end

subgraph group_web["Web/API"]
  node_user_controller["User controller<br/>REST controller"]
  node_global_exception_handler["Error handler<br/>Exception advice"]
  node_user_request["User request<br/>Request DTO<br/>[UserRequest.java]"]
  node_update_user_request["Update request<br/>Request DTO"]
  node_update_user_admin_request["Admin update<br/>Request DTO"]
  node_user_detail_response["User detail<br/>Response DTO"]
  node_base_api_response["Base response<br/>Response DTO"]
end

subgraph group_application["Application"]
  node_register_case["Register use case<br/>Application service"]
  node_find_case["Find use case<br/>Application service<br/>[FindUserCase.java]"]
  node_update_case["Update use case<br/>Application service"]
  node_login_in_port{{"Login port<br/>Inbound port"}}
  node_register_in_port{{"Register port<br/>Inbound port"}}
  node_find_in_port{{"Find port<br/>Inbound port"}}
  node_update_in_port{{"Update port<br/>Inbound port"}}
  node_user_repo_out_port{{"Repo port<br/>Outbound port"}}
end

subgraph group_domain["Domain"]
  node_user_domain(("User<br/>Domain model<br/>[User.java]"))
  node_user_roles["Roles<br/>Domain enum<br/>[UserRoles.java]"]
  node_user_status["Status<br/>Domain enum<br/>[UserStatus.java]"]
  node_auth_exception["Auth error<br/>Domain exception<br/>[AuthException.java]"]
  node_entity_exists_exception["Exists error<br/>Domain exception"]
  node_entity_not_found_exception["Not found<br/>Domain exception"]
  node_invalid_data_exception["Invalid data<br/>Domain exception"]
end

subgraph group_infrastructure["Infrastructure"]
  node_application_config["App config<br/>Infra config"]
  node_security_config["Security"]
  node_cors_config["CORS<br/>Web config<br/>[CorsConfig.java]"]
  node_openapi_config["OpenAPI<br/>Docs config<br/>[OpenApiConfig.java]"]
  node_password_config["Password<br/>Crypto config"]
  node_user_persistence_adapter["Persistence adapter<br/>Outbound adapter"]
  node_jpa_user_adapter["JPA adapter<br/>Jpa repository adapter"]
  node_user_entity[("User entity<br/>Persistence entity<br/>[UserEntity.java]")]
  node_user_mapper["User mapper<br/>Model mapper<br/>[UserMapper.java]"]
  node_user_response_mapper["Response mapper<br/>DTO mapper"]
end

node_auth_app -->|"starts"| node_user_controller
node_auth_test -.->|"verifies"| node_auth_app
node_user_controller -->|"register"| node_register_in_port
node_user_controller -->|"find"| node_find_in_port
node_user_controller -->|"update"| node_update_in_port
node_user_controller -->|"maps"| node_user_mapper
node_user_controller -->|"renders"| node_user_response_mapper
node_global_exception_handler -->|"handles"| node_auth_exception
node_global_exception_handler -->|"handles"| node_entity_exists_exception
node_global_exception_handler -->|"handles"| node_entity_not_found_exception
node_global_exception_handler -->|"handles"| node_invalid_data_exception
node_register_case -->|"implements"| node_register_in_port
node_find_case -->|"implements"| node_find_in_port
node_update_case -->|"implements"| node_update_in_port
node_register_case -->|"uses"| node_user_repo_out_port
node_find_case -->|"uses"| node_user_repo_out_port
node_update_case -->|"uses"| node_user_repo_out_port
node_user_repo_out_port -->|"adapts to"| node_user_persistence_adapter
node_user_persistence_adapter -->|"delegates"| node_jpa_user_adapter
node_jpa_user_adapter -->|"persists"| node_user_entity
node_user_mapper -->|"maps"| node_user_domain
node_user_mapper -->|"maps"| node_user_entity
node_user_response_mapper -->|"maps"| node_user_domain
node_user_domain -->|"uses"| node_user_roles
node_user_domain -->|"uses"| node_user_status
node_user_domain -->|"throws"| node_auth_exception
node_user_domain -->|"throws"| node_entity_exists_exception
node_user_domain -->|"throws"| node_entity_not_found_exception
node_user_domain -->|"throws"| node_invalid_data_exception
node_application_config -->|"wires"| node_security_config
node_application_config -->|"wires"| node_cors_config
node_application_config -->|"wires"| node_openapi_config
node_application_config -->|"wires"| node_password_config
node_security_config -->|"uses"| node_password_config
node_user_controller -->|"returns"| node_base_api_response
node_user_controller -->|"accepts"| node_user_request
node_user_controller -->|"accepts"| node_update_user_request
node_user_controller -->|"accepts"| node_update_user_admin_request
node_user_controller -->|"returns"| node_user_detail_response

click node_auth_app "https://github.com/rveggab/auth-api-service/blob/main/src/main/java/io/github/rveggab/auth/AuthApplication.java"
click node_auth_test "https://github.com/rveggab/auth-api-service/blob/main/src/test/java/io/github/rveggab/auth/AuthApplicationTests.java"
click node_user_controller "https://github.com/rveggab/auth-api-service/blob/main/src/main/java/io/github/rveggab/auth/infrastructure/adapter/in/web/controller/UserController.java"
click node_global_exception_handler "https://github.com/rveggab/auth-api-service/blob/main/src/main/java/io/github/rveggab/auth/infrastructure/adapter/in/web/handler/GlobalExceptionHandler.java"
click node_user_request "https://github.com/rveggab/auth-api-service/blob/main/src/main/java/io/github/rveggab/auth/infrastructure/adapter/in/web/dto/request/UserRequest.java"
click node_update_user_request "https://github.com/rveggab/auth-api-service/blob/main/src/main/java/io/github/rveggab/auth/infrastructure/adapter/in/web/dto/request/UpdateUserRequest.java"
click node_update_user_admin_request "https://github.com/rveggab/auth-api-service/blob/main/src/main/java/io/github/rveggab/auth/infrastructure/adapter/in/web/dto/request/UpdateUserAdminRequest.java"
click node_user_detail_response "https://github.com/rveggab/auth-api-service/blob/main/src/main/java/io/github/rveggab/auth/infrastructure/adapter/in/web/dto/response/UserDetailResponse.java"
click node_base_api_response "https://github.com/rveggab/auth-api-service/blob/main/src/main/java/io/github/rveggab/auth/infrastructure/adapter/in/web/dto/BaseApiResponse.java"
click node_register_case "https://github.com/rveggab/auth-api-service/blob/main/src/main/java/io/github/rveggab/auth/application/useCase/RegisterUserCase.java"
click node_find_case "https://github.com/rveggab/auth-api-service/blob/main/src/main/java/io/github/rveggab/auth/application/useCase/FindUserCase.java"
click node_update_case "https://github.com/rveggab/auth-api-service/blob/main/src/main/java/io/github/rveggab/auth/application/useCase/UpdateUserCase.java"
click node_login_in_port "https://github.com/rveggab/auth-api-service/blob/main/src/main/java/io/github/rveggab/auth/application/ports/in/LoginUserInPort.java"
click node_register_in_port "https://github.com/rveggab/auth-api-service/blob/main/src/main/java/io/github/rveggab/auth/application/ports/in/RegisterUserInPort.java"
click node_find_in_port "https://github.com/rveggab/auth-api-service/blob/main/src/main/java/io/github/rveggab/auth/application/ports/in/FindUserInPort.java"
click node_update_in_port "https://github.com/rveggab/auth-api-service/blob/main/src/main/java/io/github/rveggab/auth/application/ports/in/UpdateUserInPort.java"
click node_user_repo_out_port "https://github.com/rveggab/auth-api-service/blob/main/src/main/java/io/github/rveggab/auth/application/ports/out/UserRepositoryOutPort.java"
click node_user_domain "https://github.com/rveggab/auth-api-service/blob/main/src/main/java/io/github/rveggab/auth/domain/model/identity/User.java"
click node_user_roles "https://github.com/rveggab/auth-api-service/blob/main/src/main/java/io/github/rveggab/auth/domain/model/enums/UserRoles.java"
click node_user_status "https://github.com/rveggab/auth-api-service/blob/main/src/main/java/io/github/rveggab/auth/domain/model/enums/UserStatus.java"
click node_auth_exception "https://github.com/rveggab/auth-api-service/blob/main/src/main/java/io/github/rveggab/auth/domain/exceptions/AuthException.java"
click node_entity_exists_exception "https://github.com/rveggab/auth-api-service/blob/main/src/main/java/io/github/rveggab/auth/domain/exceptions/EntityAlreadyExistsException.java"
click node_entity_not_found_exception "https://github.com/rveggab/auth-api-service/blob/main/src/main/java/io/github/rveggab/auth/domain/exceptions/EntityNotFoundException.java"
click node_invalid_data_exception "https://github.com/rveggab/auth-api-service/blob/main/src/main/java/io/github/rveggab/auth/domain/exceptions/InvalidDataException.java"
click node_application_config "https://github.com/rveggab/auth-api-service/blob/main/src/main/java/io/github/rveggab/auth/infrastructure/config/ApplicationConfig.java"
click node_security_config "https://github.com/rveggab/auth-api-service/blob/main/src/main/java/io/github/rveggab/auth/infrastructure/config/SecurityConfig.java"
click node_cors_config "https://github.com/rveggab/auth-api-service/blob/main/src/main/java/io/github/rveggab/auth/infrastructure/config/CorsConfig.java"
click node_openapi_config "https://github.com/rveggab/auth-api-service/blob/main/src/main/java/io/github/rveggab/auth/infrastructure/config/OpenApiConfig.java"
click node_password_config "https://github.com/rveggab/auth-api-service/blob/main/src/main/java/io/github/rveggab/auth/infrastructure/config/PasswordConfig.java"
click node_user_persistence_adapter "https://github.com/rveggab/auth-api-service/blob/main/src/main/java/io/github/rveggab/auth/infrastructure/adapter/in/user/UserPersistenceAdapter.java"
click node_jpa_user_adapter "https://github.com/rveggab/auth-api-service/blob/main/src/main/java/io/github/rveggab/auth/infrastructure/adapter/in/user/JpaUserAdapter.java"
click node_user_entity "https://github.com/rveggab/auth-api-service/blob/main/src/main/java/io/github/rveggab/auth/infrastructure/adapter/out/UserEntity.java"
click node_user_mapper "https://github.com/rveggab/auth-api-service/blob/main/src/main/java/io/github/rveggab/auth/infrastructure/adapter/mapper/UserMapper.java"
click node_user_response_mapper "https://github.com/rveggab/auth-api-service/blob/main/src/main/java/io/github/rveggab/auth/infrastructure/adapter/mapper/UserResponseMapper.java"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_auth_app,node_auth_test toneBlue
class node_user_controller,node_global_exception_handler,node_user_request,node_update_user_request,node_update_user_admin_request,node_user_detail_response,node_base_api_response toneAmber
class node_register_case,node_find_case,node_update_case,node_login_in_port,node_register_in_port,node_find_in_port,node_update_in_port,node_user_repo_out_port toneMint
class node_user_domain,node_user_roles,node_user_status,node_auth_exception,node_entity_exists_exception,node_entity_not_found_exception,node_invalid_data_exception toneRose
class node_application_config,node_security_config,node_cors_config,node_openapi_config,node_password_config,node_user_persistence_adapter,node_jpa_user_adapter,node_user_entity,node_user_mapper,node_user_response_mapper toneIndigo
```

## Components

### Bootstrap

Application entrypoint and smoke test

- [Auth app](https://github.com/rveggab/auth-api-service/blob/main/src/main/java/io/github/rveggab/auth/AuthApplication.java): Spring Boot main · Application bootstrap and runtime entrypoint · `src/main/java/io/github/rveggab/auth/AuthApplication.java`
- [Boot test](https://github.com/rveggab/auth-api-service/blob/main/src/test/java/io/github/rveggab/auth/AuthApplicationTests.java): Application test · Basic startup verification · `src/test/java/io/github/rveggab/auth/AuthApplicationTests.java`

### Web/API

HTTP boundary, DTOs, and exception translation

- [User controller](https://github.com/rveggab/auth-api-service/blob/main/src/main/java/io/github/rveggab/auth/infrastructure/adapter/in/web/controller/UserController.java): REST controller · Inbound HTTP API for user operations · `src/main/java/io/github/rveggab/auth/infrastructure/adapter/in/web/controller/UserController.java`
- [Error handler](https://github.com/rveggab/auth-api-service/blob/main/src/main/java/io/github/rveggab/auth/infrastructure/adapter/in/web/handler/GlobalExceptionHandler.java): Exception advice · Maps domain and application failures to API responses · `src/main/java/io/github/rveggab/auth/infrastructure/adapter/in/web/handler/GlobalExceptionHandler.java`
- [User request](https://github.com/rveggab/auth-api-service/blob/main/src/main/java/io/github/rveggab/auth/infrastructure/adapter/in/web/dto/request/UserRequest.java): Request DTO · Create-user inbound payload · `src/main/java/io/github/rveggab/auth/infrastructure/adapter/in/web/dto/request/UserRequest.java`
- [Update request](https://github.com/rveggab/auth-api-service/blob/main/src/main/java/io/github/rveggab/auth/infrastructure/adapter/in/web/dto/request/UpdateUserRequest.java): Request DTO · User update inbound payload · `src/main/java/io/github/rveggab/auth/infrastructure/adapter/in/web/dto/request/UpdateUserRequest.java`
- [Admin update](https://github.com/rveggab/auth-api-service/blob/main/src/main/java/io/github/rveggab/auth/infrastructure/adapter/in/web/dto/request/UpdateUserAdminRequest.java): Request DTO · Privileged user update inbound payload · `src/main/java/io/github/rveggab/auth/infrastructure/adapter/in/web/dto/request/UpdateUserAdminRequest.java`
- [User detail](https://github.com/rveggab/auth-api-service/blob/main/src/main/java/io/github/rveggab/auth/infrastructure/adapter/in/web/dto/response/UserDetailResponse.java): Response DTO · User details returned to clients · `src/main/java/io/github/rveggab/auth/infrastructure/adapter/in/web/dto/response/UserDetailResponse.java`
- [Base response](https://github.com/rveggab/auth-api-service/blob/main/src/main/java/io/github/rveggab/auth/infrastructure/adapter/in/web/dto/BaseApiResponse.java): Response DTO · Common API response envelope · `src/main/java/io/github/rveggab/auth/infrastructure/adapter/in/web/dto/BaseApiResponse.java`

### Application

Use cases and ports

- [Register use case](https://github.com/rveggab/auth-api-service/blob/main/src/main/java/io/github/rveggab/auth/application/useCase/RegisterUserCase.java): Application service · Coordinates user registration · `src/main/java/io/github/rveggab/auth/application/useCase/RegisterUserCase.java`
- [Find use case](https://github.com/rveggab/auth-api-service/blob/main/src/main/java/io/github/rveggab/auth/application/useCase/FindUserCase.java): Application service · Coordinates user lookup · `src/main/java/io/github/rveggab/auth/application/useCase/FindUserCase.java`
- [Update use case](https://github.com/rveggab/auth-api-service/blob/main/src/main/java/io/github/rveggab/auth/application/useCase/UpdateUserCase.java): Application service · Coordinates user update flows · `src/main/java/io/github/rveggab/auth/application/useCase/UpdateUserCase.java`
- [Login port](https://github.com/rveggab/auth-api-service/blob/main/src/main/java/io/github/rveggab/auth/application/ports/in/LoginUserInPort.java): Inbound port · Login service contract · `src/main/java/io/github/rveggab/auth/application/ports/in/LoginUserInPort.java`
- [Register port](https://github.com/rveggab/auth-api-service/blob/main/src/main/java/io/github/rveggab/auth/application/ports/in/RegisterUserInPort.java): Inbound port · Registration service contract · `src/main/java/io/github/rveggab/auth/application/ports/in/RegisterUserInPort.java`
- [Find port](https://github.com/rveggab/auth-api-service/blob/main/src/main/java/io/github/rveggab/auth/application/ports/in/FindUserInPort.java): Inbound port · User lookup service contract · `src/main/java/io/github/rveggab/auth/application/ports/in/FindUserInPort.java`
- [Update port](https://github.com/rveggab/auth-api-service/blob/main/src/main/java/io/github/rveggab/auth/application/ports/in/UpdateUserInPort.java): Inbound port · User update service contract · `src/main/java/io/github/rveggab/auth/application/ports/in/UpdateUserInPort.java`
- [Repo port](https://github.com/rveggab/auth-api-service/blob/main/src/main/java/io/github/rveggab/auth/application/ports/out/UserRepositoryOutPort.java): Outbound port · Persistence contract for users · `src/main/java/io/github/rveggab/auth/application/ports/out/UserRepositoryOutPort.java`

### Domain

Core identity model and business failures

- [User](https://github.com/rveggab/auth-api-service/blob/main/src/main/java/io/github/rveggab/auth/domain/model/identity/User.java): Domain model · Core identity aggregate · `src/main/java/io/github/rveggab/auth/domain/model/identity/User.java`
- [Roles](https://github.com/rveggab/auth-api-service/blob/main/src/main/java/io/github/rveggab/auth/domain/model/enums/UserRoles.java): Domain enum · User role definitions · `src/main/java/io/github/rveggab/auth/domain/model/enums/UserRoles.java`
- [Status](https://github.com/rveggab/auth-api-service/blob/main/src/main/java/io/github/rveggab/auth/domain/model/enums/UserStatus.java): Domain enum · User lifecycle states · `src/main/java/io/github/rveggab/auth/domain/model/enums/UserStatus.java`
- [Auth error](https://github.com/rveggab/auth-api-service/blob/main/src/main/java/io/github/rveggab/auth/domain/exceptions/AuthException.java): Domain exception · Base authentication failure · `src/main/java/io/github/rveggab/auth/domain/exceptions/AuthException.java`
- [Exists error](https://github.com/rveggab/auth-api-service/blob/main/src/main/java/io/github/rveggab/auth/domain/exceptions/EntityAlreadyExistsException.java): Domain exception · Duplicate entity failure · `src/main/java/io/github/rveggab/auth/domain/exceptions/EntityAlreadyExistsException.java`
- [Not found](https://github.com/rveggab/auth-api-service/blob/main/src/main/java/io/github/rveggab/auth/domain/exceptions/EntityNotFoundException.java): Domain exception · Missing entity failure · `src/main/java/io/github/rveggab/auth/domain/exceptions/EntityNotFoundException.java`
- [Invalid data](https://github.com/rveggab/auth-api-service/blob/main/src/main/java/io/github/rveggab/auth/domain/exceptions/InvalidDataException.java): Domain exception · Validation and data integrity failure · `src/main/java/io/github/rveggab/auth/domain/exceptions/InvalidDataException.java`

### Infrastructure

Security, persistence, and external adapters

- [App config](https://github.com/rveggab/auth-api-service/blob/main/src/main/java/io/github/rveggab/auth/infrastructure/config/ApplicationConfig.java): Infra config · Core bean wiring · `src/main/java/io/github/rveggab/auth/infrastructure/config/ApplicationConfig.java`
- [Security](https://github.com/rveggab/auth-api-service/blob/main/src/main/java/io/github/rveggab/auth/infrastructure/config/SecurityConfig.java): Security config · Authentication and authorization setup · `src/main/java/io/github/rveggab/auth/infrastructure/config/SecurityConfig.java`
- [CORS](https://github.com/rveggab/auth-api-service/blob/main/src/main/java/io/github/rveggab/auth/infrastructure/config/CorsConfig.java): Web config · Cross-origin policy · `src/main/java/io/github/rveggab/auth/infrastructure/config/CorsConfig.java`
- [OpenAPI](https://github.com/rveggab/auth-api-service/blob/main/src/main/java/io/github/rveggab/auth/infrastructure/config/OpenApiConfig.java): Docs config · API documentation setup · `src/main/java/io/github/rveggab/auth/infrastructure/config/OpenApiConfig.java`
- [Password](https://github.com/rveggab/auth-api-service/blob/main/src/main/java/io/github/rveggab/auth/infrastructure/config/PasswordConfig.java): Crypto config · Password encoder and hashing setup · `src/main/java/io/github/rveggab/auth/infrastructure/config/PasswordConfig.java`
- [Persistence adapter](https://github.com/rveggab/auth-api-service/blob/main/src/main/java/io/github/rveggab/auth/infrastructure/adapter/in/user/UserPersistenceAdapter.java): Outbound adapter · Implements user repository port · `src/main/java/io/github/rveggab/auth/infrastructure/adapter/in/user/UserPersistenceAdapter.java`
- [JPA adapter](https://github.com/rveggab/auth-api-service/blob/main/src/main/java/io/github/rveggab/auth/infrastructure/adapter/in/user/JpaUserAdapter.java): Jpa repository adapter · Database-facing persistence implementation · `src/main/java/io/github/rveggab/auth/infrastructure/adapter/in/user/JpaUserAdapter.java`
- [User entity](https://github.com/rveggab/auth-api-service/blob/main/src/main/java/io/github/rveggab/auth/infrastructure/adapter/out/UserEntity.java): Persistence entity · ORM-backed user record · `src/main/java/io/github/rveggab/auth/infrastructure/adapter/out/UserEntity.java`
- [User mapper](https://github.com/rveggab/auth-api-service/blob/main/src/main/java/io/github/rveggab/auth/infrastructure/adapter/mapper/UserMapper.java): Model mapper · Transforms requests and entities to domain model · `src/main/java/io/github/rveggab/auth/infrastructure/adapter/mapper/UserMapper.java`
- [Response mapper](https://github.com/rveggab/auth-api-service/blob/main/src/main/java/io/github/rveggab/auth/infrastructure/adapter/mapper/UserResponseMapper.java): DTO mapper · Transforms domain data to API responses · `src/main/java/io/github/rveggab/auth/infrastructure/adapter/mapper/UserResponseMapper.java`

## Connections

- Auth app → User controller: starts · Bootstraps the web API and application context
- Boot test → Auth app: verifies · Confirms the application starts
- User controller → Register port: register · Delegates registration requests through the inbound port
- User controller → Find port: find · Delegates lookup requests through the inbound port
- User controller → Update port: update · Delegates update requests through the inbound port
- User controller → User mapper: maps · Converts inbound request DTOs to internal models
- User controller → Response mapper: renders · Converts internal results to response DTOs
- Error handler → Auth error: handles · Normalizes domain failures for the API
- Error handler → Exists error: handles · Normalizes duplicate-entity failures
- Error handler → Not found: handles · Normalizes not-found failures
- Error handler → Invalid data: handles · Normalizes invalid-data failures
- Register use case → Register port: implements · Backs the registration input contract
- Find use case → Find port: implements · Backs the lookup input contract
- Update use case → Update port: implements · Backs the update input contract
- Register use case → Repo port: uses · Reads and writes users through the repository abstraction
- Find use case → Repo port: uses · Reads users through the repository abstraction
- Update use case → Repo port: uses · Persists updates through the repository abstraction
- Repo port → Persistence adapter: adapts to · Implemented by the infrastructure persistence adapter
- Persistence adapter → JPA adapter: delegates · Bridges the port to the JPA layer
- JPA adapter → User entity: persists · Stores and loads ORM entities
- User mapper → User: maps · Converts between request/persistence data and the domain user
- User mapper → User entity: maps · Converts between domain user and persistence entity
- Response mapper → User: maps · Converts domain user data to API response models
- User → Roles: uses · Encodes role state
- User → Status: uses · Encodes lifecycle state
- User → Auth error: throws · Uses domain-specific failure types
- User → Exists error: throws · Uses domain-specific failure types
- User → Not found: throws · Uses domain-specific failure types
- User → Invalid data: throws · Uses domain-specific failure types
- App config → Security: wires · Central configuration loads security concerns
- App config → CORS: wires · Central configuration loads web policy
- App config → OpenAPI: wires · Central configuration loads API docs
- App config → Password: wires · Central configuration loads password encoding
- Security → Password: uses · Security depends on password encoding
- User controller → Base response: returns · Wraps endpoint responses in a shared envelope
- User controller → User request: accepts · Consumes create-user request payloads
- User controller → Update request: accepts · Consumes standard update payloads
- User controller → Admin update: accepts · Consumes admin update payloads
- User controller → User detail: returns · Produces user detail responses
