A Spring Boot backend RESTful web service that handles movie theater seating reservations, ticket purchasing, ticket refunds/returns, and real-time administrative statistics.
- Base Server URL:
http://localhost:28852 - Seating Capacity: 9 rows × 9 columns (81 total seats)
- Ticket Pricing:
- Rows 1 – 4:
$10 - Rows 5 – 9:
$8
- Rows 1 – 4:
- Tech Stack: Java 17+, Spring Boot 3, Gradle, Jackson JSON
- JDK 17 or higher installed and set in your
JAVA_HOME. - Gradle (or use the included Gradle wrapper).
To ensure the server starts on port 28852, verify that your src/main/resources/application.properties includes:
server.port=28852Open a terminal in the project root directory and run:
Linux / macOS:
./gradlew bootRunWindows (Command Prompt / PowerShell):
gradlew.bat bootRun
Alternatively, build the executable JAR and run it directly specifying the port:
./gradlew build
java -jar build/libs/cinema-rest-service-1.0.jar --server.port=28852Once started, the service will be listening at:
Returns the cinema layout and a list of all currently available seats with their respective prices.
-
Method: GET
-
Response (200 OK):
{
"rows": 9,
"columns": 9,
"seats": [
{
"row": 1,
"column": 1,
"price": 10
},
{
"row": 1,
"column": 2,
"price": 10
}
]
}Reserves a seat if available and generates a unique UUID token for the buyer.
-
Method: POST
-
Headers: Content-Type: application/json
-
Request Body:
{
"row": 3,
"column": 5
}- Response (200 OK):
{
"token": "d290f1ee-6c54-4b01-90e6-d701748f0851",
"ticket": {
"row": 3,
"column": 5,
"price": 10
}
}Cancels a booking using the ticket token provided during purchase and releases the seat back to the available pool.
-
Method: POST
-
Headers: Content-Type: application/json
-
Request Body:
{
"token": "d290f1ee-6c54-4b01-90e6-d701748f0851"
}- Response (200 OK):
{
"ticket": {
"row": 3,
"column": 5,
"price": 10
}
}Fetches financial metrics and current occupancy counts. Requires admin password authentication via a query parameter.
-
Method: GET
-
Query Parameter: password (Default: super_secret)
-
Response (200 OK):
{
"income": 10,
"available_seats": 80,
"purchased_tickets": 1
}When an error occurs, the API responds with an appropriate HTTP status code and a JSON error message:
| Scenario | HTTP Status | Response Payload |
|---|---|---|
| Seat out of bounds (e.g. row 10, col 0) | 400 Bad Request |
{"error": "The number of a row or a column is out of bounds!"} |
| Seat already booked | 400 Bad Request |
{"error": "The ticket has been already purchased!"} |
| Invalid/Wrong Token on Return | 400 Bad Request |
{"error": "Wrong token!"} |
Wrong Admin Password on /stats |
401 Unauthorized |
{"error": "Wrong password!"} |