A comprehensive airline management system built using Spring Boot, designed to manage flight schedules and ticket bookings with robust validation and RESTful APIs.
✅ Retrieve available flight schedules.
✅ View detailed information for specific flights.
✅ Book a new ticket with proper validation checks.
✅ View ticket details.
✅ Cancel a ticket.
✅ Built-in Swagger UI for API testing.
✅ H2 Database for lightweight, in-memory data management.
├── src
│ ├── main
│ │ ├── java
│ │ │ └── com
│ │ │ └── airline
│ │ │ ├── controller
│ │ │ ├── model
│ │ │ ├── repository
│ │ │ ├── service
│ │ │ └── AirlineManagementApplication.java
│ │ └── resources
│ │ ├── application.properties
│ │ └── data.sql
│ ├── test
│ └── (Test files for unit/integration testing)
├── .gitignore
├── README.md
└── pom.xml
- Java 17
- Spring Boot 3.2.0
- Spring Data JPA
- H2 Database
- Swagger (Springdoc)
- Lombok
Ensure you have the following installed:
- JDK 17 or higher
- Maven 3.8+
- IDE such as IntelliJ IDEA, VSCode, or Eclipse
Clone the repository and navigate to the project directory:
git clone https://github.com/your-repo/airline-management-system.git
cd airline-management-system
Run the following command to compile the project and resolve dependencies:
mvn clean install
If you face dependency issues, use:
mvn clean install -U
Start the Spring Boot application with:
mvn spring-boot:run
Expected console message:
Started AirlineManagementApplication in 2.345 seconds (JVM running for 3.012)
Method | Endpoint | Description |
---|---|---|
GET |
/flights?sort=asc |
Get all flights (sorted) |
GET |
/flights/{id} |
Get flight details by ID |
GET |
/flights/{id}/schedules?dates= |
Get flight schedules by date(s) |
POST |
/tickets |
Book a new ticket |
GET |
/tickets/{id} |
Get ticket details by ID |
DELETE |
/tickets/{id} |
Cancel a ticket |
✅ Create Ticket Request
{
"passengerName": "Alice Johnson",
"email": "alice.johnson@example.com",
"flightId": 1,
"seatNumber": "C3",
"status": "ACTIVE"
}
✅ Flight Schedule Response
{
"flightNumber": "AI101",
"origin": "New York",
"destination": "London",
"departureTime": "2025-04-01T10:00:00",
"arrivalTime": "2025-04-01T18:00:00",
"status": "ON_TIME"
}
Once the app is running, visit:
🔗 Swagger UI
To view and manage data directly in the H2 database:
🔗 H2 Console
Connection Details:
- JDBC URL:
jdbc:h2:mem:testdb
- Username:
sa
- Password: (Leave empty)
To execute unit and integration tests:
mvn test
❗ Port Already in Use:
lsof -i :8080 # Identify process
kill -9 <PID> # Kill conflicting process
❗ Dependency Issues:
mvn clean install -U
❗ H2 Console Errors:
Ensure the JDBC URL is correctly set to:
jdbc:h2:mem:testdb
This project is licensed under the MIT License.
For questions or improvements, feel free to reach out. 🚀