This project is a reservation management application that allows users to make and manage accommodation reservations. The application includes features such as reservation statistics calculation and profit maximization.
- Project Structure
- Technologies Used
- Methodologies
- How to Run the Application
- How to Deploy with Docker
- How to Run Tests
- API Documentation
- Contributions
- License
The project follows a hexagonal architecture (Ports and Adapters) and is designed under the principles of Domain-Driven Design (DDD) with main folders for different components:
src/main/java/org/main/booking
: Contains the application source code.application
: Includes application logic and services.domain
: Defines the domain model and entities.adapter
: Contains application adapters, such as controllers and repositories.config
: Application configurations.
src/test
: Contains unit tests.src/main/resources
: Contains resources, such as configuration files.
- Java
- Spring Boot
- Lombok
The development of this project follows the following methodologies:
-
Agile Methodology (Scrum): Agile practices have been employed for iterative and incremental development, allowing adaptation to changes and continuous delivery of value to the client.
-
Test-Driven Development (TDD): TDD practices have been followed to ensure adequate test coverage and improve code quality.
-
The hexagonal architecture: also known as Ports and Adapters, organizes a system into independent layers, allowing the separation of business logic from external code, thereby facilitating adaptability and testing.
-
Domain-Driven Design (DDD): is a software design methodology that focuses on understanding and modeling the problem domain to develop more effective solutions aligned with business needs.
- Clone the repository:
git clone https://github.com/your-username/code-challenge-hotel
- Navigate to the project directory:
cd stayForLong
- Run the application:
./mvnw spring-boot:run
The application will be available at http://localhost:8080.
The Swagger UI is available at http://localhost:8080/swagger-ui.html. You can use this interface to visualize and interact with the API endpoints.
The Swagger JSON file, which describes the API, can be found at http://localhost:8080/v2/api-docs.
- Endpoint:
POST /stats
- This endpoint calculates and returns the average, minimum, and maximum profit per night based on the provided booking requests.
Example Request:
[
{
"request_id": "booking_request_1",
"check_in": "2022-03-01",
"nights": 3,
"selling_rate": 150,
"margin": 15
},
{
"request_id": "booking_request_2",
"check_in": "2022-03-05",
"nights": 2,
"selling_rate": 120,
"margin": 10
}
]
{
"avg_night": 12.67,
"min_night": 10.5,
"max_night": 15
}
- Endpoint:
POST /maximize
- This endpoint identifies the best combination of booking requests to maximize total profits.
Example Request:
[
{
"request_id": "booking_request_1",
"check_in": "2022-03-01",
"nights": 3,
"selling_rate": 150,
"margin": 15
},
{
"request_id": "booking_request_2",
"check_in": "2022-03-05",
"nights": 2,
"selling_rate": 120,
"margin": 10
}
]
{
"request_ids": ["booking_request_1", "booking_request_2"],
"total_profit": 78,
"avg_night": 13,
"min_night": 12,
"max_night": 15
}
To run tests, use the following command:
./mvn test