# todocodeacademy/pruebatecnicasupermercado architecture

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

- Interactive diagram: https://gitdiagram.com/todocodeacademy/pruebatecnicasupermercado
- Repository: https://github.com/todocodeacademy/pruebatecnicasupermercado

## Overview

1. **Overall shape**
   - This is a **single Spring Boot backend application** for a supermarket domain.
   - It follows a classic layered architecture: **HTTP API → service layer → persistence layer → domain model**, with DTOs used at the API boundary.

2. **Main functional bounded contexts**
   - The domain is split around three core business areas:
     - **Productos**: catalog and product management.
     - **Sucursales**: store/branch management.
     - **Ventas**: sales transactions, including sale details.
   - These are reflected consistently in controllers, services, repositories, models, and DTOs.

3. **API layer**
   - The `controller` package contains three REST controllers:
     - `ProductoController`
     - `SucursalController`
     - `VentaController`
   - These are the entry points for client requests and are the main external interface for the system.
   - The included Postman collection in `#otros archivos` suggests the repository is intended to be exercised as a REST API.

4. **Service layer**
   - The `service` package contains both interfaces and implementations:
     - `IProductoService` / `ProductoService`
     - `ISucursalService` / `SucursalService`
     - `IVentaService` / `VentaService`
   - This layer holds the business rules and orchestrates operations across repositories and mappers.
   - Controllers should not access persistence directly; they depend on these services instead.

5. **Persistence layer**
   - The `repository` package contains:
     - `ProductoRepository`
     - `SucursalRepository`
     - `VentaRepository`
   - These are the persistence abstractions, likely Spring Data repositories backed by a database configured through `application.properties`.
   - This layer is the boundary to storage and is isolated from HTTP concerns.

6. **Domain model**
   - The `model` package defines the persistent business objects:
     - `Producto`
     - `Sucursal`
     - `Venta`
     - `DetalleVenta`
   - `Venta` and `DetalleVenta` indicate that a sale is composed of one or more line items, so the sales flow is more than a flat CRUD resource.
   - The model layer represents the internal state used by the service and repository layers.

7. **DTO boundary**
   - The `dto` package defines transport objects:
     - `ProductoDTO`
     - `SucursalDTO`
     - `VentaDTO`
     - `DetalleVentaDTO`
   - These DTOs separate the API contract from the persistence model, which helps control what data is exposed and accepted over the wire.
   - In an architecture diagram, this is an important anti-corruption boundary between clients and the internal model.

8. **Mapping and transformation**
   - The `mapper` package contains a `Mapper` utility/class.
   - This is the translation boundary between DTOs and domain entities.
   - It prevents controllers and services from duplicating object conversion logic and keeps API shapes decoupled from entity shapes.

9. **Error handling**
   - The `exception` package contains `NotFoundException`.
   - This indicates the app has explicit handling for missing resources, likely used when a requested product, branch, or sale does not exist.
   - Architecturally, this is part of the service/API contract for error responses.

10. **Runtime and deployment**
   - The presence of `Dockerfile`, `docker-compose.yml`, and Maven wrapper files (`mvnw`, `.mvn`) indicates the app is designed to be **buildable and runnable in a containerized local environment** as well as via Maven.
   - `application.properties` centralizes runtime configuration, likely including server and datasource settings.

11. **Application bootstrap and tests**
   - `PruebaTecSupermercadoApplication.java` is the Spring Boot entry point.
   - The test folder contains a basic application test class, suggesting repository-level automated testing exists but is minimal from the tree alone.

12. **Suggested architecture diagram boundaries**
   - Draw the system as one backend service with these layers:
     - **Clients** → **REST controllers** → **service interfaces/implementations** → **repositories** → **database**
     - Side boundaries for **DTOs/mapping** and **exceptions**
   - Treat `Producto`, `Sucursal`, `Venta`, and `DetalleVenta` as the core domain objects flowing through the service and persistence layers.

