This assignment aims to develop a RESTful API for a movie ticket booking system using PostgreSQL and Spring Boot. The system will manage movies, showtimes, users, and ticket bookings.
- Java 17
- PostgreSQL
- Maven
movieticketbooking
│── src
│ ├── main
│ │ ├── java
│ │ │ ├──/org/example/movieticketbooking
│ │ │ │ ├── controller
│ │ │ │ │ ├── MovieController.java
│ │ │ │ │ ├── ShowtimeController.java
│ │ │ │ │ ├── TicketController.java
│ │ │ │ │ ├── UserController.java
│ │ │ │ ├── service
│ │ │ │ │ ├── MovieService.java
│ │ │ │ │ ├── ShowtimeService.java
│ │ │ │ │ ├── TicketService.java
│ │ │ │ │ ├── UserService.java
│ │ │ │ ├── repository
│ │ │ │ │ ├── MovieRepository.java
│ │ │ │ │ ├── ShowtimeRepository.java
│ │ │ │ │ ├── TicketRepository.java
│ │ │ │ │ ├── UserRepository.java
│ │ │ │ ├── model
│ │ │ │ │ ├── Movie.java
│ │ │ │ │ ├── Showtime.java
│ │ │ │ │ ├── Ticket.java
│ │ │ │ │ ├── User.java
│ │ │ │ ├── MovieticketbookingApplication.java
│ │ ├── resources
│ │ │ ├── application.properties
│ ├── test
│ │ ├── java/org/example/movieticketbooking/service
│ │ │ ├── ShowtimeServiceTest.java
│ │ │ ├── TicketServiceTest.java
│── pom.xml
Installing Postgres Database using Homebrew
brew install postgresql
This will fetch the latest version of Postgres from the repository and get it installed on your machine.
To start the service to be available for use, use the command as follows to start running the service:
brew services start postgresql
Once the PostgreSQL server is up and running, the next step is configuring it. We are going to create a root user that will have administrator privileges to the database server.
psql postgres
Now you're logged into the postgres service and ready to execute PGSQL commands:
CREATE ROLE newuser WITH LOGIN PASSWORD ‘password’;
ALTER ROLE newuser CREATEDB;
CREATE DATABASE movieticketbooking;
\c movieticketbooking
Some command:
\l - List all databases.
\dt - List database tables.
\c <database-name> - connect to a Database.
\d <table-name> - Describe a table.
git clone https://github.com/Yuda4/Movie-Ticket-Booking-System.git
cd movieticketbooking
mvn clean install
mvn spring-boot:run
After project is running, you can enter to Swagger-UI from here and play with the API:
http://localhost:8080/swagger-ui/index.html#/
- Open Postman or use curl.
- Make a POST request to:
http://localhost:8080/movies for movies.
http://localhost:8080/showtimes for showtimes.
http://localhost:8080/tickets/book for ticket bookings.
http://localhost:8080/users for users.
- Use the JSON as the request body, examples below.
- Verify by making GET requests to:
http://localhost:8080/api/movies
http://localhost:8080/api/showtimes
http://localhost:8080/users/{id}
- In order to delete a ticket, make a DELETE request to:
http://localhost:8080/tickets/cancel/{ticketId}
{ "movie": { "id": 1 }, "theater": "IMAX Theater 1", "startTime": "2025-03-12T14:00:00", "endTime": "2025-03-12T16:30:00" }
{ "movie": { "id": 2 }, "theater": "IMAX Theater 1", "startTime": "2025-03-12T17:00:00", "endTime": "2025-03-12T19:30:00" }
{ "movie": { "id": 3 }, "theater": "Cinema Hall 3", "startTime": "2025-03-13T18:00:00", "endTime": "2025-03-13T21:00:00" }
{ "movie": { "id": 4 }, "theater": "Classic Cinema 5", "startTime": "2025-03-14T20:00:00", "endTime": "2025-03-14T23:15:00" }
{ "movie": { "id": 1 }, "theater": "IMAX Theater 1", "startTime": "2025-03-18T14:00:00", "endTime": "2025-03-18T16:30:00" }
{ "title": "Inception", "genre": "Sci-Fi", "duration": 148, "rating": 8.8, "releaseYear": 2010 }
{ "title": "The Dark Knight", "genre": "Action", "duration": 152, "rating": 9.0, "releaseYear": 2008 }
{ "title": "Interstellar", "genre": "Sci-Fi", "duration": 169, "rating": 8.6, "releaseYear": 2014 }
{ "title": "Titanic", "genre": "Romance", "duration": 195, "rating": 7.9, "releaseYear": 1997 }
{ "showtime": { "id": 1, "movie": { "id": 1 } }, "user": { "id": 1 }, "seatNumber": 12, "price": 15.50 }
{ "showtime": { "id": 2, "movie": { "id": 2 } }, "user": { "id": 5 }, "seatNumber": 8, "price": 17.00 }
{ "email": "yehduan@gmail.com", "name": "Yehuda N" }
{ "email": "tomb@gmail.com", "name": "Tom B" }
{ "email": "jerryc@gmail.com", "name": "Jerry C" }



