How unilopers/concessionaria works
1. Overall shape
This repository is a single Spring Boot mini-ERP for a concessionária, organized as a layered monolith: REST controllers at the edge, service classes for business rules, Spring Data JPA repositories for persistence, and JPA entities as the domain model.
2. API layer / entry points
The main HTTP surface is under com.grupo8.concessionaria.controller. It exposes resource-oriented endpoints for:
• clientes
• funcionários
• modelos
• veículos em estoque
• vendas and itens de venda
• ordens de serviço and itens de ordem de serviço
• movimentações financeiras
There is also a PublicController, which represents the unauthenticated/public part of the API.
3. Security boundary
Authentication is implemented with an API key, not session or OAuth. ApiKeyAuthInterceptor, ApiKeyConfig, and WebConfig form the request-filtering boundary: protected business routes require the x-api-key header, while /public/** and /h2-console/** remain open. Error handling for missing/invalid keys is standardized through ApiErrorResponse.
4. Business/service layer
Each domain area has a service class in model/service, such as ClienteService, VendaService, OrdemServicoService, and MovimentacaoFinanceiraService. These services are the main place where business rules and cross-entity coordination live, sitting between controllers and repositories.
5. Persistence layer
Persistence is handled by Spring Data JPA repositories in model/repository. Each major entity has its own repository, enabling CRUD-style database access with minimal boilerplate. The application uses an in-memory H2 database for development and local execution.
6. Domain model
The core entities are:
• Cliente
• Funcionario
• Modelo
• VeiculoEstoque
• Venda
• ItemVenda
• OrdemServico
• ItemOrdemServico
• Servico
• MovimentacaoFinanceira
There are also enums for status and classification, such as StatusVeiculo, StatusOS, TipoPagamento, TipoMovimentacao, and OrigemMovimentacao, which define the business state space.
7. Typical data flow
A request usually follows: controller receives JSON → service validates/coordinates → repository persists or fetches entities → response is returned to the client. For richer workflows like sales or service orders, the service layer is where multiple tables/entities are likely updated together, including line items and financial records.
8. Async subsystem
There is a small asynchronous branch under async, with AsyncConfig, ClienteAsyncService, and VendaAsyncService. This suggests some operations are intended to run off the request thread, likely for background processing or non-blocking domain work related to customer and sales flows.
9. Configuration and runtime
application.properties centralizes runtime settings, including the API key value and H2 configuration. The app is started from ConcessionariaApplication, and the project is built with Maven Wrapper, making the runtime stack Java + Spring Boot + Spring Data JPA + H2.
10. Testing and validation
The test suite includes ApiKeyIntegrationTest, which validates the security boundary: blocked access without/with wrong key and allowed access with the correct key, plus public-route access. There is also a load-tests/ClienteDavi.py script, indicating manual or scripted load testing for at least the client-related API.
11. Architecture summary for a diagram
If drawing this system, show one HTTP API boundary guarded by API-key middleware/interceptor, a service layer beneath it, JPA repositories connected to an H2 database, and a separate asynchronous execution path for selected operations. The main domain centers on dealership entities, sales, service orders, inventory, and finance.
Main entry points: ApiKeyAuthInterceptor.java API key check · WebConfig.java Web config · ClienteService.java Cliente svc · VendaService.java Venda svc
Components 25
Runtime
Application bootstrap and configuration
- App · Main application bootstrap.
src/main/java/com/grupo8/concessionaria/ConcessionariaApplication.java
API
HTTP entry points and request boundary
- Web config · Registers request interception and route handling rules.
src/main/java/com/grupo8/concessionaria/config/WebConfig.java - API key cfg · Defines API key security wiring and protected/public route boundaries.
src/main/java/com/grupo8/concessionaria/config/ApiKeyConfig.java - API key check · Validates x-api-key on protected routes.
src/main/java/com/grupo8/concessionaria/config/ApiKeyAuthInterceptor.java - API error · Standardized error response for auth failures and API errors.
src/main/java/com/grupo8/concessionaria/config/ApiErrorResponse.java - Public API · Unauthenticated API surface.
src/main/java/com/grupo8/concessionaria/controller/PublicController.java - Clientes · Customer endpoints.
src/main/java/com/grupo8/concessionaria/controller/ClienteController.java - Vendas · Sales endpoints.
src/main/java/com/grupo8/concessionaria/controller/VendaController.java - OS · Service order endpoints.
src/main/java/com/grupo8/concessionaria/controller/OrdemServicoController.java - Financeiro · Financial movement endpoints.
src/main/java/com/grupo8/concessionaria/controller/MovimentacaoFinanceiraController.java
Async
Background execution paths
- Async cfg · Enables asynchronous execution.
src/main/java/com/grupo8/concessionaria/async/AsyncConfig.java - Cliente async · Background customer-related processing.
src/main/java/com/grupo8/concessionaria/async/cliente/ClienteAsyncService.java - Venda async · Background sales-related processing.
src/main/java/com/grupo8/concessionaria/async/venda/VendaAsyncService.java
Service
Business rules and orchestration
- Cliente svc · Customer rules and coordination.
src/main/java/com/grupo8/concessionaria/model/service/ClienteService.java - Venda svc · Sales workflow orchestration.
src/main/java/com/grupo8/concessionaria/model/service/VendaService.java - OS svc · Service order workflow orchestration.
src/main/java/com/grupo8/concessionaria/model/service/OrdemServicoService.java - Finance svc · Financial movement rules and coordination.
src/main/java/com/grupo8/concessionaria/model/service/MovimentacaoFinanceiraService.java
Persistence
Spring Data repositories and database access
- Cliente repo · Persistence access for customers.
src/main/java/com/grupo8/concessionaria/model/repository/ClienteRepository.java - Venda repo · Persistence access for sales.
src/main/java/com/grupo8/concessionaria/model/repository/VendaRepository.java - OS repo · Persistence access for service orders.
src/main/java/com/grupo8/concessionaria/model/repository/OrdemServicoRepository.java - Finance repo · Persistence access for financial movements.
src/main/java/com/grupo8/concessionaria/model/repository/MovimentacaoFinanceiraRepository.java
Domain
Core entities and business state
- Cliente · Customer domain entity.
src/main/java/com/grupo8/concessionaria/model/entities/Cliente.java - Venda · Sale domain entity.
src/main/java/com/grupo8/concessionaria/model/entities/Venda.java - Ordem OS · Service order domain entity.
src/main/java/com/grupo8/concessionaria/model/entities/OrdemServico.java - Movimento · Financial movement domain entity.
src/main/java/com/grupo8/concessionaria/model/entities/MovimentacaoFinanceira.java
Connections 25
- App → Web config: starts with · Application bootstraps MVC and security configuration.
- Web config → API key cfg: uses · Web config wires the API-key security boundary.
- API key cfg → API key check: registers · Security config installs the request interceptor.
- API key check → API error: rejects with · Invalid or missing keys are normalized into API errors.
- Web config → Public API: opens · Public routes remain outside the API-key gate.
- API key check → Clientes: protects · Protected business endpoints require a valid key.
- API key check → Vendas: protects · Protected business endpoints require a valid key.
- API key check → OS: protects · Protected business endpoints require a valid key.
- API key check → Financeiro: protects · Protected business endpoints require a valid key.
- Clientes → Cliente svc: delegates · Controller hands off business logic to the service layer.
- Vendas → Venda svc: delegates · Controller hands off business logic to the service layer.
- OS → OS svc: delegates · Controller hands off business logic to the service layer.
- Financeiro → Finance svc: delegates · Controller hands off business logic to the service layer.
- Cliente svc → Cliente repo: persists via · Customer service reads and writes through JPA.
- Venda svc → Venda repo: persists via · Sales service reads and writes through JPA.
- OS svc → OS repo: persists via · Service order service reads and writes through JPA.
- Finance svc → Finance repo: persists via · Financial service reads and writes through JPA.
- Cliente repo → Cliente: maps · Repository manages customer entities.
- Venda repo → Venda: maps · Repository manages sale entities.
- OS repo → Ordem OS: maps · Repository manages service order entities.
- Finance repo → Movimento: maps · Repository manages financial movement entities.
- Cliente svc → Cliente async: can offload to · Customer flows may branch into async processing.
- Venda svc → Venda async: can offload to · Sales flows may branch into async processing.
- Async cfg → Cliente async: enables · Async configuration activates background customer work.
- Async cfg → Venda async: enables · Async configuration activates background sales work.