The Movie Booking Service is a REST API designed to handle movie booking operations for theaters. It allows users to add movies, associate them with theaters, view available seats, and book seats for a movie in a specific theater. The project is built using C++ with the Crow framework and utilizes Conan for dependency management. The API exposes multiple endpoints to manage movie-related operations, such as adding movies, listing available theaters, checking seat availability, and booking seats.
- Add movies to the system.
- Associate theaters with movies.
- Check seat availability for specific theaters.
- Book seats for movies.
- Expose a RESTful API for each operation.
- Conan for dependency management.
- C++17 for building the project.
- Crow (a modern C++ web framework).
- Make for building the project.
- Docker (Optional) for running service in a container.
src/
- Contains the main source code for the application.scripts/
- Contains bash scripts for testing the endpoints by simulating various operations such as adding movies, booking seats, etc.conanfile.txt
- Conan file for managing external dependencies like Crow.
To install the project dependencies using Conan, follow these steps:
python3 -m pip install --upgrade pip
python3 -m pip install conan
conan profile detect
make build
./bin/movie_booking_service
make run
The service will start and listen on port 8080.
docker build -t movie_booking_service:latest .
docker run -p 8080:8080 movie_booking_service
docker run -p 8080:8080 zezulinsky/movie_booking_service:latest
The scripts/
folder contains multiple bash scripts to test the API endpoints.
You can use these to interact with the movie booking service.
add_movies.sh
: Adds movies to the service.get_movies.sh
: Lists added movies.add_theaters.sh
: Add theaters for movies.get_theaters.sh
: Lists theaters showing a movie.show_available_seats.sh
: Shows available seats for a movie in a theater.book_seats.sh
: Books seats for a movie in a theater.
Use the add_movies.sh
script to add movies to the service.
This script sends a POST request to the /add_movie
endpoint to add multiple movies.
./scripts/add_movies.sh
Adding movie: The Godfather
Response: {"movieName":"The Godfather"}
------------------------------------
Adding movie: Schindler's List
Response: {"movieName":"Schindler's List"}
------------------------------------
Adding movie: Pulp Fiction
Response: {"movieName":"Pulp Fiction"}
------------------------------------
Adding movie: Fight Club
Response: {"movieName":"Fight Club"}
------------------------------------
Use the get_movies.sh
script to list all the added movies.
This script sends a GET request to the /movies
endpoint.
./scripts/get_movies.sh
[
{
"movieName": "The Godfather"
},
{
"movieName": "Schindler's List"
},
{
"movieName": "Pulp Fiction"
},
{
"movieName": "Fight Club"
}
]
Use the add_theaters.sh
script to associate theaters with movies.
This script sends a POST request to the /add_theaters_to_movie
endpoint for each movie.
./scripts/add_theaters.sh
Adding theaters to movie: Fight Club
Response: Theaters added for a movie
Adding theaters to movie: The Godfather
Response: Theaters added for a movie
Adding theaters to movie: Schindler List
Response: Theaters added for a movie
Adding theaters to movie: Pulp Fiction
Response: Theaters added for a movie
Use the get_theaters.sh
script to list all theaters playing a particular movie.
This script sends a POST request to the /movies/theaters
endpoint.
./scripts/get_theaters.sh
Schindler's List
[]
The Godfather
[
{
"theaterName": "The Vito Corleone Theater"
},
{
"theaterName": "The Family Cinema"
}
]
Pulp Fiction
[
{
"theaterName": "The Reservoir Dogs Theater"
},
{
"theaterName": "The Fiction Lounge"
}
]
Fight Club
[
{
"theaterName": "The Underground Theater"
},
{
"theaterName": "The Rebel Cinema"
}
]
To check available seats in a theater for a specific movie, use the show_available_seats.sh
script.
It interacts with the /movies/seats
endpoint
./scripts/show_available_seats.sh "Fight Club" "The Rebel Cinema"
Response for 'Fight Club' in 'The Rebel Cinema'
[
"a1", "a2", "a3", "a4", "a5", "a6", "a7", "a8", "a9", "a10",
"a11", "a12", "a13", "a14", "a15", "a16", "a17", "a18", "a19", "a20"
]
To book one or more seats for a movie in a particular theater, use the book_seats.sh
script.
The script sends a POST request to the /movies/book_seats
endpoint.
./scripts/book_seats.sh "Fight Club" "The Rebel Cinema" "a17" "a18"
Response for 'Fight Club' in 'The Rebel Cinema': Seats booked successfully.
After booking, you can run the show_available_seats.sh
script again to confirm the booking:
./scripts/show_available_seats.sh "Fight Club" "The Rebel Cinema"
Response for 'Fight Club' in 'The Rebel Cinema'
[
"a1", "a2", "a3", "a4", "a5", "a6", "a7", "a8", "a9", "a10",
"a11", "a12", "a13", "a14", "a15", "a16", "a19", "a20"
]
- Endpoint:
POST /add_movie
- Request:
{ "movieName": "The Matrix" }
- Response:
{ "movieName": "The Matrix" }
- Endpoint:
GET /movies
- Response:
[ { "movieName": "The Matrix" }, { "movieName": "Inception" } ]
- Endpoint:
POST /add_theaters_to_movie
- Request body:
{ "movieName": "The Matrix", "theaters": ["Theater 1", "Theater 2", "Theater 3"] }
- Response:
{ "movieName": "The Matrix", "theaters": [ { "theaterName": "Theater 1" }, { "theaterName": "Theater 2" }, { "theaterName": "Theater 3" } ] }
- Endpoint:
POST /movies/theaters
- Request body:
{
"movieName": "The Matrix"
}
- Response:
[
{
"theaterName": "Theater A"
},
{
"theaterName": "Theater B"
}
]
- Endpoint:
POST /movies/seats
- Request body:
{ "movieName": "The Matrix", "theaterName": "IMAX" }
- Response:
[
"a1", "a2", "a3", "a20"
]
- Endpoint:
POST /movies/book_seats
- Request body:
{ "movieName": "The Matrix", "theaterName": "IMAX", "seats": ["a10", "a11"] }
- Response:
{ "message": "Seats booked successfully." }
- Endpoint:
POST /movies/seats
- Request body:
{ "movieName": "The Matrix", "theaterName": "IMAX" }
- Response:
[
"a1", "a2", "a3", "a9", "a12", "a13", "a20"
]