This Rails API serves as the backend for the Festival Scheduler application. It allows users to view, manage, and interact with festival shows and schedules. The API provides endpoints for managing shows, user schedules, and admin functionalities.
This solo project was fully created in under 16 hours, including front end, as part of a take-home challenge
The Festival Scheduler Backend is a RESTful API that:
- Manages shows, users, and user schedules.
- Supports many-to-many relationships between users and shows.
- Provides a clean and scalable API design for frontend interaction.
This diagram outlines the database schema and relationships:
- Users: Represents festival-goers.
- Shows: Represents scheduled performances.
- UsersShows: A join table for managing the many-to-many relationship between users and shows.
- Ruby: 3.2.0
- Rails: 7.1+
- PostgreSQL
- Start the Rails server:
rails server
- The API will be available at
http://localhost:3000
.
- Fetch all shows
Endpoint:GET /api/v1/shows
Description: Retrieves a list of all festival shows.
Example Response:[ { "id": 1, "artist": "The Lumineers", "location": "Main Stage", "time_slot": 1, "image_url": "https://example.com/show1.jpg" } ]
-
Fetch a user's schedule
Endpoint:GET /api/v1/users/:user_id/shows
Description: Retrieves all shows in the user's schedule.
Example Response:[ { "id": 1, "artist": "The Lumineers", "location": "Main Stage", "time_slot": 1, "image_url": "https://example.com/show1.jpg" } ]
-
Add a show to a user's schedule
Endpoint:POST /api/v1/users/:user_id/shows
Request Body:{ "show_id": 1 }
Example Response:
{ "id": 1, "artist": "The Lumineers", "location": "Main Stage", "time_slot": 1, "image_url": "https://example.com/show1.jpg" }
-
Remove a show from a user's schedule
Endpoint:DELETE /api/v1/users/:user_id/shows/:id
Example Response:{ "message": "Show successfully removed from schedule" }
- Fetch all user schedules
Endpoint:GET /api/v1/users/shows
Description: Returns all users and their schedules.
Example Response:[ { "user_id": 1, "username": "johndoe", "schedule": [ { "id": 1, "artist": "The Lumineers", "location": "Main Stage", "time_slot": 1, "image_url": "https://example.com/show1.jpg" } ] } ]
-
Database Design:
- A normalized schema ensures scalability:
users
table for user details.shows
table for festival details.users_shows
join table for many-to-many relationships.
- A normalized schema ensures scalability:
-
Error Handling:
- Custom error handling using
ErrorSerializer
for consistent error messages. - Handles edge cases like duplicate schedules or invalid IDs.
- Custom error handling using
-
RESTful Routes:
- Follows RESTful principles for intuitive and scalable API design.
-
Validation:
- Validates the presence of required fields (e.g.,
username
,artist
). - Ensures no duplicate schedule entries for a user.
- Validates the presence of required fields (e.g.,
- Backend:
- Ruby on Rails
- PostgreSQL
- Testing:
- RSpec for unit and integration tests.
- Analytics Dashboard:
- Add insights for admins, such as most attended shows or busiest time slots.
- Permissions and Roles:
- Implement user roles for admins and general users.
- Batch Operations:
- Allow bulk additions or removals of shows for a user.
- Run RSpec tests:
bundle exec rspec
- Example test cases include:
- Validations for
User
andShow
models. - API request specs for endpoints.
- Validations for