A REST API built with PHP 8.3 and Symfony components for managing booking statistics and maximizing booking profits.
- Calculate booking statistics (average, minimum, and maximum profits per night)
- Find optimal booking combinations to maximize total profit
- CQRS and DDD architectural patterns
- Built with PHP 8.3
- Docker ready
- The application runs on port
8089
to avoid collision with other common ports.
- Docker and Docker Compose
- Git
You can test the endpoints using either:
- Postman - GUI tool for API testing
- cURL - Command-line tool for HTTP requests
- Clone the repository
git clone https://github.com/dgineblasco/booking-api.git
- Build and start Docker containers
docker compose up -d
- Install dependencies
docker exec -it booking-api composer install
- Run phpunit tests
docker exec -it booking-api vendor/bin/phpunit
curl -X POST http://localhost:8089/stats \
-H "Content-Type: application/json" \
-d '[
{
"request_id": "1",
"check_in": "2026-01-01",
"nights": 2,
"selling_rate": 100,
"margin": 10.5
}
]'
Response:
{
"average": 5.25,
"minimum": 5.25,
"maximum": 5.25
}
curl -X POST http://localhost:8089/maximize \
-H "Content-Type: application/json" \
-d '[
{
"request_id": "A",
"check_in": "2026-01-01",
"nights": 5,
"selling_rate": 1000,
"margin": 10
},
{
"request_id": "B",
"check_in": "2026-01-03",
"nights": 5,
"selling_rate": 700,
"margin": 10
},
{
"request_id": "C",
"check_in": "2026-01-07",
"nights": 5,
"selling_rate": 400,
"margin": 10
}
]'
Response:
{
"request_ids": ["A", "C"],
"total_profit": 140,
"avg_night": 14,
"min_night": 8,
"max_night": 20
}