=======
A modular hotel reservation management system built with ASP.NET Core 8, CQRS with MediatR, Entity Framework Core, Redis caching, and Serilog with Seq logging.
The solution is structured with clean architecture principles: Api, Application, Domain, and Infrastructure layers.
- User Management: Register, login (JWT-based), update, delete users with roles (Admin, Guest).
- Rooms: Create, update, delete rooms, assign/remove facilities, view room details.
- Bookings: Create, view, update, delete bookings (Admin and Guest).
- Facilities: Manage facilities and assign them to rooms.
- Reviews: Guests can add reviews for rooms, admins can manage them.
- Caching: Redis cache for users, bookings, rooms, facilities, and reviews.
- Logging: Structured logging with Serilog and Seq.
- Error Handling: Centralized middleware for validation, authentication, and business exceptions.
HotelReservationSystem/
├── HotelReservationSystem.Api/ # Presentation layer (controllers, middleware)
├── HotelReservationSystem.Application/ # Application layer (CQRS, DTOs, validators)
├── HotelReservationSystem.Domain/ # Domain entities and enums
├── HotelReservationSystem.Infrastructure/# Infrastructure (DbContext, repositories, services)
├── docker-compose.yml # Docker setup (API, SQL Server, Redis, Seq)
└── HotelReservationSystem.sln # Visual Studio solution
- Docker Desktop or Docker Engine + Compose V2
- .NET 8 SDK (optional if running locally without Docker)
- Clone the repository.
- From the project root, run:
docker compose up --build- Open Swagger UI:
| Service | Host Port | Container Port |
|---|---|---|
| API | 5001/5002 | 8080/8081 |
| SQL Server | 1433 | 1433 |
| Redis | 6379 | 6379 |
| Redis Commander | 7001 | 8081 |
| Seq (logging UI) | 9090 | 80 |
Settings are in appsettings.json and environment variables in docker-compose.yml.
- Connection String:
Server=db;Database=HotelReservationSystem;User Id=sa;Password=####;... - JWT Settings:
- Expiration: 60 minutes
- Redis:
redis:6379 - Seq:
http://seq:80
POST /api/Account/register— register new userPOST /api/Account/login— login and get JWTGET /api/Account(Admin only) — get all users
GET /api/Rooms— list roomsGET /api/Rooms/{id}— get room by IDPOST /api/Rooms(Admin) — create roomPUT /api/Rooms/{id}(Admin) — update roomDELETE /api/Rooms/{id}(Admin) — delete roomPOST /api/Rooms/{roomId}/facility/{facilityId}— assign facility to roomDELETE /api/Rooms/{roomId}/facility/{facilityId}— remove facility
GET /api/Bookings(Admin) — list all bookingsGET /api/Bookings/current(User) — get current user's bookingsPOST /api/Bookings(User/Admin) — create bookingPUT /api/Bookings/{id}(Admin) — update bookingDELETE /api/Bookings/{id}(Admin) — delete booking
GET /api/Facilities— list facilitiesPOST /api/Facilities(Admin) — create facility
GET /api/Reviews(Admin) — list reviewsGET /api/Reviews/Room/{id}— get reviews for a roomPOST /api/Reviews(User/Admin) — create review
- Setup SQL Server and Redis locally.
- Update
appsettings.jsonconnection strings. - Run migrations:
cd HotelReservationSystem.Infrastructure
dotnet ef database update- Run the API project:
cd HotelReservationSystem.Api
dotnet run- All logs are pushed to Seq (
http://localhost:9090). - View queries, exceptions, and structured logs.
- Implement email notifications for bookings.
- Improve unit test coverage.
- Move secrets to environment variables or secret manager.
- Authentication & Authorization
- User registration and login
- Role-based access control (Admin, Guest) using JWT
- Room Management
- Full CRUD operations for rooms
- Assign facilities (WiFi, AC, Pool, etc.)
- Facility Management
- Manage hotel facilities with CRUD
- Booking Management
- Create, update, cancel reservations
- Automatic date conflict checks
- Review System
- Guests can leave reviews and ratings for rooms
- Validation & Error Handling
- Request validation with FluentValidation
- Centralized exception handling middleware
- Performance & Maintainability
- CQRS pattern with MediatR
- Logging with Serilog
- Mapster for object mapping
- Distributed Caching with Redis
- Cache-aside strategy applied to all controllers
- Sliding & absolute expiration policies
- Automatic cache invalidation on create/update/delete operations
- Data Persistence
- Entity Framework Core with SQL Server
- Automatic migrations and seed data on startup
- Framework: ASP.NET Core 8 (Web API)
- Database: SQL Server (configurable)
- ORM: Entity Framework Core
- Architecture: Clean Architecture + CQRS
- Caching: Redis (via Docker)
- Libraries:
- MediatR (CQRS)
- FluentValidation (validation)
- Mapster (object mapping)
- Serilog with Seq (logging)
- Authentication: JWT
- DevOps: Docker & Docker Compose
- Documentation: Swagger (OpenAPI)
git clone https://github.com/mohammadsofan/HotelReservationSystem.git
cd HotelReservationSystemMigrations are applied automatically on startup via the built-in seeder.
docker-compose up --build- API available at: http://localhost:5001
- Swagger docs: http://localhost:5001/swagger
- Seq logging UI: http://localhost:9090
- Redis Commander: http://localhost:7001
HotelReservationSystem/
│
├── HotelReservationSystem.Domain # Domain entities, enums, constants
├── HotelReservationSystem.Application # Application logic, CQRS handlers, DTOs, validation
├── HotelReservationSystem.Infrastructure # Data access, repositories, cache service, seeders
├── HotelReservationSystem.Api # API controllers, middleware, configuration
└── docker-compose.yml # Docker setup (API, DB, Redis, Seq, Redis Commander)
Swagger UI is enabled by default:
http://localhost:5001/swagger
- Add support for multiple hotels and branches
- Implement payment gateway integration (Stripe/PayPal)
- Add reporting module (occupancy, revenue stats)
- Implement receptionist and housekeeping roles
- Enhance review system with photos