Skip to content

hamidfarmani/ticketmaster-clone

Repository files navigation

Ticketmaster Clone

A robust Spring Boot application that implements a ticket booking system similar to Ticketmaster, featuring real-time seat reservations, booking management, and event handling.

Features

  • Event Management

    • Create, update, and manage events
    • Configure event capacity and pricing
    • Categorize seats (VIP, General, Balcony)
  • Seat Reservation System

    • Real-time seat availability tracking
    • Temporary seat reservations with timeout
    • Optimistic and pessimistic locking for concurrent access
    • Redis-based distributed locking
  • Booking Management

    • Secure booking process
    • Booking status tracking
    • Booking cancellation support
    • User-specific booking history
  • User Management

    • User registration and authentication
    • JWT-based security
    • Role-based access control
  • Technical Features

    • Distributed locking using Redis
    • Optimistic and pessimistic concurrency control
    • Scheduled cleanup of expired reservations
    • Email notifications
    • RESTful API design

Technology Stack

  • Backend Framework: Spring Boot 3.x
  • Database: PostgreSQL
  • Caching: Redis
  • Security: Spring Security with JWT
  • ORM: Spring Data JPA
  • Build Tool: Maven
  • Java Version: 21

Prerequisites

  • Java 21 or later
  • PostgreSQL
  • Redis
  • Maven

Configuration

The application can be configured through application.properties:

# Database Configuration
spring.datasource.url=jdbc:postgresql://localhost:5432/ticketmaster-clone
spring.datasource.username=myuser
spring.datasource.password=mypass

# Redis Configuration
spring.data.redis.host=localhost
spring.data.redis.port=6379

# JWT Configuration
jwt.secret=your-secret-key
jwt.expiration=86400000

# Server Configuration
server.port=8080

# Mail Configuration
spring.mail.host=smtp.gmail.com
spring.mail.port=587
spring.mail.username=your-email@gmail.com
spring.mail.password=your-app-specific-password

Running the Application

  1. Clone the repository
  2. Configure the application properties
  3. Start PostgreSQL and Redis
  4. Run the application:
    mvn spring-boot:run

API Endpoints

Events

  • GET /api/events - List all events
  • GET /api/events/{id} - Get event details
  • POST /api/events - Create new event
  • PUT /api/events/{id} - Update event
  • DELETE /api/events/{id} - Delete event

Seats

  • GET /api/events/{eventId}/seats - List available seats
  • GET /api/events/{eventId}/seats/{category} - List seats by category

Reservations

  • POST /api/reservations - Create seat reservation
  • DELETE /api/reservations/{id} - Cancel reservation
  • GET /api/reservations/user/{userId} - Get user's reservations

Bookings

  • POST /api/bookings - Create booking
  • DELETE /api/bookings/{id} - Cancel booking
  • GET /api/bookings/user/{userId} - Get user's bookings

Concurrency Handling

The application implements several concurrency control mechanisms:

  1. Pessimistic Locking

    • Used for seat reservations to prevent double-booking
    • Ensures atomic operations on critical resources
  2. Optimistic Locking

    • Implemented using JPA versioning
    • Handles concurrent updates to events and bookings
  3. Distributed Locking

    • Redis-based locking for distributed environments
    • Prevents race conditions in seat reservations
  4. Transaction Management

    • All critical operations are wrapped in transactions
    • Ensures data consistency

Contributing

  1. Fork the repository
  2. Create your feature branch
  3. Commit your changes
  4. Push to the branch
  5. Create a new Pull Request

License

This project is licensed under the MIT License - see the LICENSE file for details.

About

A Spring boot application, showcasing different locks that can be implemented in a Ticketmaster clone.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages