A comprehensive hotel management system with REST API for room booking, user management, and authentication.
- Project Description
- Architecture
- Technologies
- Installation
- Configuration
- API Endpoints
- Project Structure
- Usage
Hotel Management System is a web API for hotel management that provides:
- User registration and authentication
- Room management (add, edit, delete)
- Room booking with availability checking
- Image upload for rooms
- Search available rooms by dates and parameters
- Price management by room type
The project is built following Clean Architecture principles with separation into three main layers:
- API Layer (
HotelHTTP.API) - controllers, services, requests - Domain Layer (
HotelHTTP.Domain) - entities, interfaces - Infrastructure Layer (
HotelHttp.Infrastracture) - repositories, database
- .NET 8.0 - main platform
- ASP.NET Core Web API - web framework
- Entity Framework Core - ORM
- PostgreSQL - database
- JWT Bearer Authentication - authentication
- Swagger/OpenAPI - API documentation
- CORS - cross-domain request support
- .NET 8.0 SDK
- PostgreSQL
- Git
- Clone the repository:
git clone <repository-url>
cd Hotel_Server- Install dependencies:
dotnet restore-
Configure database:
- Create PostgreSQL database
- Update connection string in
appsettings.json
-
Run migrations:
dotnet ef database update --project HotelHttp.Infrastracture --startup-project HotelHTTP.API- Run the project:
dotnet run --project HotelHTTP.API{
"ConnectionStrings": {
"DefaultConnectionString": "Host=localhost;Database=HotelDB;Username=your_username;Password=your_password"
},
"Jwt": {
"Key": "your-super-secret-key-here",
"Issuer": "HotelAPI",
"Audience": "HotelClients"
}
}The API is configured to work with frontend on http://localhost:5173.
| Method | Endpoint | Description | Authorization |
|---|---|---|---|
| POST | /register |
User registration | β |
| POST | /login |
User login | β |
| POST | /logout |
User logout | β |
| Method | Endpoint | Description | Authorization |
|---|---|---|---|
| GET | / |
Get all rooms | β |
| GET | /{id} |
Get room by ID | β |
| POST | / |
Create room | β |
| PUT | /{id} |
Update room | β |
| DELETE | /{id} |
Delete room | β |
| GET | /available |
Search available rooms | β |
| POST | /update-prices |
Update prices by type | β |
| Method | Endpoint | Description | Authorization |
|---|---|---|---|
| GET | / |
Get all bookings | β |
| GET | /user |
Get current user bookings | β |
| POST | / |
Create booking | β |
| DELETE | /{id} |
Cancel booking | β |
| GET | /bookings-per-day |
Bookings statistics by day | β |
| Method | Endpoint | Description | Authorization |
|---|---|---|---|
| GET | /me |
Get current user info | β |
Hotel_Server/
βββ HotelHTTP.API/ # API Layer
β βββ Controllers/ # API Controllers
β β βββ AuthController.cs
β β βββ BookingController.cs
β β βββ RoomsController.cs
β β βββ UserController.cs
β βββ Requests/ # Request Models
β β βββ BookingRequest.cs
β β βββ LoginRequest.cs
β β βββ RegisterRequest.cs
β β βββ RoomRequest.cs
β β βββ UpdatePriceRequest.cs
β βββ Service/ # Business Logic
β β βββ AuthService.cs
β β βββ BookingService.cs
β β βββ RoomService.cs
β β βββ TokenService.cs
β βββ wwwroot/images/ # Room Images
β βββ Program.cs
βββ HotelHTTP.Domain/ # Domain Layer
β βββ Entities/ # Entities
β β βββ User.cs
β β βββ Room.cs
β β βββ Booking.cs
β βββ Interfaces/ # Interfaces
β βββ Auth/
β βββ Repo/
βββ HotelHttp.Infrastracture/ # Infrastructure Layer
βββ Data/
β βββ HotelDBContext.cs
βββ Repositories/ # Repositories
β βββ BookingRepository.cs
β βββ RoomRepository.cs
β βββ UserRepository.cs
βββ Migrations/ # Database Migrations
βββ PasswordHasher.cs
POST /api/auth/register
Content-Type: application/json
{
"name": "John Doe",
"email": "john@example.com",
"password": "password123",
"role": "User"
}POST /api/auth/login
Content-Type: application/json
{
"email": "john@example.com",
"password": "password123"
}GET /api/rooms/available?checkInDate=2024-01-15&checkOutDate=2024-01-20&maxPrice=1000&capacity=2POST /api/booking
Authorization: Bearer <token>
Content-Type: application/json
{
"roomId": 1,
"checkInDate": "2024-01-15T14:00:00Z",
"checkOutDate": "2024-01-20T12:00:00Z"
}- JWT tokens stored in HTTP-only cookies
- Passwords hashed using BCrypt
- CORS configured for secure frontend communication
- Input validation for all data
This project is distributed under the MIT License. See the LICENSE file for details.