How brunoonofre64/desafio-prolog-app works
Project type and purpose
• This is a monolithic back-end REST API built with Java 17 and Spring Boot.
• It manages “Veiculo” (vehicles) and “Pneu” (tires), applying Clean Architecture principles: layers for presentation, application, domain, and infrastructure.
• It persists data in PostgreSQL (via Docker Compose) and uses H2 for integration tests.
File structure
• Top-level:
• src/main/java/com/prologapp/desafio/presentation/v1 → REST controllers and exception handlers
• src/main/java/com/prologapp/desafio/application → DTOs, validators, mappers, services interfaces & implementations
• src/main/java/com/prologapp/desafio/domain → business entities, enums, repository interfaces
• src/main/java/com/prologapp/desafio/insfraestructure → persistence (Spring Data JPA and custom repositories), configs, exception implementations
• Resources: Flyway (or Liquibase) migration scripts, application.properties.
• Tests: Unit tests under src/test; integration tests under src/integration-test using H2.
Key insights from README
• Clean Architecture splits responsibilities: controllers → services → repositories → database
• Performance optimizations: custom EntityManager queries, generic pagination DTO, DB indices
• Centralized exception messages and a global ApiExceptionHandler
• Docker Compose brings up PostgreSQL; Swagger UI for API exploration
Main components and their interactions
a. Presentation Layer (Controllers + Swagger UI)
• PneuController, VeiculoController receive HTTP requests → validate → call Application services
• ApiExceptionHandler catches and translates exceptions into error responses
b. Application Layer
• Service interfaces (IPneuService, IVeiculoService) and implementations handle business workflows
• DTOs (Request/Response), mappers convert between Domain entities and DTOs
• Custom annotations/validators enforce input constraints
c. Domain Layer
• Entities (PneuEntity, VeiculoEntity), enums, business-rule exceptions
• Repository interfaces define persistence contracts
d. Infrastructure Layer
• Spring Data JPA repositories and custom JpaPneuRepository using EntityManager
• Configuration classes (OpenApiConfig, MessageBundleConfig), Flyway/Liquibase migrations
• application.properties for DB connectivity
e. Database
• PostgreSQL (production), H2 (integration tests)
f. External
• Docker Compose orchestrates the PostgreSQL container
Architectural patterns and design principles
• Clean Architecture (layered): clear separation of concerns
• Dependency Inversion: services depend on repository interfaces, not implementations
• Single Responsibility: each package/class has a well-defined role
• Centralized exception handling and messaging for consistency