# jhoanatanchaparro/java architecture

> Architecture diagram of the GitHub repository jhoanatanchaparro/java, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-06-17). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/jhoanatanchaparro/java
- Repository: https://github.com/jhoanatanchaparro/java

## Overview

This repo contains two separate Spring Boot applications, each with its own `pom.xml`, bootstrap class, and runtime boundaries:

1. **`EjercicioAutonomo`** is a classic layered Spring app with both **server-rendered views** and **API-style controllers**.
2. **`facturacion-prod`** is a second Spring Boot service focused on **facturation/invoicing**, with REST controllers, persistence, DTO mapping, and security.

##### 1) Top-level structure: two independent applications
These are not just modules of one app; they appear to be **two deployable services** living side by side in the same repository. Each has its own:
- Spring Boot main class
- resources/configuration
- repository/service/controller stack
- tests

That means architecture diagrams should show them as **separate bounded contexts**, not a single monolith.

##### 2) `EjercicioAutonomo`: domain-oriented CRUD app
This app manages a small business domain:
- `Categoria`
- `Producto`
- `Proveedor`
- `Cliente`
- `Orden_Compra`
- `Orden_Detalle`

The package layout suggests a standard flow:
**Controller → Service → Repository → Entity/DB**, with DTOs at the boundary.

##### 3) Dual presentation layer in `EjercicioAutonomo`
This app has two controller styles:
- `Controller/*` for REST-like endpoints
- `Controller/View/*` for HTML page rendering backed by templates in `src/main/resources/templates`

So the app likely serves both:
- browser pages for CRUD screens
- JSON endpoints for programmatic access

That is an important boundary for the diagram: **UI templates and REST endpoints are separate entry paths into the same domain services**.

##### 4) DTO + mapper boundary in `EjercicioAutonomo`
For each domain area there are:
- `Dto/Request/*`
- `Dto/Response/*`
- `Mapper/*`

That implies input/output data is intentionally decoupled from persistence entities. The services likely translate:
- request DTOs → entities
- entities → response DTOs

This is the main anti-corruption boundary between transport and persistence.

##### 5) Persistence layer in `EjercicioAutonomo`
Repositories exist for each aggregate:
- `CategoriaRepository`
- `ProductoRepository`
- `ProveedorRepository`
- `ClienteRepository`
- `OrdenCompraRepository`
- `OrdenDetalleRepository`

Entities are stored under `Entity/`, so the app likely uses Spring Data JPA with relational persistence. The diagram should show repositories as the only layer directly touching the database.

##### 6) External service integration in `EjercicioAutonomo`
This app also includes:
- `Feign/ClienteFeignClient`
- `Controller/Feign/ClienteFeignController`
- `Service/Servicelmpl/ClienteFeignServiceImpl`
- `Config/FeignConfig`

That indicates an outbound integration via **Spring Cloud OpenFeign** to a remote client/customer service. This is a separate flow from local CRUD:
**Feign controller/service → Feign client → external HTTP service**.

##### 7) Caching and resilience concerns in `EjercicioAutonomo`
`Config/CacheConfig.java` shows a cache layer is enabled or configured. That suggests some service results may be cached, probably to reduce repeated reads or remote calls. Even if the cache backend is not visible here, it is a distinct architectural concern worth marking around the service layer.

##### 8) Error handling in `EjercicioAutonomo`
`Exception/GlobalExceptionHandler.java` and `ResourceNotFoundException.java` indicate centralized exception translation. In the diagram, this sits as a cross-cutting boundary around controllers/services:
- domain/service errors are converted into HTTP responses
- not-found cases are handled consistently

##### 9) `facturacion-prod`: invoice and product service
The second app is narrower and centers on:
- `Factura`
- `DetalleFactura`
- `Producto`

Its structure is also layered:
**Controller → Service → Repository → Model/DB**

This suggests a transactional invoice domain where a `Factura` contains one or more `DetalleFactura` entries.

