This API provides functionality for an online event booking system, allowing users to register, create events, book tickets, and leave reviews.
Follow these steps to deploy Talk to Ai:
-
Clone the Repository
git clone https://github.com/lewenbraun/event-test-task.git cd event-test-task -
Configure Environment
-
Copy the sample environment file:
cp .env.example .env
-
Update your
.envfile if necessary.
-
-
Start Docker Containers
Launch the application using Docker Compose:
docker compose up -d
-
Generate Application Key
Generate the Laravel application key:
docker compose exec ett-backend php artisan key:generate -
Run Migrations
Initialize the database schema with:
docker compose exec ett-backend php artisan migrate -
Run Seeder
Initialize the database schema with:
docker compose exec ett-backend php artisan db:seed
Base URL for all endpoints: http://localhost/api/v1
| Method | URL | Description | Requires Authentication |
|---|---|---|---|
POST |
http://localhost/api/v1/register |
Register a new user. | No |
POST |
http://localhost/api/v1/login |
Authenticate a user and get an authentication token. | No |
POST |
http://localhost/api/v1/logout |
Log out the user (invalidate the token). | Yes |
Authentication Endpoint Details:
POST http://localhost/api/v1/register- Description: Registers a new user in the system.
- Request Parameters (JSON Body):
name(string, required): The user's name.email(string, required): A unique email address for the user.password(string, required): The user's password (minimum 8 characters).password_confirmation(string, required): Confirmation of the password.
- Successful Response (201 Created):
{ "token": "authentication_token" }
POST http://localhost/api/v1/login- Description: Authenticates a user using their email and password.
- Request Parameters (JSON Body):
email(string, required): The user's email address.password(string, required): The user's password.
- Successful Response (200 OK):
{ "token": "authentication_token" }
POST http://localhost/api/v1/logout- Description: Logs out the currently authenticated user by invalidating their token.
- Request Parameters: None.
- Successful Response (204 No Content): Empty response body.
| Method | URL | Description | Requires Authentication |
|---|---|---|---|
GET |
http://localhost/api/v1/events |
Get a list of available events. | Yes |
POST |
http://localhost/api/v1/events/store |
Create a new event. | Yes |
POST |
http://localhost/api/v1/events/reserve |
Reserve a ticket for an event. | Yes |
Event Endpoint Details:
GET http://localhost/api/v1/events- Description: Returns a paginated list of events that are still available for booking (attendee limit not reached and event date/time is in the future).
- Request Parameters (Query Parameters):
page(integer, optional): The page number for pagination. Defaults to 1.per_page(integer, optional): The number of events per page. Defaults to 15.
- Successful Response (200 OK): A paginated list of event resources.
{ "data": [ { "id": 1, "user_id": 1, "title": "Event Title", "description": "Event Description", "date_and_time": "YYYY-MM-DD HH:MM:SS", "location": "Event Location", "price": "100.00", "attendee_limit": 50, "created_at": "YYYY-MM-DD HH:MM:SS", "updated_at": "YYYY-MM-DD HH:MM:SS" } // ... other events ], "first_page_url": "...", "from": 1, "last_page": 1, "last_page_url": "...", "links": [ ... ], "next_page_url": null, "path": "...", "per_page": 15, "prev_page_url": null, "to": 1, "total": 1 }
POST http://localhost/api/v1/events/store- Description: Creates a new event. The authenticated user is set as the event organizer.
- Request Parameters (JSON Body):
title(string, required): The title of the event.description(string, optional): A description of the event.date_and_time(datetime, required): The date and time of the event (format:YYYY-MM-DD HH:MM:SS).location(string, optional): The location of the event.price(numeric, optional): The price of the ticket.attendee_limit(integer, required): The maximum number of attendees for the event.
- Successful Response (201 Created):
{ "message": "Event created successfully", "event": { "id": 1, "user_id": 1, "title": "Event Title", "description": "Event Description", "date_and_time": "YYYY-MM-DD HH:MM:SS", "location": "Event Location", "price": "100.00", "attendee_limit": 50, "created_at": "YYYY-MM-DD HH:MM:SS", "updated_at": "YYYY-MM-DD HH:MM:SS" } }
POST http://localhost/api/v1/events/reserve- Description: Reserves a ticket for the specified event for the authenticated user. Booking is only possible if the attendee limit has not been reached and the event date/time is in the future.
- Request Parameters (JSON Body):
event_id(integer, required): The ID of the event to reserve a ticket for.
- Successful Response (200 OK):
{ "message": "Ticket reserved successfully" }
| Method | URL | Description | Requires Authentication |
|---|---|---|---|
GET |
http://localhost/api/v1/reviews/{eventId} |
Get reviews for a specific event. | Yes |
POST |
http://localhost/api/v1/reviews/add |
Add a review for an event. | Yes |
Review Endpoint Details:
GET http://localhost/api/v1/reviews/{eventId}- Description: Returns a list of reviews for the event with the specified ID, including the average rating.
- URL Parameters:
eventId(integer, required): The ID of the event.
- Request Parameters: None.
- Successful Response (200 OK):
{ "average_rating": 2.5, "reviews": [ { "id": 199, "name": "Dr. Raoul Hodkiewicz II", "rating": 3, "comment": "Exercitationem magni et autem et molestiae." }, { "id": 289, "name": "Kaycee Pfeffer", "rating": 2, "comment": null } ] }
POST http://localhost/api/v1/reviews/add- Description: Adds a review for an event on behalf of the authenticated user. A user can only leave a review if they have reserved a ticket for the event.
- Request Parameters (JSON Body):
event_id(integer, required): The ID of the event to add a review to.rating(integer, optional): The rating for the event (1-5).comment(string, optional): The review comment.
- Successful Response (201 Created):
{ "message": "Review added successfully", "review": { "id": 1, "name": "Username", "rating": 5, "comment": "Great event!" } }
This project is licensed under the MIT License.