How sttadic/car-rental-cicd works
1. Overall shape
- This is a single Spring Boot REST microservice for a car-rental domain.
- It is organized as a classic layered application: HTTP controllers, service layer, persistence repositories, and domain entities, with DTOs and mappers separating API payloads from internal models.
2. Primary runtime boundary
- The executable entry point is CarRentalRestApiApplication.
- At runtime it exposes REST endpoints for two domain areas: Cars and Bookings.
3. HTTP/API layer
- CarController and BookingController are the external API boundary.
- They receive request DTOs such as CreateCarRequest and CreateBookingRequest, and return response DTOs such as CarDTO and BookingDTO.
- This layer is responsible for request validation and translating service outcomes into HTTP responses.
4. Application/service layer
- CarService / BookingService define the business operations.
- CarServiceImpl / BookingServiceImpl contain the actual orchestration logic.
- This is where the domain rules live, including booking-related checks and coordination between cars and bookings.
5. Persistence layer
- CarRepository and BookingRepository are the data-access boundary.
- The presence of entity/ classes and repository interfaces strongly indicates Spring Data-backed persistence, likely to a relational database.
- application.properties configures the runtime connection and JPA behavior.
6. Domain model
- Car and Booking are the core persisted entities.
- They represent the system’s main data objects and are distinct from API-facing DTOs.
7. Mapping and API isolation
- CarMapper and BookingMapper translate between entities and DTOs.
- This keeps the REST contract decoupled from persistence structure, which is important for diagramming the boundary between external API models and internal data models.
8. Error handling boundary
- ResourceNotFoundException captures missing-resource cases.
- GlobalExceptionHandler centralizes error-to-HTTP response translation.
- ApiError is the standardized error response payload, so failures are handled consistently across controllers.
9. Seed data and initialization
- src/main/resources/data.sql provides initial database content.
- This suggests the app can start with preloaded cars/bookings for local development or tests.
10. Testing structure
- The test suite is broad and maps directly to the architecture:
- controller tests for HTTP behavior and validation,
- mapper tests for DTO/entity translation,
- service tests for business logic,
- integration and end-to-end tests for full-stack behavior.
- This indicates the key boundaries are expected to be stable and independently testable.
11. Delivery and deployment path
- pom.xml drives the Maven build.
- Dockerfile packages the service into a container.
- Jenkinsfile defines the CI/CD pipeline, with README indicating build, test, SonarQube analysis, Docker image creation, and deployment to a local Docker host.
- deploy.sh is the final deployment step used by that pipeline.
12. Operational view
- The main data flow is: client request → controller → service → repository → database → mapper → controller response.
- Cross-cutting concerns like validation and exception handling sit alongside the controller/service boundary, while CI/CD and containerization are separate delivery concerns around the application itself.
Main entry points: CarController.java Car API · BookingController.java Booking API · CarRentalRestApiApplication.java App · BookingServiceImpl.java Booking Logic
Components 25
Runtime
Application code that serves REST requests and persists car-rental data.
- App · Application bootstrap for the REST microservice.
src/main/java/edu/stjepan/carrental/CarRentalRestApiApplication.java - Car API · HTTP boundary for car operations.
src/main/java/edu/stjepan/carrental/controller/CarController.java - Booking API · HTTP boundary for booking operations.
src/main/java/edu/stjepan/carrental/controller/BookingController.java - Car Service · Business contract for car use cases.
src/main/java/edu/stjepan/carrental/service/CarService.java - Booking Service · Business contract for booking use cases.
src/main/java/edu/stjepan/carrental/service/BookingService.java - Car Logic · Orchestrates car business operations.
src/main/java/edu/stjepan/carrental/service/impl/CarServiceImpl.java - Booking Logic · Orchestrates booking rules and car availability checks.
src/main/java/edu/stjepan/carrental/service/impl/BookingServiceImpl.java - Car Repo · Persistence boundary for car records.
src/main/java/edu/stjepan/carrental/repository/CarRepository.java - Booking Repo · Persistence boundary for booking records.
src/main/java/edu/stjepan/carrental/repository/BookingRepository.java - Car · Persisted car model.
src/main/java/edu/stjepan/carrental/entity/Car.java - Booking · Persisted booking model.
src/main/java/edu/stjepan/carrental/entity/Booking.java - Car Mapper · Translates car entities and API DTOs.
src/main/java/edu/stjepan/carrental/mapper/CarMapper.java - Booking Mapper · Translates booking entities and API DTOs.
src/main/java/edu/stjepan/carrental/mapper/BookingMapper.java - Errors · Centralizes API error formatting and resource-not-found handling.
src/main/java/edu/stjepan/carrental/exception/GlobalExceptionHandler.java
Delivery
Build, container, and CI/CD assets around the service.
- Maven · Build and dependency management for the project.
pom.xml - Dockerfile · Container packaging for the service runtime.
Dockerfile - Jenkinsfile · CI/CD pipeline for build, test, analysis, and deployment.
Jenkinsfile - Deploy Script · Final deployment step invoked by the pipeline.
deploy.sh - Seed Data · Initial database data loaded at startup.
src/main/resources/data.sql
Tests
Representative test slices covering the main architectural boundaries.
- Car API Test · Validates HTTP behavior for car endpoints.
src/test/java/edu/stjepan/carrental/controller/CarControllerTest.java - Booking API Test · Validates request handling and constraints for booking endpoints.
src/test/java/edu/stjepan/carrental/controller/BookingControllerValidationTest.java - Car Service Test · Exercises car business logic in isolation.
src/test/java/edu/stjepan/carrental/service/CarServiceImplTest.java - Booking Service Test · Exercises booking business rules and orchestration.
src/test/java/edu/stjepan/carrental/service/BookingServiceImplTest.java - Mapper Tests · Checks DTO/entity translation for cars and bookings.
src/test/java/edu/stjepan/carrental/mapper/CarMapperTest.java - Integration · Full-stack integration and end-to-end coverage.
src/test/java/edu/stjepan/carrental/BookingEndToEndIT.java
Connections 31
- App → Car API: exposes · Bootstraps the REST API.
- App → Booking API: exposes · Bootstraps the REST API.
- Car API → Car Service: uses · Delegates car use cases.
- Booking API → Booking Service: uses · Delegates booking use cases.
- Car Service → Car Logic: implemented by · Interface-to-implementation boundary.
- Booking Service → Booking Logic: implemented by · Interface-to-implementation boundary.
- Car Logic → Car Repo: reads/writes · Persists car data.
- Booking Logic → Booking Repo: reads/writes · Persists booking data.
- Booking Logic → Car Repo: checks availability · Looks up cars during booking flow.
- Car Repo → Car: stores · Repository manages car entities.
- Booking Repo → Booking: stores · Repository manages booking entities.
- Car API → Car Mapper: maps · Converts API payloads and responses.
- Booking API → Booking Mapper: maps · Converts API payloads and responses.
- Car Mapper → Car: translates · Entity-to-DTO and DTO-to-entity mapping.
- Booking Mapper → Booking: translates · Entity-to-DTO and DTO-to-entity mapping.
- Car API → Errors: handled by · Controller errors are centralized.
- Booking API → Errors: handled by · Controller errors are centralized.
- Seed Data → Car Repo: primes · Initial car records are loaded.
- Seed Data → Booking Repo: primes · Initial booking records are loaded.
- Maven → App: builds · Maven builds the application.
- Jenkinsfile → Maven: orchestrates · Pipeline runs build and tests.
- Jenkinsfile → Dockerfile: packages · Builds a container image.
- Jenkinsfile → Deploy Script: deploys via · Hands off to deployment script.
- Dockerfile → App: contains · Container image wraps the service.
- Integration → App: covers · Exercises the running application.
- Car API Test → Car API: covers · Validates car API behavior.
- Booking API Test → Booking API: covers · Validates booking API behavior.
- Car Service Test → Car Logic: covers · Validates car business rules.
- Booking Service Test → Booking Logic: covers · Validates booking orchestration.
- Mapper Tests → Car Mapper: covers · Validates mapping logic.
- Mapper Tests → Booking Mapper: covers · Validates mapping logic.