Booking a show using Java 8 SpringBoot Application
- Java 8 (Pre-Install)
- Gradle (Pre-Install)
- H2 (Pre-Install)
- Spring Boot 2.7.2
- Lombok
- Download source code
- Run BookYourShowApplication.java click on the GREEN PLAY button on the springboot class highlighted in red circle.
- Follow the instruction to select ADMIN or BUYER role and follow the step according.
- Build a simple Java application for the use case of ‘Booking a Show’. The program must take input from command line.
- The program would setup available seats per show, allow buyers to select 1 or more available seats and buy/cancel tickets.
- The application shall cater to the below 2 types of users & their requirements - Admin and Buyer
- Admin – The users should be able to Setup and view the list of shows and seat allocations.
For the simplicity of system, the following assumptions was made while implementing the solution -
- Single User Model - No Concurrency as only One user will enter the command at console issue comman each time.
- Single Screen Theaters - No multiple screen handling for a theater has been done. However an option is given for future scope.
- Admin user can config max up to 10 seats for each show and max row in theater to be 26. Seat numbers are kept fixed in all theaters.
- No Payment flow used as there is no requirement from the scope
- Seat book first within the cancellation timing are having booking status as BOOKING_RESERVED
- No reset of booking seat status for any seat reserved until the springboot is restarted and in memory is wiped. This can be enhanced in future scope.
- I adopted using spring framework @Transactional to prevent dirty read and obey ACID within any process involving in each buyer booking and cancellation of the ticket.
- No Add command for ADMIN as the requirement is not clear in the given assignment screenshot
- We assumed Buyer will input the correct seat number that is within scope of this assignment, if incorrect entry is insert program will ignore them. eg. Z11
-
Setup <Show Number> <Number of Rows> <Number of seats per row> <Cancellation window in minutes> (To setup the number of seats per show)
-
View <Show Number> (To display Show Number, Ticket#, Buyer Phone#, Seat Numbers allocated to the buyer) Buyer – The users should be able retrieve list of available seats for a show
-
Availability <Show Number> (To list all available seat numbers for a show. E,g A1, F4 etc)
-
Book <Show Number> <Phone#> <Comma separated list of seats> (To book a ticket. This must generate a unique ticket # and display)
-
Cancel <Ticket#> <Phone#> (To cancel a ticket. See contraints in the section below) Select 1 or more seats , buy and cancel tickets.
-
Assume max seats per row is 10 and max rows are 26. Example seat number A1, H5 etc.
-
The “Add” command for admin must ensure rows cannot be added beyond the upper limit of 26.
-
After booking, User can cancel the seats within a time window of 2 minutes (configurable). Cancellation after that is not allowed.
-
Only one booking per phone# is allowed per show.
-
Implement the solution as Java standalone application (Java 8+). Can be Springboot as well. The data shall be in-memory.
-
Write appropriate Unit Tests.
-
Implement the above use case considering object oriented principles and development best practices. The implementation should be a tested working executable.
-
To add background scheduler job to scan all the records in the database for show_seat to change them from status BOOKING_RESERVED to BOOKING_CONFIRMED after cancellation time in minute is reach for each booking.
-
To add background scheduler job to scan all the record in the database for each end of day at a fixed timing to reset t all booking_status back to UNRESERVED so that buyer can book them the next time.
-
To add more on the fly interractive digraam on the cinema seating plan after any booking or cancelling of the ticket is done at real time.
-
To utilise of ORM hibernate mapping @JoinColumn to query 2 more more table at the same time instead of one query per table to fetch information from different table to reduce number of database call.