A REST API to manage event bookings, allowing users to create, find, and reserve tickets for events, view and manage their reservations, and receive notifications before events start.
- User account creation and authentication
- Event creation, updating, deletion, and search
- Ticket reservation and management
- Notifications for upcoming events
- JDK 11+
- Maven 3.6+
-
Build the project:
mvn clean install
-
Compile the project:
mvn compile
-
Run the application:
mvn spring-boot:run
The application will be accessible at http://localhost:8080
.
If you prefer to use Docker, you can set up a containerized environment. Ensure you have Docker installed and running on your machine.
Access the API documentation at http://localhost:8080/documentation/swagger-ui/index.html#/
.
-
Run unit tests:
mvn test
-
Run integration tests:
mvn verify
Integration tests use PostgreSQLTestContainer to simulate the database environment.
The application uses H2 in-memory database for local development. Necessary reference data and dummy data are preloaded on startup.
For integration tests, PostgreSQLTestContainer is used to ensure the tests run in a controlled environment with data preloaded as needed.
- Application properties can be configured in
src/main/resources/application.properties
. - For test configurations, use
src/test/resources/application-test.properties
.
Here are some common CURL commands for the endpoints:
User Endpoints
- Create a new user:
curl -X POST "http://localhost:8080/api/v1/event-booking/users/" -H "Content-Type: application/json" -d '{"name":"Joy Osayi","email":"osayijoy17@gmail.com","password":"password"}'
- User login:
curl -X POST "http://localhost:8080/api/v1/event-booking/authentication/login" -H "Content-Type: application/json" -d '{"email":"osayijoy17@gmail.com","password":"password"}'
- Get user by email:
curl -X GET "http://localhost:8080/api/v1/event-booking/users/osayijoy17@gmail.com" H "Authorization: Bearer <access_token>" -H "Content-Type: application/json"
- Update user by email:
curl -X PUT "http://localhost:8080/api/v1/event-booking/users/osayijoy17@gmail.com" H "Authorization: Bearer <access_token>" -H "Content-Type: application/json" -d '{"name":"Updated Name"}'
- Get all users:
curl -X GET "http://localhost:8080/api/v1/event-booking/users/?page=1&size=10" H "Authorization: Bearer <access_token>" -H "Content-Type: application/json"
- Delete user by email:
curl -X DELETE "http://localhost:8080/api/v1/event-booking/users/osayijoy17@gmail.com"H "Authorization: Bearer <access_token>"
Event Endpoints
- Create a new event:
curl -X POST "http://localhost:8080/api/v1/event-booking/events/" H "Authorization: Bearer <access_token>" -H "Content-Type: application/json" -d '{"name":"Conference","date":"2024-07-15T10:00:00","availableAttendeesCount":100,"description":"Tech Conference","category":"CONCERT"}'
- Update event by id:
curl -X PUT "http://localhost:8080/api/v1/event-booking/events/1" H "Authorization: Bearer <access_token>" -H "Content-Type: application/json" -d '{"name":"Updated Conference Name"}'
- Get event by id:
curl -X GET "http://localhost:8080/api/v1/event-booking/events/1" H "Authorization: Bearer <access_token>" -H "Content-Type: application/json"
- Get all events with filters:
curl -X GET "http://localhost:8080/api/v1/event-booking/events/?name=conference&startDate=2024-07-15&endDate=2024-07-20&category=CONCERT&page=1&size=10" H "Authorization: Bearer <access_token>" -H "Content-Type: application/json"
- Delete event by id:
curl -X DELETE "http://localhost:8080/api/v1/event-booking/events/1" H "Authorization: Bearer <access_token>"
Reservation Endpoints
- Reserve a ticket for an event:
curl -X POST "http://localhost:8080/api/v1/event-booking/reservations/" H "Authorization: Bearer <access_token>" -H "Content-Type: application/x-www-form-urlencoded" -d "eventId=1&email=osayijoy17@gmail.com&attendeesCount=1"
- Get all reservations for a user:
curl -X GET "http://localhost:8080/api/v1/event-booking/reservations/user/osayijoy17@gmail.com?page=1&size=10" H "Authorization: Bearer <access_token>"
- Get all reservations for an event:
curl -X GET "http://localhost:8080/api/v1/event-booking/reservations/event/1?page=1&size=10" H "Authorization: Bearer <access_token>"
- Get a reservation by event id and user email:
curl -X GET "http://localhost:8080/api/v1/event-booking/reservations/event/1/osayijoy17@gmail.com" H "Authorization: Bearer <access_token>"
- Cancel a reservation by reservation id:
curl -X DELETE "http://localhost:8080/api/v1/event-booking/reservations/1" H "Authorization: Bearer <access_token>"