A robust Spring Boot application that implements a ticket booking system similar to Ticketmaster, featuring real-time seat reservations, booking management, and event handling.
-
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
- 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
- Java 21 or later
- PostgreSQL
- Redis
- Maven
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
- Clone the repository
- Configure the application properties
- Start PostgreSQL and Redis
- Run the application:
mvn spring-boot:run
GET /api/events
- List all eventsGET /api/events/{id}
- Get event detailsPOST /api/events
- Create new eventPUT /api/events/{id}
- Update eventDELETE /api/events/{id}
- Delete event
GET /api/events/{eventId}/seats
- List available seatsGET /api/events/{eventId}/seats/{category}
- List seats by category
POST /api/reservations
- Create seat reservationDELETE /api/reservations/{id}
- Cancel reservationGET /api/reservations/user/{userId}
- Get user's reservations
POST /api/bookings
- Create bookingDELETE /api/bookings/{id}
- Cancel bookingGET /api/bookings/user/{userId}
- Get user's bookings
The application implements several concurrency control mechanisms:
-
Pessimistic Locking
- Used for seat reservations to prevent double-booking
- Ensures atomic operations on critical resources
-
Optimistic Locking
- Implemented using JPA versioning
- Handles concurrent updates to events and bookings
-
Distributed Locking
- Redis-based locking for distributed environments
- Prevents race conditions in seat reservations
-
Transaction Management
- All critical operations are wrapped in transactions
- Ensures data consistency
- Fork the repository
- Create your feature branch
- Commit your changes
- Push to the branch
- Create a new Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.