The Airline Ticketing System is a Spring Boot application designed to handle flight bookings, cancellations, and flight management. It supports features such as flight search, booking, cancellation, and flight information retrieval. The application uses MongoDB as the database and provides RESTful APIs for interacting with the system.
- Flight Management: Add, update, retrieve, and delete flights.
- Flight Search: Search for available flights based on source, destination, and date.
- Booking: Book seats on available flights.
- Cancellation: Cancel existing bookings.
- Default Data: Add default flights for initial setup.
- Spring Boot: Framework for building the application.
- MongoDB: NoSQL database for storing flight and booking data.
- Swagger: API documentation and testing.
- Docker: Containerization for deployment.
- Java 17 or later
- MongoDB (local or server instance)
- Maven or Gradle (for building the project)
- Docker (optional, for containerization)
git clone https://github.com/rishidyno/airline-ticketing-system.git
cd airline-ticketing-system- MongoDB Configuration: Update the MongoDB connection settings in
src/main/resources/application.propertiesorapplication.yml.
spring.data.mongodb.uri=mongodb://localhost:27017/airline_db- Swagger Documentation: Swagger UI is available at
/swagger-ui.html.
mvn clean install
mvn spring-boot:run./gradlew build
./gradlew bootRun- Build Docker Image
docker build -t airline-ticketing-system .- Run Docker Container
docker run -p 8080:8080 airline-ticketing-system- Endpoint:
POST /api/v1/flights/add-single-flight - Description: Adds a new flight to the system.
- Request Body:
{
"flightType": "A320",
"source": "Delhi",
"destination": "Hyderabad",
"schedule": [
"Monday",
"Wednesday",
"Friday"
],
"departureTime": "08:30",
"duration": "110",
"totalSeats": {
"$numberInt": "180"
},
"seatConfiguration": {
"rows": {
"$numberInt": "30"
},
"seatsPerRow": {
"$numberInt": "6"
},
"seatLabels": [
"A",
"B",
"C",
"D",
"E",
"F"
]
}
}- Responses:
200 OK: Successfully added the flight.400 Bad Request: Invalid flight details.500 Internal Server Error: Error adding the flight.
- Endpoint:
POST /api/v1/flights/add-default-flights - Description: Adds a set of default flights for initial setup.
- Responses:
200 OK: Default flights added successfully.400 Bad Request: Error adding default flights.500 Internal Server Error: Error adding default flights.
- Endpoint:
GET /api/v1/flights/get-all-flights - Description: Retrieves a list of all flights.
- Responses:
200 OK: Successfully retrieved the list of flights.500 Internal Server Error: Error retrieving the list of flights.
- Endpoint:
GET /api/v1/flights/get-flight-by-flight-number/{id} - Description: Retrieves details of a specific flight by flight number.
- Responses:
200 OK: Successfully retrieved the flight details.404 Not Found: Flight not found for the given flight number.500 Internal Server Error: Error retrieving the flight.
- Endpoint:
PUT /api/v1/flights/update-flight/{id} - Description: Updates the details of an existing flight.
- Request Body:
- Responses:
200 OK: Successfully updated the flight details.400 Bad Request: Invalid flight details.404 Not Found: Flight not found for the given flight number.500 Internal Server Error: Error updating the flight.
- Endpoint:
DELETE /api/v1/flights/delete-flight/{id} - Description: Deletes an existing flight by flight number.
- Responses:
204 No Content: Successfully deleted the flight.404 Not Found: Flight not found for the given flight number.500 Internal Server Error: Error deleting the flight.
- Endpoint:
POST /api/v1/bookings/book - Description: Books seats on a specified flight.
- Request Body:
{
"date": "string",
"flightNumber": "string",
"flightType": "string",
"seats": [
{
"row": 0,
"seat": "string"
}
]
}- Responses:
200 OK: Booking successful.400 Bad Request: Invalid booking details.404 Not Found: Flight or date not found.500 Internal Server Error: Error during booking.
- Endpoint:
POST /api/v1/bookings/cancel - Description: Cancels an existing booking.
- Request Body:
{
"bookingId": "string",
"date": "string",
"flightNumber": "string",
"flightType": "string"
}- Responses:
200 OK: Cancellation successful.400 Bad Request: Invalid cancellation details.404 Not Found: Booking not found.500 Internal Server Error: Error during cancellation.
- Endpoint:
POST /api/v1/flights/search - Description: Searches for available flights based on the search criteria.
- Request Body:
{
"source": "Delhi",
"destination": "Mumbai",
"date": "2024-09-15"
}- Responses:
200 OK: List of available flights.400 Bad Request: Invalid search criteria.500 Internal Server Error: Error during search.
- Common Errors:
400 Bad Request: The request could not be understood or was missing required parameters.404 Not Found: The requested resource could not be found.500 Internal Server Error: A generic error occurred on the server.
We welcome contributions to improve the Airline Ticketing System. To contribute:
- Fork the repository.
- Create a new branch (
git checkout -b feature/new-feature). - Make your changes.
- Commit your changes (
git commit -am 'Add new feature'). - Push to the branch (
git push origin feature/new-feature). - Create a new Pull Request.
For any questions or issues, please contact:
- Author:
Rishi - Username:
rishidyno