Main entry points: [`PruebaTecSupermercado/src/main/java/com/todocodeacademy/PruebaTecSupermercado/controller/VentaController.java`](https://github.com/todocodeacademy/pruebatecnicasupermercado/blob/master/PruebaTecSupermercado/src/main/java/com/todocodeacademy/PruebaTecSupermercado/controller/VentaController.java) (Venta API), [`PruebaTecSupermercado/src/main/java/com/todocodeacademy/PruebaTecSupermercado/service/ProductoService.java`](https://github.com/todocodeacademy/pruebatecnicasupermercado/blob/master/PruebaTecSupermercado/src/main/java/com/todocodeacademy/PruebaTecSupermercado/service/ProductoService.java) (Producto Service), [`PruebaTecSupermercado/src/main/java/com/todocodeacademy/PruebaTecSupermercado/service/SucursalService.java`](https://github.com/todocodeacademy/pruebatecnicasupermercado/blob/master/PruebaTecSupermercado/src/main/java/com/todocodeacademy/PruebaTecSupermercado/service/SucursalService.java) (Sucursal Service), [`PruebaTecSupermercado/src/main/java/com/todocodeacademy/PruebaTecSupermercado/service/VentaService.java`](https://github.com/todocodeacademy/pruebatecnicasupermercado/blob/master/PruebaTecSupermercado/src/main/java/com/todocodeacademy/PruebaTecSupermercado/service/VentaService.java) (Venta Service)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_external["External"]
  node_postman["Postman Collection<br/>rest client"]
end

subgraph group_api["API Layer"]
  node_producto_controller["Producto API<br/>controller"]
  node_sucursal_controller["Sucursal API<br/>controller"]
  node_venta_controller["Venta API<br/>controller"]
  node_producto_dto["Producto DTO<br/>[ProductoDTO.java]"]
  node_sucursal_dto["Sucursal DTO<br/>[SucursalDTO.java]"]
  node_venta_dto["Venta DTO<br/>[VentaDTO.java]"]
  node_detalleventa_dto["Detalle DTO"]
end

subgraph group_service["Service Layer"]
  node_producto_service["Producto Service"]
  node_sucursal_service["Sucursal Service"]
  node_venta_service["Venta Service<br/>[VentaService.java]"]
end

subgraph group_persistence["Persistence Layer"]
  node_producto_repo[("Producto Repo")]
  node_sucursal_repo[("Sucursal Repo")]
  node_venta_repo[("Venta Repo")]
end

subgraph group_core["Core Domain"]
  node_producto_model["Producto<br/>entity<br/>[Producto.java]"]
  node_sucursal_model["Sucursal<br/>entity<br/>[Sucursal.java]"]
  node_venta_model["Venta<br/>entity<br/>[Venta.java]"]
  node_detalle_model["DetalleVenta<br/>entity<br/>[DetalleVenta.java]"]
  node_mapper{{"Mapper<br/>translator<br/>[Mapper.java]"}}
  node_not_found(("Not Found<br/>exception"))
end

subgraph group_runtime["Runtime"]
  node_app(("Spring Boot App<br/>bootstrap"))
end

node_postman -->|"calls"| node_producto_controller
node_postman -->|"calls"| node_sucursal_controller
node_postman -->|"calls"| node_venta_controller
node_producto_controller -->|"uses"| node_producto_dto
node_sucursal_controller -->|"uses"| node_sucursal_dto
node_venta_controller -->|"uses"| node_venta_dto
node_venta_controller -->|"uses"| node_detalleventa_dto
node_producto_controller -->|"delegates"| node_producto_service
node_sucursal_controller -->|"delegates"| node_sucursal_service
node_venta_controller -->|"delegates"| node_venta_service
node_producto_service -->|"maps"| node_mapper
node_sucursal_service -->|"maps"| node_mapper
node_venta_service -->|"maps"| node_mapper
node_producto_service -->|"persists"| node_producto_repo
node_sucursal_service -->|"persists"| node_sucursal_repo
node_venta_service -->|"persists"| node_venta_repo
node_producto_repo -->|"stores"| node_producto_model
node_sucursal_repo -->|"stores"| node_sucursal_model
node_venta_repo -->|"stores"| node_venta_model
node_venta_model -->|"contains"| node_detalle_model
node_producto_service -.->|"raises"| node_not_found
node_sucursal_service -.->|"raises"| node_not_found
node_venta_service -.->|"raises"| node_not_found
node_app -->|"starts"| node_producto_controller
node_app -->|"starts"| node_sucursal_controller
node_app -->|"starts"| node_venta_controller

click node_postman "https://github.com/todocodeacademy/pruebatecnicasupermercado/blob/master/PruebaTecSupermercado/#otros archivos/PruebaTécnicaSupermercado.postman_collection.json"
click node_producto_controller "https://github.com/todocodeacademy/pruebatecnicasupermercado/blob/master/PruebaTecSupermercado/src/main/java/com/todocodeacademy/PruebaTecSupermercado/controller/ProductoController.java"
click node_sucursal_controller "https://github.com/todocodeacademy/pruebatecnicasupermercado/blob/master/PruebaTecSupermercado/src/main/java/com/todocodeacademy/PruebaTecSupermercado/controller/SucursalController.java"
click node_venta_controller "https://github.com/todocodeacademy/pruebatecnicasupermercado/blob/master/PruebaTecSupermercado/src/main/java/com/todocodeacademy/PruebaTecSupermercado/controller/VentaController.java"
click node_producto_dto "https://github.com/todocodeacademy/pruebatecnicasupermercado/blob/master/PruebaTecSupermercado/src/main/java/com/todocodeacademy/PruebaTecSupermercado/dto/ProductoDTO.java"
click node_sucursal_dto "https://github.com/todocodeacademy/pruebatecnicasupermercado/blob/master/PruebaTecSupermercado/src/main/java/com/todocodeacademy/PruebaTecSupermercado/dto/SucursalDTO.java"
click node_venta_dto "https://github.com/todocodeacademy/pruebatecnicasupermercado/blob/master/PruebaTecSupermercado/src/main/java/com/todocodeacademy/PruebaTecSupermercado/dto/VentaDTO.java"
click node_detalleventa_dto "https://github.com/todocodeacademy/pruebatecnicasupermercado/blob/master/PruebaTecSupermercado/src/main/java/com/todocodeacademy/PruebaTecSupermercado/dto/DetalleVentaDTO.java"
click node_producto_service "https://github.com/todocodeacademy/pruebatecnicasupermercado/blob/master/PruebaTecSupermercado/src/main/java/com/todocodeacademy/PruebaTecSupermercado/service/ProductoService.java"
click node_sucursal_service "https://github.com/todocodeacademy/pruebatecnicasupermercado/blob/master/PruebaTecSupermercado/src/main/java/com/todocodeacademy/PruebaTecSupermercado/service/SucursalService.java"
click node_venta_service "https://github.com/todocodeacademy/pruebatecnicasupermercado/blob/master/PruebaTecSupermercado/src/main/java/com/todocodeacademy/PruebaTecSupermercado/service/VentaService.java"
click node_producto_repo "https://github.com/todocodeacademy/pruebatecnicasupermercado/blob/master/PruebaTecSupermercado/src/main/java/com/todocodeacademy/PruebaTecSupermercado/repository/ProductoRepository.java"
click node_sucursal_repo "https://github.com/todocodeacademy/pruebatecnicasupermercado/blob/master/PruebaTecSupermercado/src/main/java/com/todocodeacademy/PruebaTecSupermercado/repository/SucursalRepository.java"
click node_venta_repo "https://github.com/todocodeacademy/pruebatecnicasupermercado/blob/master/PruebaTecSupermercado/src/main/java/com/todocodeacademy/PruebaTecSupermercado/repository/VentaRepository.java"
click node_producto_model "https://github.com/todocodeacademy/pruebatecnicasupermercado/blob/master/PruebaTecSupermercado/src/main/java/com/todocodeacademy/PruebaTecSupermercado/model/Producto.java"
click node_sucursal_model "https://github.com/todocodeacademy/pruebatecnicasupermercado/blob/master/PruebaTecSupermercado/src/main/java/com/todocodeacademy/PruebaTecSupermercado/model/Sucursal.java"
click node_venta_model "https://github.com/todocodeacademy/pruebatecnicasupermercado/blob/master/PruebaTecSupermercado/src/main/java/com/todocodeacademy/PruebaTecSupermercado/model/Venta.java"
click node_detalle_model "https://github.com/todocodeacademy/pruebatecnicasupermercado/blob/master/PruebaTecSupermercado/src/main/java/com/todocodeacademy/PruebaTecSupermercado/model/DetalleVenta.java"
click node_mapper "https://github.com/todocodeacademy/pruebatecnicasupermercado/blob/master/PruebaTecSupermercado/src/main/java/com/todocodeacademy/PruebaTecSupermercado/mapper/Mapper.java"
click node_not_found "https://github.com/todocodeacademy/pruebatecnicasupermercado/blob/master/PruebaTecSupermercado/src/main/java/com/todocodeacademy/PruebaTecSupermercado/exception/NotFoundException.java"
click node_app "https://github.com/todocodeacademy/pruebatecnicasupermercado/blob/master/PruebaTecSupermercado/src/main/java/com/todocodeacademy/PruebaTecSupermercado/PruebaTecSupermercadoApplication.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_postman toneBlue
class node_producto_controller,node_sucursal_controller,node_venta_controller,node_producto_dto,node_sucursal_dto,node_venta_dto,node_detalleventa_dto toneAmber
class node_producto_service,node_sucursal_service,node_venta_service toneMint
class node_producto_repo,node_sucursal_repo,node_venta_repo toneRose
class node_producto_model,node_sucursal_model,node_venta_model,node_detalle_model,node_mapper,node_not_found toneIndigo
class node_app toneTeal
```

## Components

### External

API clients and test tooling

- [Postman Collection](https://github.com/todocodeacademy/pruebatecnicasupermercado/blob/HEAD/PruebaTecSupermercado/%23otros%20archivos/PruebaT%C3%A9cnicaSupermercado.postman_collection.json): rest client · Sample API client collection for exercising the backend · `PruebaTecSupermercado/#otros archivos/PruebaTécnicaSupermercado.postman_collection.json`

### API Layer

HTTP controllers and transport DTOs

- [Producto API](https://github.com/todocodeacademy/pruebatecnicasupermercado/blob/master/PruebaTecSupermercado/src/main/java/com/todocodeacademy/PruebaTecSupermercado/controller/ProductoController.java): controller · REST entry point for product operations · `PruebaTecSupermercado/src/main/java/com/todocodeacademy/PruebaTecSupermercado/controller/ProductoController.java`
- [Sucursal API](https://github.com/todocodeacademy/pruebatecnicasupermercado/blob/master/PruebaTecSupermercado/src/main/java/com/todocodeacademy/PruebaTecSupermercado/controller/SucursalController.java): controller · REST entry point for branch operations · `PruebaTecSupermercado/src/main/java/com/todocodeacademy/PruebaTecSupermercado/controller/SucursalController.java`
- [Venta API](https://github.com/todocodeacademy/pruebatecnicasupermercado/blob/master/PruebaTecSupermercado/src/main/java/com/todocodeacademy/PruebaTecSupermercado/controller/VentaController.java): controller · REST entry point for sales operations · `PruebaTecSupermercado/src/main/java/com/todocodeacademy/PruebaTecSupermercado/controller/VentaController.java`
- [Producto DTO](https://github.com/todocodeacademy/pruebatecnicasupermercado/blob/master/PruebaTecSupermercado/src/main/java/com/todocodeacademy/PruebaTecSupermercado/dto/ProductoDTO.java): dto · Transport model for product requests and responses · `PruebaTecSupermercado/src/main/java/com/todocodeacademy/PruebaTecSupermercado/dto/ProductoDTO.java`
- [Sucursal DTO](https://github.com/todocodeacademy/pruebatecnicasupermercado/blob/master/PruebaTecSupermercado/src/main/java/com/todocodeacademy/PruebaTecSupermercado/dto/SucursalDTO.java): dto · Transport model for branch requests and responses · `PruebaTecSupermercado/src/main/java/com/todocodeacademy/PruebaTecSupermercado/dto/SucursalDTO.java`
- [Venta DTO](https://github.com/todocodeacademy/pruebatecnicasupermercado/blob/master/PruebaTecSupermercado/src/main/java/com/todocodeacademy/PruebaTecSupermercado/dto/VentaDTO.java): dto · Transport model for sales requests and responses · `PruebaTecSupermercado/src/main/java/com/todocodeacademy/PruebaTecSupermercado/dto/VentaDTO.java`
- [Detalle DTO](https://github.com/todocodeacademy/pruebatecnicasupermercado/blob/master/PruebaTecSupermercado/src/main/java/com/todocodeacademy/PruebaTecSupermercado/dto/DetalleVentaDTO.java): dto · Transport model for sale line items · `PruebaTecSupermercado/src/main/java/com/todocodeacademy/PruebaTecSupermercado/dto/DetalleVentaDTO.java`

### Service Layer

Business services and orchestration

- [Producto Service](https://github.com/todocodeacademy/pruebatecnicasupermercado/blob/master/PruebaTecSupermercado/src/main/java/com/todocodeacademy/PruebaTecSupermercado/service/ProductoService.java): service · Product business operations and orchestration · `PruebaTecSupermercado/src/main/java/com/todocodeacademy/PruebaTecSupermercado/service/ProductoService.java`
- [Sucursal Service](https://github.com/todocodeacademy/pruebatecnicasupermercado/blob/master/PruebaTecSupermercado/src/main/java/com/todocodeacademy/PruebaTecSupermercado/service/SucursalService.java): service · Branch business operations and orchestration · `PruebaTecSupermercado/src/main/java/com/todocodeacademy/PruebaTecSupermercado/service/SucursalService.java`
- [Venta Service](https://github.com/todocodeacademy/pruebatecnicasupermercado/blob/master/PruebaTecSupermercado/src/main/java/com/todocodeacademy/PruebaTecSupermercado/service/VentaService.java): service · Sales workflow and transaction orchestration · `PruebaTecSupermercado/src/main/java/com/todocodeacademy/PruebaTecSupermercado/service/VentaService.java`

### Persistence Layer

Repositories and stored domain objects

- [Producto Repo](https://github.com/todocodeacademy/pruebatecnicasupermercado/blob/master/PruebaTecSupermercado/src/main/java/com/todocodeacademy/PruebaTecSupermercado/repository/ProductoRepository.java): repository · Persistence access for products · `PruebaTecSupermercado/src/main/java/com/todocodeacademy/PruebaTecSupermercado/repository/ProductoRepository.java`
- [Sucursal Repo](https://github.com/todocodeacademy/pruebatecnicasupermercado/blob/master/PruebaTecSupermercado/src/main/java/com/todocodeacademy/PruebaTecSupermercado/repository/SucursalRepository.java): repository · Persistence access for branches · `PruebaTecSupermercado/src/main/java/com/todocodeacademy/PruebaTecSupermercado/repository/SucursalRepository.java`
- [Venta Repo](https://github.com/todocodeacademy/pruebatecnicasupermercado/blob/master/PruebaTecSupermercado/src/main/java/com/todocodeacademy/PruebaTecSupermercado/repository/VentaRepository.java): repository · Persistence access for sales · `PruebaTecSupermercado/src/main/java/com/todocodeacademy/PruebaTecSupermercado/repository/VentaRepository.java`

### Core Domain

Shared domain model, mapping, and errors

- [Producto](https://github.com/todocodeacademy/pruebatecnicasupermercado/blob/master/PruebaTecSupermercado/src/main/java/com/todocodeacademy/PruebaTecSupermercado/model/Producto.java): entity · Persistent product domain object · `PruebaTecSupermercado/src/main/java/com/todocodeacademy/PruebaTecSupermercado/model/Producto.java`
- [Sucursal](https://github.com/todocodeacademy/pruebatecnicasupermercado/blob/master/PruebaTecSupermercado/src/main/java/com/todocodeacademy/PruebaTecSupermercado/model/Sucursal.java): entity · Persistent branch domain object · `PruebaTecSupermercado/src/main/java/com/todocodeacademy/PruebaTecSupermercado/model/Sucursal.java`
- [Venta](https://github.com/todocodeacademy/pruebatecnicasupermercado/blob/master/PruebaTecSupermercado/src/main/java/com/todocodeacademy/PruebaTecSupermercado/model/Venta.java): entity · Sale aggregate root · `PruebaTecSupermercado/src/main/java/com/todocodeacademy/PruebaTecSupermercado/model/Venta.java`
- [DetalleVenta](https://github.com/todocodeacademy/pruebatecnicasupermercado/blob/master/PruebaTecSupermercado/src/main/java/com/todocodeacademy/PruebaTecSupermercado/model/DetalleVenta.java): entity · Sale line-item entity · `PruebaTecSupermercado/src/main/java/com/todocodeacademy/PruebaTecSupermercado/model/DetalleVenta.java`
- [Mapper](https://github.com/todocodeacademy/pruebatecnicasupermercado/blob/master/PruebaTecSupermercado/src/main/java/com/todocodeacademy/PruebaTecSupermercado/mapper/Mapper.java): translator · DTO-to-entity and entity-to-DTO transformation boundary · `PruebaTecSupermercado/src/main/java/com/todocodeacademy/PruebaTecSupermercado/mapper/Mapper.java`
- [Not Found](https://github.com/todocodeacademy/pruebatecnicasupermercado/blob/master/PruebaTecSupermercado/src/main/java/com/todocodeacademy/PruebaTecSupermercado/exception/NotFoundException.java): exception · Explicit missing-resource error handling · `PruebaTecSupermercado/src/main/java/com/todocodeacademy/PruebaTecSupermercado/exception/NotFoundException.java`

### Runtime

Application bootstrap and packaging

- [Spring Boot App](https://github.com/todocodeacademy/pruebatecnicasupermercado/blob/master/PruebaTecSupermercado/src/main/java/com/todocodeacademy/PruebaTecSupermercado/PruebaTecSupermercadoApplication.java): bootstrap · Application entry point · `PruebaTecSupermercado/src/main/java/com/todocodeacademy/PruebaTecSupermercado/PruebaTecSupermercadoApplication.java`

## Connections

- Postman Collection → Producto API: calls · Exercises the REST API
- Postman Collection → Sucursal API: calls · Exercises the REST API
- Postman Collection → Venta API: calls · Exercises the REST API
- Producto API → Producto DTO: uses · Reads and writes product payloads
- Sucursal API → Sucursal DTO: uses · Reads and writes branch payloads
- Venta API → Venta DTO: uses · Reads and writes sale payloads
- Venta API → Detalle DTO: uses · Handles sale line items
- Producto API → Producto Service: delegates · Routes product requests into business logic
- Sucursal API → Sucursal Service: delegates · Routes branch requests into business logic
- Venta API → Venta Service: delegates · Routes sales requests into business logic
- Producto Service → Mapper: maps · Converts between DTOs and entities
- Sucursal Service → Mapper: maps · Converts between DTOs and entities
- Venta Service → Mapper: maps · Converts between DTOs and entities
- Producto Service → Producto Repo: persists · Product storage access
- Sucursal Service → Sucursal Repo: persists · Branch storage access
- Venta Service → Venta Repo: persists · Sales storage access
- Producto Repo → Producto: stores · Persists product entities
- Sucursal Repo → Sucursal: stores · Persists branch entities
- Venta Repo → Venta: stores · Persists sale entities
- Venta → DetalleVenta: contains · Sale is composed of line items
- Producto Service → Not Found: raises · Signals missing product resources
- Sucursal Service → Not Found: raises · Signals missing branch resources
- Venta Service → Not Found: raises · Signals missing sale resources
- Spring Boot App → Producto API: starts · Bootstraps controller layer
- Spring Boot App → Sucursal API: starts · Bootstraps controller layer
- Spring Boot App → Venta API: starts · Bootstraps controller layer
