Skip to content

pranaybankar/ticketing_system

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

25 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Theater Ticket Booking System

This project is a theater ticket booking system with FastAPI, SQLAlchemy, and Redis. It provides functionality for checking available seats, booking seats, and temporarily reserving seats with an expiry time.

Features

  • Check available theaters.
  • Check available seats in a theater.
  • Book a seat (idempotent operation).
  • Temporarily reserve a seat with an expiry time.
  • Caching for seat availability. We will cache only those object which are not booked.

Requirements

  • Docker
  • Docker Compose

Setting Up the Project

  1. Clone the Repository:

    git clone [email protected]:pranaybankar/ticketing_system.git
    cd theater_booking
  2. Build and Run the Docker Containers:

    • The data is already feeded in SQLITE DB, if you want to update the data please add it in app/data/theaters.json and app/data/seats.json before running the below commnads.
    docker-compose up --build
  3. Access the Application:

  4. API Endpoints:

    • GET /theaters: Retrieves all theater information.
    • GET /theaters/{theaterId}/seats: Retrieves the current availability of seats for a specified theater.
    • POST /theaters/{theaterId}/book: Books a seat for a specified theater.
    • POST /theaters/{theaterId}/reserve: Temporarily reserves a seat for a specified theater with an expiry time of five minutes.
  5. How to use the API Endpoints:

    • To try any API click on the Try it out button.image
    • GET /theaters: Run this first to retrieves all theatre information. Using this you get to know the Theatre id and name. image
    • GET /theaters/{theaterId}/seats: Using the information from the earlier API you can check how many seats are available in the particular theatre. So, you can retrieve the current availability of seats for a specified theatre. So, you will get the id, seat_number, is_booked and theater_id. image image
    • POST /theaters/{theaterId}/reserve: To temporarily reserves a seat for a specified theatre provide the Theatre id and the seat number from the earlier API. The seat will be reserved for 5 mins to book. If you make a mistake in providing the seat number the API will return the available seat numbers. Note: You need to provide the theatre_id as a path parameter and seat_number as a body payload parameter.image image
    • POST /theaters/{theaterId}/book: Now to book your ticket specify the Theatre Id and the seart number to books a seat for the specified theatre. If you make a mistake in providing the seat number the API will return the available seat numbers. Note: You need to provide the theatre_id as a path parameter and seat_number as a body payload parameter. image image
  6. Stopping the Containers:

    docker-compose down

Notes

  • Ensure Docker and Docker Compose are installed on your machine.
  • The application uses Sqlite as the database and Redis for caching.
  • I have used Swagger UI to interact with the APIs.
  • You can update the RESERVATION_TIMEOUT in docker-compose.yml file.

This setup ensures your theater ticket booking system is containerized, easy to deploy, and scalable.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published