Open In App

Design a movie ticket booking system like Bookmyshow

Last Updated : 03 May, 2024
Improve
Improve
Like Article
Like
Save
Share
Report

We need to design an online Movie ticket booking system where a user can search for a movie in a given city and book it. This article will explain to you the architecture and implementation of the booking system.

Requirements of a movie ticket booking system

  • User Registration and Authentication: Users should be able to register with the system.
  • Movie Listings: Display a list of movies currently playing in theaters.
  • Seat Selection and Reservation: Interactive seat map allowing users to select seats. Real-time updates on seat availability.
  • Booking Process: Seamless booking flow with step-by-step guidance.
  • Payment Processing: Integration with multiple payment gateway. Secure handling of payment information.
  • Cancellation and Refund: Allow users to cancel bookings within a certain time frame.
  • Performance: Fast response times for browsing movies and booking tickets. Scalability to handle a large number of users concurrently, especially during peak hours.
  • Reliability: High availability of the system

How do we implement the seat booking process?

Let us see how we can implement the seat booking process. The Main Classes to be used for the users are: 

  1. User
  2. Movie
  3. Theater
  4. Booking
  5. Address
  6. Facilities
Java
// Java skeleton code to design an online movie
// booking system.
Enums :

public enum SeatStatus {
    SEAT_BOOKED,
    SEAT_NOT_BOOKED;
}

public enum MovieStatus {
    Movie_Available,
    Movie_NotAvailable;
}

public enum MovieType {
    ENGLISH,
    HINDI;
}

public enum SeatType {
    NORMAL,
    EXECUTIVE,
    PREMIUM,
    VIP;
}

public enum PaymentStatus {
    PAID,
    UNPAID;
}

class User {

    int userId;
    String name;
    Date dateOfBirth;
    String mobNo;
    String emailId;
    String sex;
}

class Movie {

    int movieId;
    int theaterId;
    MovieType movieType;
    MovieStatus movieStatus;
}

class Theater {

    int theaterId;
    String theaterName;
    Address address;

    List<Movie> movies;
    float rating;
}

class Booking {
    int bookingId;
    int userId;
    int movieId;
    List<Movie> bookedSeats;
    int amount;
    PaymentStatus status_of_payment;
    Date booked_date;
    Time movie_timing;
}

class Address {

    String city;
    String pinCode;
    String state;
    String streetNo;
    String landmark;
}

This is the pseudo implementation of the above logic. The above code has classes and attributes only. As you can see enums are self-explanatory. 

Below is the explanation of the classes used in the above code:

  • We have a Movie class which keeps all the details of the movies.
  • We have users class in which users details are kept. 
  • Theater class in which name of the theater, it’s address and list of movies currently running are kept. 
  • Booking class lets you book the seat in a particular theater. It keeps a reference in Movie, Payment class.
  • We have Address class which the details of the user(city, pin code, State) are kept.
     

How to handle those cases where more than one person tries to access the same seat simultaneously?

Lets take SeatBook and Transactions class which will be called from the main class. Here from the above code, We expand a bit the payment process which is not shown in the above code. In SeatBook class we will have reference to Transaction class also.

Now to ensure when two persons are trying to access the same seat almost at the same time then we would use Synchronized method of Thread class and will call a thread belong to each log in user. Let us see how it works:

Java
Class SeatBook
{
    Transaction transaction_obj;
    bool seats[total_seats];
    String place;
    String ticketType;

    bool check_availability();

    int  position_of_seat()
    {
        return seat_pos_in_theater;
    }

    void multiple tickets();

    void final_booking()
    {
        place = positon_of_seat();
        if (single_ticket)
            continue;
        else
            mutliple_ticket_booking();

        Transaction_obj.pay(ticketType, seats_booked, place);
    }
}




Like Article
Suggest improvement
Share your thoughts in the comments

Similar Reads