This service is designed to manage Restaurant reservations. It provides functionalities for making, canceling, and listing reservations, as well as user authentication for secure access. The service is built using C# and follows a clean architecture with clearly defined use cases.
- Restaurant Reservation Service
The Restaurant Reservation Service allows users to manage Restaurant reservations through a set of RESTful API endpoints. The service handles the following scenarios:
- Creating new reservations
- Canceling existing reservations
- Listing all reservations
- Retrieving details of a specific reservation
- Authenticating users
The service is built using the principles of Clean Architecture, Domain-Driven Design (DDD), and Slicing Architecture. These architectural patterns ensure that the application is scalable, maintainable, and testable by organizing code into distinct layers with clear responsibilities. A graphical description of how the layers are organized can be found in the Architecture Graph.
POST /api/reservation
This endpoint allows users to create a new reservation. It validates the reservation details and ensures that the reservation date is within the allowed range.
MakeCommandHandler
- Reservation date must be in the future.
- Reservation date must be within 30 days from the current date.
- Reservation time must be between 7:00 PM and 10:00 PM.
{
"id": "unique-reservation-id",
"date": "2023-08-15T20:00:00Z",
"guests": 2,
"name": "John Doe"
}
DELETE /api/reservation/{id}
This endpoint allows users to cancel an existing reservation. It verifies the existence of the reservation before canceling it.
CancelCommandHandler
DELETE /api/reservation/unique-reservation-id
GET /api/reservation
This endpoint retrieves a list of all reservations.
ListQueryHandler
GET /api/reservation
GET /api/reservation/{id}
This endpoint retrieves the details of a specific reservation by its ID.
DetailQueryHandler
GET /api/reservation/unique-reservation-id
POST /authorization/token
This endpoint allows users to authenticate by providing their username and password. It generates a token for authenticated users.
LoginQueryHandler
{
"username": "testuser",
"password": "password"
}
- Clone the repository:
git clone https://github.com/yourusername/bal-reservation.git
- Navigate to the project directory:
cd bal-reservation
- Install the required dependencies:
dotnet restore
- Ensure that you have Docker running on your machine.
- Start the SQL Server using Docker Compose:
docker-compose up -d
- Run the application:
dotnet run --project src/Api/Api.csproj
- The application will be available at
http://localhost:5001/
.
- Ensure that you have Docker running on your machine.
- Navigate to the
src
folder:cd src
- Build and start the services using Docker Compose:
docker-compose up --build
- The application will be available at
http://localhost:5002/
.
You can import the Postman collection provided in the src
folder to test the API endpoints. The collection file is named Bla Restaurant.postman_collection.json
.
Run the tests using the following command:
dotnet test
The project includes comprehensive tests for all handlers to ensure the correctness of the business logic and validate various scenarios.