A Django REST Framework-based ticket booking system for events.
- Event management (create, update, list, delete events)
- Ticket booking system
- User authentication
- Role-based access control (admin and customer)
- Filtering and searching events
- Swagger documentation
- Docker
- Docker Compose
-
Clone the repository
-
Run the application:
docker-compose up --build
-
Generate sample data:
docker-compose exec web python manage.py generate_sample_data
The application will be available at http://localhost:53801
-
Admin user:
- Username: admin
- Password: admin123
-
Sample users:
- Username: user0, user1, user2, user3, user4
- Password: user123
API documentation is available at:
- Swagger UI: http://localhost:53801/swagger/
- ReDoc: http://localhost:53801/redoc/
- List Events
curl -X GET http://localhost:53801/api/events/- Create Event (Admin only)
curl -X POST http://localhost:53801/api/events/ \
-H "Content-Type: application/json" \
-H "Authorization: Bearer <token>" \
-d '{
"title": "Summer Concert",
"description": "Annual summer concert",
"date": "2025-06-15T18:00:00Z",
"location": "Central Park",
"total_tickets": 100,
"price": "50.00"
}'- Update Event (Admin only)
curl -X PUT http://localhost:53801/api/events/1/ \
-H "Content-Type: application/json" \
-H "Authorization: Bearer <token>" \
-d '{
"title": "Updated Summer Concert",
"description": "Updated description",
"date": "2025-06-15T18:00:00Z",
"location": "Central Park",
"total_tickets": 100,
"price": "50.00"
}'- List My Bookings
curl -X GET http://localhost:53801/api/bookings/ \
-H "Authorization: Bearer <token>"- Create Booking
curl -X POST http://localhost:53801/api/bookings/ \
-H "Content-Type: application/json" \
-H "Authorization: Bearer <token>" \
-d '{
"event": 1,
"number_of_tickets": 2
}'- Update Booking
curl -X PUT http://localhost:53801/api/bookings/1/ \
-H "Content-Type: application/json" \
-H "Authorization: Bearer <token>" \
-d '{
"number_of_tickets": 3
}'- Cancel Booking
curl -X DELETE http://localhost:53801/api/bookings/1/ \
-H "Authorization: Bearer <token>"- Create, read, update, and delete events
- Filter events by date and location
- Search events by title and description
- Sort events by date and price
- Create, read, update, and cancel bookings
- Automatic price calculation
- Ticket availability tracking
- Booking status management (Pending, Confirmed, Cancelled)
- Two user roles: Admin and Customer
- Admins can manage events
- Customers can book tickets
- Users can view their booking history
- Role-based access control
- Token-based authentication
- Transaction management for booking operations
- Input validation and sanitization