This is the online movie ticket booking platform to caters both B2B (theatre partners) and B2C (end customers) clients for managing shows and booking ticket for the shows respectively.
Currently, it's implemented with below functionalities:
- Browse theatres currently running the show (movie selected) in the town, including show timing by a chosen date. We have implemented
SearchinShowController.javafor the same. - Theatres can create, update, and delete shows for the day. We have implemented crud operations in
ShowController.java.
1. Clone the repository
git clone https://github.com/rajeshdave/TicketBooking.git2. How to Run
You may package the application in the form of a jar and then run the jar file like so -
mvn clean package
java -jar target/TicketBooking-0.0.1-SNAPSHOT.jarThat's it! The application can be accessed at http://localhost:4000/show/search?city=Pune&movie=RRR&date=2022-04-05.
After starting application, access swagger UI at below:
http://localhost:4000/swagger-ui/index.html
Access swagger api docs at below:
http://localhost:4000/v3/api-docs/
curl --location --request
GET 'localhost:4000/show/search?city=Pune&movie=RRR&date=2022-04-05'
curl --location --request POST 'localhost:4000/show/' \
--header 'Content-Type: application/json' \
--data-raw '{
"fromTime": "2022-04-05T16:00:00",
"toTime": "2022-04-05T18:30:00",
"theatreScreenId": 1,
"movieId": 1
}'
curl --location --request GET 'localhost:4000/show/25'
curl --location --request PUT 'localhost:4000/show/25' \
--header 'Content-Type: application/json' \
--data-raw '{
"fromTime": "2022-04-05T16:30:00",
"toTime": "2022-04-05T18:30:00",
"theatreScreenId": 1,
"movieId": 1
}'
curl --location --request DELETE 'localhost:4000/show/25'
This is Spring boot application using Spring Boot v2.6.6.
TicketBookingApplication.javais Spring boot application class.ShowController.javais REST controller to handle all requests.ShowService.javais service layer to interact with JPA Repository.ShowRepository.javais the JPA Repository to interact with Database.ExceptionHandlerController.javais for handling all exceptions.ResourceNotFoundExceptionis custom exception. Further,ErrorCodesandErrorResponseto have standard common Error codes and Error Responses for teh Application.MDCFilter.javais to add unique Request id in MDC Context for each of the REST request.
Below are test cases added to test the code:
TicketBookingApplicationIT.javafor doing end to end integration tests by using RestTemplate. This cover testcases for both successful and exception scenarios.ShowControllerTest.javais to add Junit testcases for ShowController.
Below are motivations behind given design of application:
- Clean code
- Single Responsibility by layered design. Like
ShowController,ShowService,ShowRepositoryetc. - Isolation by use of Interfaces.
- Global Exception handling with REST standard error response.
- Unit and integration Test cases with nearly 100% Code coverage.
- No issue based on Sonar analysis.
- For more details please refer javadoc of each class.
“It is not enough for code to work.” ― Robert C. Martin, Clean Code: A Handbook of Agile Software Craftsmanship