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.