How joaomiz/pedido_cliente_produto_desafio works
This repository is a small layered Spring Boot application organized around three business domains: Cliente, Produto, and Pedido.
Architecture style
• It follows a classic three-tier / layered structure:
- Presentation layer: controller classes
- Business layer: service classes
- Persistence layer: repository interfaces
- Domain layer: model classes
• The application entry point is DesafioApplication.java, which boots the Spring container and wires the layers together through dependency injection.
Main subsystems
1. Presentation / API layer
• ClienteController
• ProdutoController
• PedidoController
These classes are the external entry points for the application. They expose the domain operations for each entity and receive incoming requests, then delegate to the corresponding service.
• Each controller maps to one business area.
• This layer should be the only one directly exposed to clients.
• It does not appear to contain business logic itself; its role is orchestration and request/response handling.
2. Business / application logic layer
• ClienteService
• ProdutoService
• PedidoService
These services sit between controllers and repositories.
• They encapsulate domain rules, validation, and workflow orchestration.
• They coordinate reads and writes across repositories.
• PedidoService is likely the most important cross-domain service because orders usually depend on both client and product data.
3. Persistence layer
• ClienteRepository
• ProdutoRepository
• PedidoRepository
These repositories provide data access for the domain entities.
• In a Spring Boot project like this, they are typically Spring Data repositories.
• They abstract the database interaction away from services.
• The service layer depends on these interfaces, not on storage details.
4. Domain / model layer
• Cliente
• Produto
• Pedido
These classes represent the core business entities.
• They are likely mapped to database tables and used in request/response payloads or persistence operations.
• Pedido likely represents a relationship between a client and one or more products, although the exact cardinality is not visible from the file tree alone.
Data flow
A typical request flows through the application like this:
• A client calls one of the controllers.
• The controller delegates to the corresponding service.
• The service applies business rules and uses one or more repositories.
• The repository reads from or writes to the persistence store.
• The result flows back up through service to controller and then to the caller.
For Pedido, the flow may involve more than one repository:
• PedidoService may need to validate a Cliente
• it may also need to retrieve Produto data before persisting the order
• this makes the order subsystem a coordination point across the other two domains
Important boundaries
• Controllers are the boundary between external callers and internal application logic.
• Services are the boundary between request handling and persistence.
• Repositories are the boundary between application code and the database.
• Models are shared internal domain objects, but they should remain separate from transport concerns where possible.
Project/runtime characteristics
• The project is a Java application built with Maven.
• It uses the Maven wrapper (mvnw, .mvn/) so the build can run without a preinstalled Maven version.
• application.properties indicates runtime configuration is externalized, most likely for Spring Boot settings such as server and database configuration.
• src/test/java/.../DesafioApplicationTests.java shows that the project includes at least a basic Spring Boot test harness.
What an architecture diagram should show
• One application boundary labeled as the Spring Boot service.
• Inside it, three vertical layers:
- Controllers at the top
- Services in the middle
- Repositories at the bottom
• Shared domain models alongside the service/repository layers.
• Three main business areas:
- Cliente
- Produto
- Pedido
• Arrows from each controller to its service, from each service to its repository, and from repositories to the underlying database.
• A special note that Pedido likely coordinates Cliente and Produto data, making it the main integration flow among the domains.
In short, this is a conventional Spring Boot CRUD-style backend with clear separation of concerns and a domain split around clients, products, and orders.
Main entry points: DesafioApplication.java DesafioApplication · PedidoService.java PedidoService · ClienteService.java ClienteService · ProdutoService.java ProdutoService
Components 14
Spring Boot Service
Application boundary and startup wiring
- DesafioApplication · Spring Boot entry point and container startup
src/main/java/xped/desafio/DesafioApplication.java
Presentation
External API controllers
- ClienteController · Cliente API entry point
src/main/java/xped/desafio/controller/ClienteController.java - ProdutoController · Produto API entry point
src/main/java/xped/desafio/controller/ProdutoController.java - PedidoController · Pedido API entry point
src/main/java/xped/desafio/controller/PedidoController.java
Business
Application services and orchestration
- ClienteService · Cliente rules and workflow
src/main/java/xped/desafio/service/ClienteService.java - ProdutoService · Produto rules and workflow
src/main/java/xped/desafio/service/ProdutoService.java - PedidoService · Coordinates order logic across domains
src/main/java/xped/desafio/service/PedidoService.java
Persistence
Repositories and storage access
- ClienteRepository · Cliente persistence boundary
src/main/java/xped/desafio/repository/ClienteRepository.java - ProdutoRepository · Produto persistence boundary
src/main/java/xped/desafio/repository/ProdutoRepository.java - PedidoRepository · Pedido persistence boundary
src/main/java/xped/desafio/repository/PedidoRepository.java
Domain
Core business entities
Database
Underlying persistence store
- Database · External data store behind repositories
Connections 23
- DesafioApplication → ClienteController: wires · Bootstraps controller layer
- DesafioApplication → ProdutoController: wires · Bootstraps controller layer
- DesafioApplication → PedidoController: wires · Bootstraps controller layer
- DesafioApplication → ClienteService: wires · Bootstraps service layer
- DesafioApplication → ProdutoService: wires · Bootstraps service layer
- DesafioApplication → PedidoService: wires · Bootstraps service layer
- ClienteController → ClienteService: delegates · Request handling passes to business logic
- ProdutoController → ProdutoService: delegates · Request handling passes to business logic
- PedidoController → PedidoService: delegates · Request handling passes to business logic
- ClienteService → ClienteRepository: uses · Reads and writes cliente data
- ProdutoService → ProdutoRepository: uses · Reads and writes produto data
- PedidoService → PedidoRepository: uses · Persists pedidos
- PedidoService → ClienteRepository: validates cliente · Pedido coordination depends on cliente data
- PedidoService → ProdutoRepository: loads produto · Pedido coordination depends on produto data
- ClienteRepository → Database: stores · Persistence access to database
- ProdutoRepository → Database: stores · Persistence access to database
- PedidoRepository → Database: stores · Persistence access to database
- ClienteService → Cliente: operates on · Business logic around cliente entity
- ProdutoService → Produto: operates on · Business logic around produto entity
- PedidoService → Pedido: operates on · Business logic around pedido entity
- ClienteRepository → Cliente: maps · Persists cliente entity
- ProdutoRepository → Produto: maps · Persists produto entity
- PedidoRepository → Pedido: maps · Persists pedido entity