This project is an implementation of the Corporate Hotel Booking Kata using a Web API in C#. The solution follows a Clean Architecture pattern, organizing the code into separate layers: Application, Domain, and Infrastructure. The project also includes unit and acceptance tests to ensure the correctness of the implementation.
- Overview
- Architecture
- Technologies Used
- Getting Started
- Running Tests
- Continuous Integration
- MongoDB Integration
- Contributing
- License
The Corporate Hotel Booking Kata is a coding exercise that involves implementing a system for booking hotel rooms for corporate clients. The system is designed to handle various booking scenarios while maintaining clean and maintainable code.
This solution implements a RESTful Web API in C# with a focus on Clean Architecture, ensuring that the core business logic is independent of external concerns like databases and UI frameworks. The project has been developed using Test-Driven Development (TDD) cycles, ensuring that all functionalities are backed by tests from the beginning and that the implementation strictly adheres to the defined requirements.
The project is structured according to Clean Architecture principles, with the following key layers:
- Application: Contains the application logic, including use cases, commands, and queries.
- Domain: Holds the core business logic and domain models. This layer is independent of any external dependencies.
- Infrastructure: Includes external dependencies such as data access (e.g., MongoDB repository) and other services required by the application.
This separation of concerns allows for easier testing, maintenance, and scalability of the system.
CorporateHotel/
└── HotelManagement/
├── Application/
├── Domain/
└── Infrastructure/
CorporateHotel.Tests/
├── Acceptance/
├── Helpers/
└── HotelManagement/
├── Application/
├── Domain/
└── Infrastructure/
CorporateHotel/Application
: Contains the application layer code.CorporateHotel/Domain
: Contains the core domain models and business logic.CorporateHotel/Infrastructure
: Contains the infrastructure code, including database repositories.CorporateHotel.Tests/Acceptance
: Contains acceptance tests that validate the overall behavior of the application.CorporateHotel.Tests/HotelManagement
: Contains unit tests for the Hotel Management service.
- .NET 8: The base framework for the Web API.
- MongoDB: A NoSQL database used for storing booking data.
- Moq: A library for creating mock objects in unit tests.
- xUnit: The testing framework used for unit and acceptance tests.
- Docker: For setting up MongoDB locally if needed.
- .NET 8 SDK installed on your machine.
- MongoDB installed locally, or access to a MongoDB instance.
- Docker if you prefer to run MongoDB in a container.
-
Clone the repository:
git clone https://github.com/kleov-rf/corporate-hotel-kata.git cd corporate-hotel-kata
-
Restore the dependencies:
dotnet restore
-
Ensure that MongoDB is running locally or update the connection string in the
appsettings.json
file of the Web API project. -
Build and run the application:
dotnet build dotnet run --project src/WebApi/WebApi.csproj
-
The API will be accessible at
http://localhost:5000
by default.
The solution includes both unit and acceptance tests to validate the implementation.
-
To run all tests, use the following command:
dotnet test
-
To run tests for a specific project, navigate to the
tests
directory and run:dotnet test <ProjectName>.csproj
This project includes a GitHub Actions CI workflow that automatically runs the tests whenever changes are pushed to the repository. The workflow is defined in the .github/workflows/workflow.yml
file.
To customize or extend the CI pipeline, modify the workflow.yml
file as needed.
We are in the process of implementing a MongoDBRepository
to handle data persistence. The repository will provide CRUD operations for the booking data and will be integrated into the application through the Infrastructure layer.
Ensure that your MongoDB instance is correctly configured in the appsettings.json
file:
{
"MongoDB": {
"ConnectionString": "mongodb://localhost:27017",
"DatabaseName": "corporate_hotel"
}
}
- Implementing advanced query capabilities using MongoDB's aggregation framework.
- Adding indexes to optimize query performance.
- Integrating with MongoDB Atlas for production-ready cloud-based MongoDB instances.
We welcome contributions to this project! If you'd like to contribute, please follow these steps:
- Fork the repository.
- Create a feature branch (
git checkout -b feature/YourFeatureName
). - Commit your changes (
git commit -m 'Add some feature'
). - Push to the branch (
git push origin feature/YourFeatureName
). - Open a pull request.
Please ensure that your code follows the existing coding conventions and passes all tests before submitting a pull request.
This project is licensed under the MIT License. See the LICENSE file for details.