##### 10) DTO mapping in `facturacion-prod`
This app uses DTOs explicitly:
- `RequestFacturaDTO`
- `RequestDetalleFacturaDTO`
- `ResponseFacturaDTO`
- `ResponseDetalleFacturaDTO`
- `ProductoDto`

It also has `Configuration/ModelMapperConfig.java`, so object mapping is automated rather than hand-written. That means the diagram should show a DTO mapping boundary between controllers and the model layer.

##### 11) Security boundary in `facturacion-prod`
`Configuration/Security.java` is a major architectural feature. It implies endpoints are protected and requests pass through a security layer before reaching controllers. This is the main cross-cutting boundary in this service and should be shown separately from business logic.

##### 12) Persistence in `facturacion-prod`
Repositories exist for:
- `FacturaReposistory`
- `DetalleFacturaRepository`
- `ProductoRepository`

The model classes are under `Model/`, so persistence is likely JPA-based. The service layer coordinates invoice creation and product lookup, while repositories isolate database access.

##### 13) Likely data flow in `facturacion-prod`
The most important runtime path is:
1. Client calls `FacturaController`
2. Security validates/filters the request
3. `FacturaService` processes invoice logic
4. Repositories persist `Factura` and `DetalleFactura`
5. DTOs are returned to the caller

`ProductoController`/`ProductoService` likely provide a supporting catalog flow used by invoices.

##### 14) How to diagram the whole repo
A good architecture diagram should show:
- **two separate Spring Boot services**
- `EjercicioAutonomo` with:
  - HTML views
  - REST/API controllers
  - Feign outbound integration
  - cache and global exception handling
- `facturacion-prod` with:
  - secured REST controllers
  - service/repository/model layers
  - DTO mapping via ModelMapper
  - invoice + invoice-detail aggregate

The strongest boundary in the repo is between:
- **presentation/API**
- **application/service logic**
- **persistence**
- **external HTTP service integration** (only in `EjercicioAutonomo`)

