- This project provides a Spring Boot API for managing user authentication, airport management, flight management, and flight search functionalities. It includes advanced logging and security features.
-
User Authentication:
- User Registration: Register users with an email and password.
- User Login: Authenticate users with email and password, generating access and refresh tokens.
- Token Refresh: Refresh expired access tokens using refresh tokens.
- User Logout: Invalidate tokens to log users out.
-
Airport Management:
- Create Airports: Accessible only to ADMIN users.
- Retrieve Airports: Paginated airport list retrieval, accessible to both ADMIN and USER roles.
- Retrieve Specific Airport: Search by airport ID, accessible to both ADMIN and USER roles.
- Update Airports: Modify an existing airport by ID, accessible only to ADMIN users.
- Delete Airports: Remove airports by ID, accessible only to ADMIN users.
-
Flight Management:
- Create Flights: Accessible only to ADMIN users.
- Retrieve Flights: Paginated flight list retrieval, accessible to both ADMIN and USER roles.
- Retrieve Specific Flight: Search by flight ID, accessible to both ADMIN and USER roles.
- Update Flights: Modify an existing flight by ID, accessible only to ADMIN users.
- Delete Flights: Remove flights by ID, accessible only to ADMIN users.
-
Flight Search:
- Search Flights: Search for flights based on departure, arrival airports, and departure date. Accessible to both ADMIN and USER roles. (One Way - Round-Trip)
-
Security:
- User Roles: ADMIN and USER roles implemented using Spring Security.
- JWT Authentication: Secure endpoints with JSON Web Tokens.
-
Logging:
- Custom Logging Aspect: Logs details of REST controller method calls and exceptions, including HTTP request and response details.
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/airports | Create a new Airport | CreateAirportRequest | CustomResponse<String> | |
GET | /api/v1/airports | Get all Airports | AirportPagingRequest | CustomResponse<CustomPagingResponse<AirportResponse>> | |
GET | /api/v1/airports/{id} | Get Airport by ID | UUID | CustomResponse<AirportResponse> | |
PUT | /api/v1/airports/{id} | Update an Airport | UpdateAirportRequest | UUID | CustomResponse<AirportResponse> |
DELETE | /api/v1/airports/{id} | Delete an Airport | UUID | CustomResponse<String> | |
POST | /api/v1/flights | Create a new Flight | CreateFlightRequest | CustomResponse<String> | |
GET | /api/v1/flights | Get all Flights | AirportPagingRequest | CustomResponse<CustomPagingResponse<FlightResponse>> | |
GET | /api/v1/flights/{id} | Get Flight by ID | UUID | CustomResponse<FlightResponse> | |
PUT | /api/v1/flights/{id} | Update a Flight | UpdateFlightRequest | UUID | CustomResponse<FlightResponse> |
DELETE | /api/v1/flights/{id} | Delete a Flight | UUID | CustomResponse<String> | |
POST | /api/v1/flights/search | Search for Flights | SearchFlightRequest | CustomResponse<CustomPagingResponse<FlightResponse>> |
- Java 21
- Spring Boot 3.0
- Restful API
- Mapstruct
- Open Api (Swagger)
- Maven
- Junit5
- Mockito
- Integration Tests
- Docker
- Docker Compose
- CI/CD (Github Actions - Jenkins)
- Postman
- TestContainer
- Mongo
- Prometheus
- Grafana
- Kubernetes
- JaCoCo (Test Report)
Import postman collection under postman_collection folder
MONGO_DB_NAME=flightdatabase
MONGO_DB_HOST=localhost
MONGO_DB_PORT=27017
http://localhost:1133/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 flightsearchapi
$ mvn clean install
$ mvn spring-boot:run
The 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 flightsearchapi
$ docker-compose up -d
If you change anything in the project and run it on Docker, you can also use this command shown below
$ cd flightsearchapi
$ docker-compose up --build
To 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:
-
Define prometheus data source url, use this link shown below
http://prometheus:9090
To build and run the application with Maven
, 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
- Define prometheus data source url, use this link shown below
http://prometheus-service.default.svc.cluster.local:9090
https://hub.docker.com/repository/docker/noyandocker/flightsearchapi/general
https://hub.docker.com/repository/docker/noyandocker/flightsearchapi-jenkins/general
- Go to
jenkins
folder - Run
docker-compose up -d
- Open Jenkins in the browser via
localhost:8080
- Go to pipeline named
flightsearchapi
- Run Pipeline
- Show
Pipeline Step
to verify if it succeeded or failed