A RESTful API system for managing flight bookings, built with ASP.NET 9.0. This application demonstrates a clean architecture approach with vertical slice organization, utilizing EF Core for data persistence with PostgreSQL, Redis for caching and distributed locking to handle concurrent booking requests, and FluentValidation for request validation.
- Passenger Management: Create and retrieve passenger information
- Flight Operations: Create flights, filter available flights, and view bookings
- Seat Booking: Book seats with concurrency control to prevent overbooking
- Distributed Locking: Redis-based distributed locks ensure thread-safe operations
- Request Validation: FluentValidation for comprehensive input validation
- API Documentation: Built-in Swagger/OpenAPI documentation
- Framework: ASP.NET 9.0
- Database: PostgreSQL 16
- Cache: Redis 7
- ORM: Entity Framework Core
- API Documentation: Swagger/OpenAPI
- Validation: FluentValidation
- Concurrency Control: Distributed Lock (Redis)
- API Pattern: Minimal APIs with Carter
- Docker and Docker Compose
- .NET 9.0 SDK (only required for running locally without Docker)
-
Clone the repository:
git clone https://github.com/MahdiyarGHD/TravelBookingSystem.git cd TravelBookingSystem -
Start all services (API, PostgreSQL, Redis):
cd src/TravelBookingSystem docker-compose up --build -
Access the API:
- API: http://localhost:5000
- Swagger UI: http://localhost:5000/swagger
-
Start dependencies (PostgreSQL and Redis):
cd src/TravelBookingSystem docker-compose up postgres redis -
Update connection strings in
src/TravelBookingSystem/appsettings.Development.jsonif needed. -
Run the application:
cd src/TravelBookingSystem dotnet run -
Access the API:
- API: https://localhost:7021 (or http://localhost:5062)
- Swagger UI: https://localhost:5062/swagger
- POST
/passengers- Create a new passenger - GET
/passengers- Get all passengers
- POST
/flights- Create a new flight - GET
/flights/filter- Filter flights by criteria - GET
/flights/get-bookings- Get bookings for a flight - PATCH
/flights/update-available-seats- Update available seats for a flight
- POST
/bookings- Book a seat on a flight
Run unit tests:
dotnet test TravelBookingSystem.TestsRun integration tests:
dotnet test TravelBookingSystem.IntegrationTestsTravelBookingSystem/
├── src/
│ └── TravelBookingSystem/
│ ├── Features/ # Feature-based vertical slices
│ │ ├── Booking/
│ │ ├── Flight/
│ │ └── Passenger/
│ ├── Common/
│ │ ├── Extensions/ # Extension methods
│ │ ├── Filters/ # Endpoint filters
│ │ ├── Persistence/ # Database context
│ │ └── Providers/ # Service providers
│ ├── Program.cs
│ ├── Dockerfile
│ └── docker-compose.yml
├── TravelBookingSystem.Tests/ # Unit tests
└── TravelBookingSystem.IntegrationTests/ # Integration tests
To stop Docker containers:
docker-compose downTo remove all data:
docker-compose down -vThis project is licensed under the MIT License - see the LICENSE file for details.