Main entry points: [`EjercicioAutonomo/src/main/java/com/example/EjercicioAutonomo/Service`](https://github.com/jhoanatanchaparro/java/tree/main/EjercicioAutonomo/src/main/java/com/example/EjercicioAutonomo/Service) (Domain Services), [`facturacion-prod/src/main/java/com/icodeap/facturacion_prod/Services`](https://github.com/jhoanatanchaparro/java/tree/main/facturacion-prod/src/main/java/com/icodeap/facturacion_prod/Services) (Services), [`EjercicioAutonomo/src/main/java/com/example/EjercicioAutonomo/Controller`](https://github.com/jhoanatanchaparro/java/tree/main/EjercicioAutonomo/src/main/java/com/example/EjercicioAutonomo/Controller) (REST API), [`EjercicioAutonomo/src/main/java/com/example/EjercicioAutonomo/Mapper`](https://github.com/jhoanatanchaparro/java/tree/main/EjercicioAutonomo/src/main/java/com/example/EjercicioAutonomo/Mapper) (Mappers)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_grp_ejercicio["EjercicioAutonomo"]
  node_ej_app(("EjercicioAutonomo<br/>Spring Boot app"))
  node_ej_web["Web UI<br/>MVC views"]
  node_ej_api["REST API<br/>controllers"]
  node_ej_dto["DTOs<br/>request/response"]
  node_ej_mapper{{"Mappers<br/>mapping"}}
  node_ej_service["Domain Services<br/>application services"]
  node_ej_repo[("Repositories")]
  node_ej_entity["Entities"]
  node_ej_feign_ctrl["Feign API<br/>outbound controller"]
  node_ej_feign_svc["Feign Service<br/>integration service"]
  node_ej_feign_client{{"Feign Client<br/>HTTP client"}}
  node_ej_config["Config"]
  node_ej_error{{"Errors<br/>exception handling"}}
end

subgraph group_grp_facturacion["facturacion-prod"]
  node_fact_app(("facturacion-prod<br/>Spring Boot app"))
  node_fact_sec{{"Security<br/>filter/config<br/>[Security.java]"}}
  node_fact_ctrl["Controllers"]
  node_fact_dto["DTOs<br/>request/response"]
  node_fact_svc["Services"]
  node_fact_repo[("Repositories")]
  node_fact_model["Models"]
  node_fact_mapper{{"ModelMapper<br/>mapping config"}}
end

node_ej_app -->|"serves"| node_ej_web
node_ej_app -->|"serves"| node_ej_api
node_ej_web -->|"uses"| node_ej_service
node_ej_api -->|"uses"| node_ej_service
node_ej_service -->|"maps"| node_ej_mapper
node_ej_mapper -->|"transforms"| node_ej_dto
node_ej_mapper -->|"transforms"| node_ej_entity
node_ej_service -->|"persists via"| node_ej_repo
node_ej_repo -->|"stores"| node_ej_entity
node_ej_feign_ctrl -->|"delegates"| node_ej_feign_svc
node_ej_feign_svc -->|"calls"| node_ej_feign_client
node_ej_feign_client -.->|"configured by"| node_ej_config
node_ej_service -.->|"uses cache"| node_ej_config
node_ej_api -.->|"handled by"| node_ej_error
node_ej_service -.->|"raises"| node_ej_error
node_fact_app -->|"protects"| node_fact_sec
node_fact_app -->|"serves"| node_fact_ctrl
node_fact_ctrl -->|"delegates"| node_fact_svc
node_fact_ctrl -->|"accepts/returns"| node_fact_dto
node_fact_svc -->|"maps with"| node_fact_mapper
node_fact_mapper -->|"transforms"| node_fact_dto
node_fact_svc -->|"persists via"| node_fact_repo
node_fact_repo -->|"stores"| node_fact_model
node_fact_svc -->|"operates on"| node_fact_model

click node_ej_app "https://github.com/jhoanatanchaparro/java/blob/main/EjercicioAutonomo/src/main/java/com/example/EjercicioAutonomo/EjercicioAutonomoApplication.java"
click node_ej_web "https://github.com/jhoanatanchaparro/java/tree/main/EjercicioAutonomo/src/main/java/com/example/EjercicioAutonomo/Controller/View"
click node_ej_api "https://github.com/jhoanatanchaparro/java/tree/main/EjercicioAutonomo/src/main/java/com/example/EjercicioAutonomo/Controller"
click node_ej_dto "https://github.com/jhoanatanchaparro/java/tree/main/EjercicioAutonomo/src/main/java/com/example/EjercicioAutonomo/Dto"
click node_ej_mapper "https://github.com/jhoanatanchaparro/java/tree/main/EjercicioAutonomo/src/main/java/com/example/EjercicioAutonomo/Mapper"
click node_ej_service "https://github.com/jhoanatanchaparro/java/tree/main/EjercicioAutonomo/src/main/java/com/example/EjercicioAutonomo/Service"
click node_ej_repo "https://github.com/jhoanatanchaparro/java/tree/main/EjercicioAutonomo/src/main/java/com/example/EjercicioAutonomo/Repository"
click node_ej_entity "https://github.com/jhoanatanchaparro/java/tree/main/EjercicioAutonomo/src/main/java/com/example/EjercicioAutonomo/Entity"
click node_ej_feign_ctrl "https://github.com/jhoanatanchaparro/java/blob/main/EjercicioAutonomo/src/main/java/com/example/EjercicioAutonomo/Controller/Feign/ClienteFeignController.java"
click node_ej_feign_svc "https://github.com/jhoanatanchaparro/java/blob/main/EjercicioAutonomo/src/main/java/com/example/EjercicioAutonomo/Service/Servicelmpl/ClienteFeignServiceImpl.java"
click node_ej_feign_client "https://github.com/jhoanatanchaparro/java/blob/main/EjercicioAutonomo/src/main/java/com/example/EjercicioAutonomo/Feign/ClienteFeignClient.java"
click node_ej_config "https://github.com/jhoanatanchaparro/java/tree/main/EjercicioAutonomo/src/main/java/com/example/EjercicioAutonomo/Config"
click node_ej_error "https://github.com/jhoanatanchaparro/java/tree/main/EjercicioAutonomo/src/main/java/com/example/EjercicioAutonomo/Exception"
click node_fact_app "https://github.com/jhoanatanchaparro/java/blob/main/facturacion-prod/src/main/java/com/icodeap/facturacion_prod/FacturacionProdApplication.java"
click node_fact_sec "https://github.com/jhoanatanchaparro/java/blob/main/facturacion-prod/src/main/java/com/icodeap/facturacion_prod/Configuration/Security.java"
click node_fact_ctrl "https://github.com/jhoanatanchaparro/java/tree/main/facturacion-prod/src/main/java/com/icodeap/facturacion_prod/Controller"
click node_fact_dto "https://github.com/jhoanatanchaparro/java/tree/main/facturacion-prod/src/main/java/com/icodeap/facturacion_prod/Dto"
click node_fact_svc "https://github.com/jhoanatanchaparro/java/tree/main/facturacion-prod/src/main/java/com/icodeap/facturacion_prod/Services"
click node_fact_repo "https://github.com/jhoanatanchaparro/java/tree/main/facturacion-prod/src/main/java/com/icodeap/facturacion_prod/Repository"
click node_fact_model "https://github.com/jhoanatanchaparro/java/tree/main/facturacion-prod/src/main/java/com/icodeap/facturacion_prod/Model"
click node_fact_mapper "https://github.com/jhoanatanchaparro/java/blob/main/facturacion-prod/src/main/java/com/icodeap/facturacion_prod/Configuration/ModelMapperConfig.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_ej_app,node_ej_web,node_ej_api,node_ej_dto,node_ej_mapper,node_ej_service,node_ej_repo,node_ej_entity,node_ej_feign_ctrl,node_ej_feign_svc,node_ej_feign_client,node_ej_config,node_ej_error toneBlue
class node_fact_app,node_fact_sec,node_fact_ctrl,node_fact_dto,node_fact_svc,node_fact_repo,node_fact_model,node_fact_mapper toneAmber
```

## Components

### EjercicioAutonomo

Standalone Spring Boot app with CRUD, views, DTO mapping, and Feign integration.

- [EjercicioAutonomo](https://github.com/jhoanatanchaparro/java/blob/main/EjercicioAutonomo/src/main/java/com/example/EjercicioAutonomo/EjercicioAutonomoApplication.java): Spring Boot app · Primary application entrypoint for the CRUD and integration service. · `EjercicioAutonomo/src/main/java/com/example/EjercicioAutonomo/EjercicioAutonomoApplication.java`
- [Web UI](https://github.com/jhoanatanchaparro/java/tree/main/EjercicioAutonomo/src/main/java/com/example/EjercicioAutonomo/Controller/View): MVC views · HTML page controllers backed by templates for browser-based CRUD flows. · `EjercicioAutonomo/src/main/java/com/example/EjercicioAutonomo/Controller/View`
- [REST API](https://github.com/jhoanatanchaparro/java/tree/main/EjercicioAutonomo/src/main/java/com/example/EjercicioAutonomo/Controller): controllers · JSON-style controllers for the core domain entities. · `EjercicioAutonomo/src/main/java/com/example/EjercicioAutonomo/Controller`
- [DTOs](https://github.com/jhoanatanchaparro/java/tree/main/EjercicioAutonomo/src/main/java/com/example/EjercicioAutonomo/Dto): request/response · Transport objects that isolate the web layer from persistence entities. · `EjercicioAutonomo/src/main/java/com/example/EjercicioAutonomo/Dto`
- [Mappers](https://github.com/jhoanatanchaparro/java/tree/main/EjercicioAutonomo/src/main/java/com/example/EjercicioAutonomo/Mapper): mapping · Converters between entities and DTOs for the domain aggregates. · `EjercicioAutonomo/src/main/java/com/example/EjercicioAutonomo/Mapper`
- [Domain Services](https://github.com/jhoanatanchaparro/java/tree/main/EjercicioAutonomo/src/main/java/com/example/EjercicioAutonomo/Service): application services · Business logic for categories, products, clients, providers, and orders. · `EjercicioAutonomo/src/main/java/com/example/EjercicioAutonomo/Service`
- [Repositories](https://github.com/jhoanatanchaparro/java/tree/main/EjercicioAutonomo/src/main/java/com/example/EjercicioAutonomo/Repository): JPA repositories · Persistence boundary for all local aggregates. · `EjercicioAutonomo/src/main/java/com/example/EjercicioAutonomo/Repository`
- [Entities](https://github.com/jhoanatanchaparro/java/tree/main/EjercicioAutonomo/src/main/java/com/example/EjercicioAutonomo/Entity): JPA entities · Relational domain model for category, product, client, provider, and orders. · `EjercicioAutonomo/src/main/java/com/example/EjercicioAutonomo/Entity`
- [Feign API](https://github.com/jhoanatanchaparro/java/blob/main/EjercicioAutonomo/src/main/java/com/example/EjercicioAutonomo/Controller/Feign/ClienteFeignController.java): outbound controller · Entry point for the customer integration flow. · `EjercicioAutonomo/src/main/java/com/example/EjercicioAutonomo/Controller/Feign/ClienteFeignController.java`
- [Feign Service](https://github.com/jhoanatanchaparro/java/blob/main/EjercicioAutonomo/src/main/java/com/example/EjercicioAutonomo/Service/Servicelmpl/ClienteFeignServiceImpl.java): integration service · Coordinates remote customer lookups and related processing. · `EjercicioAutonomo/src/main/java/com/example/EjercicioAutonomo/Service/Servicelmpl/ClienteFeignServiceImpl.java`
- [Feign Client](https://github.com/jhoanatanchaparro/java/blob/main/EjercicioAutonomo/src/main/java/com/example/EjercicioAutonomo/Feign/ClienteFeignClient.java): HTTP client · Typed outbound client used to call the external customer service. · `EjercicioAutonomo/src/main/java/com/example/EjercicioAutonomo/Feign/ClienteFeignClient.java`
- [Config](https://github.com/jhoanatanchaparro/java/tree/main/EjercicioAutonomo/src/main/java/com/example/EjercicioAutonomo/Config): cache/feign config · Cross-cutting configuration for cache and Feign integration. · `EjercicioAutonomo/src/main/java/com/example/EjercicioAutonomo/Config`
- [Errors](https://github.com/jhoanatanchaparro/java/tree/main/EjercicioAutonomo/src/main/java/com/example/EjercicioAutonomo/Exception): exception handling · Global exception translation and not-found handling for HTTP responses. · `EjercicioAutonomo/src/main/java/com/example/EjercicioAutonomo/Exception`

### facturacion-prod

Standalone Spring Boot service for invoicing, products, DTO mapping, and security.

- [facturacion-prod](https://github.com/jhoanatanchaparro/java/blob/main/facturacion-prod/src/main/java/com/icodeap/facturacion_prod/FacturacionProdApplication.java): Spring Boot app · Primary application entrypoint for the invoicing service. · `facturacion-prod/src/main/java/com/icodeap/facturacion_prod/FacturacionProdApplication.java`
- [Security](https://github.com/jhoanatanchaparro/java/blob/main/facturacion-prod/src/main/java/com/icodeap/facturacion_prod/Configuration/Security.java): filter/config · Security boundary protecting the invoice and product endpoints. · `facturacion-prod/src/main/java/com/icodeap/facturacion_prod/Configuration/Security.java`
- [Controllers](https://github.com/jhoanatanchaparro/java/tree/main/facturacion-prod/src/main/java/com/icodeap/facturacion_prod/Controller): REST controllers · REST entry points for invoices and products. · `facturacion-prod/src/main/java/com/icodeap/facturacion_prod/Controller`
- [DTOs](https://github.com/jhoanatanchaparro/java/tree/main/facturacion-prod/src/main/java/com/icodeap/facturacion_prod/Dto): request/response · Request and response payloads for invoices, details, and products. · `facturacion-prod/src/main/java/com/icodeap/facturacion_prod/Dto`
- [Services](https://github.com/jhoanatanchaparro/java/tree/main/facturacion-prod/src/main/java/com/icodeap/facturacion_prod/Services): business services · Invoice orchestration and product lookup logic. · `facturacion-prod/src/main/java/com/icodeap/facturacion_prod/Services`
- [Repositories](https://github.com/jhoanatanchaparro/java/tree/main/facturacion-prod/src/main/java/com/icodeap/facturacion_prod/Repository): JPA repositories · Persistence boundary for factura, detail, and product storage. · `facturacion-prod/src/main/java/com/icodeap/facturacion_prod/Repository`
- [Models](https://github.com/jhoanatanchaparro/java/tree/main/facturacion-prod/src/main/java/com/icodeap/facturacion_prod/Model): JPA models · Invoice domain model including factura and detalle entities. · `facturacion-prod/src/main/java/com/icodeap/facturacion_prod/Model`
- [ModelMapper](https://github.com/jhoanatanchaparro/java/blob/main/facturacion-prod/src/main/java/com/icodeap/facturacion_prod/Configuration/ModelMapperConfig.java): mapping config · Automatic DTO-to-model mapping configuration. · `facturacion-prod/src/main/java/com/icodeap/facturacion_prod/Configuration/ModelMapperConfig.java`

## Connections

- EjercicioAutonomo → Web UI: serves · Bootstraps the browser-facing MVC entry path.
- EjercicioAutonomo → REST API: serves · Bootstraps the JSON API entry path.
- Web UI → Domain Services: uses · View controllers delegate to domain services.
- REST API → Domain Services: uses · REST controllers delegate to domain services.
- Domain Services → Mappers: maps · Services convert between DTOs and entities.
- Mappers → DTOs: transforms · Mapping boundary around request and response payloads.
- Mappers → Entities: transforms · Mapping boundary around persistence entities.
- Domain Services → Repositories: persists via · Services coordinate repository access for aggregates.
- Repositories → Entities: stores · Repositories directly manage entity persistence.
- Feign API → Feign Service: delegates · Feign controller forwards integration requests to service logic.
- Feign Service → Feign Client: calls · Service uses the outbound Feign client for HTTP calls.
- Feign Client → Config: configured by · Feign behavior is shaped by shared configuration.
- Domain Services → Config: uses cache · Domain services may be affected by cache configuration.
- REST API → Errors: handled by · Controller exceptions are translated centrally.
- Domain Services → Errors: raises · Service-layer not-found errors flow into global handling.
- facturacion-prod → Security: protects · Security filters guard the service endpoints.
- facturacion-prod → Controllers: serves · Bootstraps the REST controllers.
- Controllers → Services: delegates · Controllers pass request handling to business services.
- Controllers → DTOs: accepts/returns · Controllers exchange request and response DTOs.
- Services → ModelMapper: maps with · Services rely on ModelMapper configuration.
- ModelMapper → DTOs: transforms · Mapping layer converts request and response payloads.
- Services → Repositories: persists via · Business services coordinate repository access.
- Repositories → Models: stores · Repositories directly manage invoice domain models.
- Services → Models: operates on · Services orchestrate factura and detalle models.
