-
Authentication:
- Users must register before accessing car and service endpoints.
- Login returns an access + refresh token; refresh-token endpoint issues new tokens.
- Logout invalidates the refresh token.
- Responses use HTTP‑status codes: 200 for success, 400 for bad data, 401 for unauthorized, 409 for conflicts.
-
Car Management:
- Roles “USER” or “ADMIN” can assign cars; only admins can list/update/delete any car.
- Each car has a unique license plate; duplicates yield 409 Conflict.
- Owners (and admins) can retrieve, update, or soft‑delete by ID.
- Admin‐only endpoints support pagination and filtering by “active” status.
-
Service Management:
- Only admins may create, assign, or update services.
- Services can be listed (all, by car, or filtered by status), with pagination on every list endpoint.
- Assigning a service to a car or updating it returns the updated ServiceResponse.
Endpoints Summary
| Method | Url | Description | Request Body | Path Variable | Response |
|---|---|---|---|---|---|
| POST | /api/v1/authentication/user/register | Register for Admin or User | RegisterRequest | CustomResponse<Void> | |
| POST | /api/v1/authentication/user/login | Login for Admin or User | LoginRequest | CustomResponse<TokenResponse> | |
| POST | /api/v1/authentication/user/refresh-token | Refresh Token for Admin or User | TokenRefreshRequest | CustomResponse<TokenResponse> | |
| POST | /api/v1/authentication/user/logout | Logout for Admin or User | TokenInvalidateRequest | CustomResponse<Void> | |
| POST | /api/v1/cars | Assign a new car to a user | CreateCarRequest | CustomResponse<CarResponse> | |
| GET | /api/v1/cars/{carId} | Get car by ID | carId (UUID) | CustomResponse<CarResponse> | |
| POST | /api/v1/cars/users/{userId} | Get all cars for a user | CustomPagingRequest | userId (UUID) | CustomResponse<CustomPagingResponse<CarResponse>> |
| POST | /api/v1/cars/all | Get all cars (admin) | CustomPagingRequest | CustomResponse<CustomPagingResponse<CarResponse>> | |
| POST | /api/v1/cars/allcarsByActiveStatus | Get all active cars (admin) | CustomPagingRequest | CustomResponse<CustomPagingResponse<CarResponse>> | |
| PUT | /api/v1/cars/{carId} | Update car by ID | UpdateCarRequest | carId (UUID) | CustomResponse<CarResponse> |
| DELETE | /api/v1/cars/{carId} | Soft delete car by ID (admin) | carId (UUID) | CustomResponse<String> | |
| POST | /api/services/all | Get all services (admin) | CustomPagingRequest | CustomResponse<CustomPagingResponse<ServiceResponse>> | |
| POST | /api/services/car/{carId} | Get services by car ID (admin) | CustomPagingRequest | carId (UUID) | CustomResponse<CustomPagingResponse<ServiceResponse>> |
| POST | /api/services/filter | Filter services by car/status (admin) | FilterServicePagingRequest | CustomResponse<CustomPagingResponse<ServiceResponse>> | |
| POST | /api/services | Create a new service (admin) | CreateServiceRequest | CustomResponse<ServiceResponse> | |
| POST | /api/services/assign | Assign service to car (admin) | AssignServiceToCarRequest | CustomResponse<ServiceResponse> | |
| PUT | /api/services/car/{carId}/service/{serviceId} | Update service on car (admin) | UpdateServiceRequest | carId, serviceId (UUID) | CustomResponse<ServiceResponse> |
- Java 21
- Spring Boot 3.0
- Restful API
- Open Api (Swagger)
- Maven
- Junit5
- Mockito
- Integration Tests
- Docker
- Docker Compose
- CI/CD (Github Actions)
- Postman
- Prometheus
- Grafana
- Alert Manager
- Sonarqube
- Kubernetes
- JaCoCo (Test Report)
Import postman collection under postman_collection folder
CAR_SERVICE_DB_IP=localhost
CAR_SERVICE_DB_PORT=3306
DATABASE_USERNAME={MY_SQL_DATABASE_USERNAME}
DATABASE_PASSWORD={MY_SQL_DATABASE_PASSWORD}
GF_SMTP_ENABLED=true
GF_SMTP_HOST=smtp.gmail.com:587
GF_SMTP_USER={your_gmail_email}
GF_SMTP_PASSWORD={gmail_authentication_password}
GF_SMTP_SKIP_VERIFY=true
GF_SMTP_FROM_ADDRESS={your_gmail_email}
ALERT_RESOLVE_TIMEOUT=5m
SMTP_SMARTHOST=smtp.gmail.com:587
SMTP_FROM={your_gmail_email}
SMTP_AUTH_USERNAME={your_gmail_email}
SMTP_AUTH_PASSWORD={gmail_authentication_password}
SMTP_REQUIRE_TLS=true
ALERT_EMAIL_TO={your_gmail_email}
http://localhost:4110/swagger-ui/index.html
After the command named mvn clean install completes, the JaCoCo report will be available at:
target/site/jacoco/index.html
Navigate to the target/site/jacoco/ directory.
Open the index.html file in your browser to view the detailed coverage report.
To build and run the application with Maven, please follow the directions shown below;
$ cd carservice
$ mvn clean install
$ mvn spring-boot:runThe application can be built and run by the Docker engine. The Dockerfile has multistage build, so you do not need to build and run separately.
Please follow directions shown below in order to build and run the application with Docker Compose file;
$ cd carservice
$ docker-compose up -dIf you change anything in the project and run it on Docker, you can also use this command shown below
$ cd carservice
$ docker-compose up --buildTo monitor the application, you can use the following tools:
-
Prometheus:
Open in your browser at http://localhost:9090
Prometheus collects and stores application metrics. -
Grafana:
Open in your browser at http://localhost:3000
Grafana provides a dashboard for visualizing the metrics.
Default credentials:- Username:
admin - Password:
admin
- Username:
-
AlertManager:
Open in your browser at http://localhost:9093
Define prometheus data source url, use this link shown below
http://prometheus:9090
Define alertManager data source url, use this link shown below
http://alertmanager:9093
To run the application, please follow the directions shown below;
- Start Minikube
$ minikube start- Open Minikube Dashboard
$ minikube dashboard- To deploy the application on Kubernetes, apply the Kubernetes configuration file underneath k8s folder
$ kubectl apply -f k8s- To open Prometheus, click tunnel url link provided by the command shown below to reach out Prometheus
minikube service prometheus-service- To open Grafana, click tunnel url link provided by the command shown below to reach out Prometheus
minikube service grafana-service- To open AlertManager, click tunnel url link provided by the command shown below to reach out Prometheus
minikube service alertmanager-service- Define prometheus data source url, use this link shown below
http://prometheus-service.default.svc.cluster.local:9090
- Define alertmanager data source url, use this link shown below
http://alertmanager-service.default.svc.cluster.local:9093
- Go to
localhost:9093for Docker and Go there throughminikube service alertmanager-servicefor Kubernetes - Define
Your Gmail addressforContract Pointand determine if test mail is send to its email - After define jvm micrometer dashboard in Grafana with its id 4701, click
Heap Used Paneledit andMore -> New Alert Rules - Define
Thresholdas input assigning toAwithIS ABOVEas2 - Create a new folder names for
3. Add folder and labelsand4. Set evaluation behaviour - Define
Contract Pointsfor your defined email in5. Configure notification - After reaching the threshold value, it triggers to send an alert notification to your defined mail
- Pre-configured Alert Rules:
- The alert is pre-defined in the
rulefile withinPrometheus, streamlining your monitoring setup
- The alert is pre-defined in the
- Threshold-based Trigger:
- Once any metric exceeds its designated threshold, the
alertis automatically activated
- Once any metric exceeds its designated threshold, the
- Instant Email Notifications:
- Upon triggering,
Alert Managersends an immediateemail notificationto your definedemail, keeping you informed in real time
- Upon triggering,
- Go to
localhost:9000for Docker and Go there throughminikube service sonarqubefor Kubernetes - Enter username and password as
admin - Change password
- Click
Create Local Project - Choose the baseline for this code for the project as
Use the global setting - Click
Locallyin Analyze Method - Define Token
- Click
Continue - Copy
sonar.host.urlandsonar.token(sonar.login) in thepropertiespart inpom.xml - Run
mvn sonar:sonarto show code analysis
https://hub.docker.com/repository/docker/noyandocker/carservice/general
Click here to show the screenshots of project
Figure 1
Figure 2
Figure 3
Figure 4
Figure 5
Figure 6
Figure 7
Figure 8
Figure 9
Figure 10
Figure 11
Figure 12
Figure 13
Figure 14
Figure 15
Figure 16
Figure 17
Figure 18
Figure 19
Figure 20
Figure 21
Figure 22
Figure 23
Figure 24
Figure 25
Figure 26
Figure 27
Figure 28
Figure 29
Figure 30
Figure 31
Figure 32
Figure 33
Figure 34
Figure 35
Figure 36
Figure 37
Figure 38
Figure 39
Figure 40
Figure 41
Figure 42
Figure 43
Figure 44
Figure 45
Figure 46
Figure 47
Figure 48
Figure 49
Figure 50
Figure 51
Figure 52
Figure 53
