The DJ Tip App provides a comprehensive REST API for managing events, users, and performers. All API endpoints are versioned and return JSON responses.
Base URL: http://localhost:3000/api/v1
Currently, the API does not require authentication. All endpoints are publicly accessible.
All API requests and responses use application/json content type.
The API returns consistent error responses:
{
"error": "Error description",
"details": ["Specific error messages"]
}Common HTTP status codes:
200- Success201- Created204- No Content (for successful deletions)404- Resource not found422- Validation errors
Returns all events with associated users and performers.
Response:
[
{
"id": "event_id",
"title": "DJ Night",
"description": "Amazing DJ event",
"date": "2024-01-15T20:00:00Z",
"location": "Club XYZ",
"users": [
{
"id": "user_id",
"name": "John Doe",
"email": "john@example.com",
"phone": "123-456-7890"
}
],
"performers": [
{
"id": "performer_id",
"name": "DJ Alpha",
"bio": "Professional DJ",
"genre": "House",
"contact": "dj@example.com"
}
]
}
]Returns a specific event with associated users and performers.
Creates a new event.
Request Body:
{
"event": {
"title": "New Event",
"description": "Event description",
"date": "2024-01-15T20:00:00Z",
"location": "Event location"
}
}Updates an existing event.
Deletes an event and all associated users and performers.
Returns all users (excluding performers) with associated events.
Response:
[
{
"id": "user_id",
"name": "John Doe",
"email": "john@example.com",
"phone": "123-456-7890",
"created_at": "2024-01-15T10:00:00Z",
"updated_at": "2024-01-15T10:00:00Z",
"events": [
{
"id": "event_id_1",
"title": "DJ Night",
"date": "2024-01-15T20:00:00Z",
"location": "Club XYZ",
"description": "Amazing DJ event"
},
{
"id": "event_id_2",
"title": "Summer Festival",
"date": "2024-07-15T18:00:00Z",
"location": "Central Park",
"description": "Outdoor music festival"
}
],
"tips": []
}
]Returns a specific user with associated events.
Creates a new user and associates them with events.
Request Body:
{
"user": {
"name": "John Doe",
"email": "john@example.com",
"phone": "123-456-7890",
"password": "password123",
"password_confirmation": "password123",
"event_ids": ["event_id_1", "event_id_2"]
}
}Updates an existing user.
Deletes a user.
Note: Performers inherit from Users using Single Table Inheritance (STI). They have all User attributes plus performer-specific fields.
Returns all performers with associated events.
Response:
[
{
"id": "performer_id",
"name": "DJ Alpha",
"bio": "Professional DJ with 10 years experience",
"genre": "House",
"contact": "dj@example.com",
"created_at": "2024-01-15T10:00:00Z",
"updated_at": "2024-01-15T10:00:00Z",
"events": [
{
"id": "event_id_1",
"title": "DJ Night",
"date": "2024-01-15T20:00:00Z",
"location": "Club XYZ",
"description": "Amazing DJ event"
},
{
"id": "event_id_2",
"title": "Summer Festival",
"date": "2024-07-15T18:00:00Z",
"location": "Central Park",
"description": "Outdoor music festival"
}
]
}
]Returns a specific performer with associated events.
Creates a new performer and associates them with events.
Request Body:
{
"performer": {
"name": "DJ Beta",
"email": "djbeta@example.com",
"password": "password123",
"password_confirmation": "password123",
"bio": "Up and coming DJ",
"genre": "Techno",
"contact": "djbeta@example.com",
"event_ids": ["event_id_1", "event_id_2"]
}
}Updates an existing performer.
Deletes a performer.
Returns all tips for a specific event.
Response:
[
{
"id": "tip_id",
"amount": 25.00,
"message": "Great performance!",
"created_at": "2024-01-15T22:30:00Z",
"updated_at": "2024-01-15T22:30:00Z",
"user": {
"id": "user_id",
"name": "John Doe",
"email": "john@example.com"
},
"event": {
"id": "event_id",
"title": "DJ Night",
"date": "2024-01-15T20:00:00Z",
"location": "Club XYZ"
}
}
]Returns a specific tip.
Creates a new tip for an event.
Request Body:
{
"tip": {
"amount": 25.00,
"message": "Amazing set!",
"user_id": "user_id"
}
}Updates an existing tip.
Deletes a tip.
- Inheritance: Performer inherits from User (Single Table Inheritance)
- Events: Many-to-many relationship (
has_and_belongs_to_many :events) - Tips: One-to-many relationship (
has_many :tips) - Scope:
User.non_performersreturns only regular users (excludes performers)
- Users: Many-to-many relationship (
has_and_belongs_to_many :users) - Tips: One-to-many relationship (
has_many :tips) - Performers: Custom method that returns users with
_type: 'Performer'
- Inheritance: Inherits from User model
- Additional Fields:
bio,genre,contact - Events: Inherited many-to-many relationship from User
- User: Belongs to a user (
belongs_to :user) - Event: Belongs to an event (
belongs_to :event) - Fields:
amount,message
curl -X POST http://localhost:3000/api/v1/events \
-H "Content-Type: application/json" \
-d '{
"event": {
"title": "Summer DJ Festival",
"description": "The biggest DJ event of the summer",
"date": "2024-07-15T18:00:00Z",
"location": "Central Park"
}
}'curl -X POST http://localhost:3000/api/v1/users \
-H "Content-Type: application/json" \
-d '{
"user": {
"name": "Alice Johnson",
"email": "alice@example.com",
"phone": "555-0123",
"password": "password123",
"password_confirmation": "password123",
"event_ids": ["EVENT_ID_1", "EVENT_ID_2"]
}
}'curl -X POST http://localhost:3000/api/v1/performers \
-H "Content-Type: application/json" \
-d '{
"performer": {
"name": "DJ Awesome",
"email": "djawesome@example.com",
"password": "password123",
"password_confirmation": "password123",
"bio": "Electronic music specialist",
"genre": "Techno",
"contact": "djawesome@example.com",
"event_ids": ["EVENT_ID_1", "EVENT_ID_2"]
}
}'curl http://localhost:3000/api/v1/events/EVENT_ID_HEREcurl -X POST http://localhost:3000/api/v1/events/EVENT_ID/tips \
-H "Content-Type: application/json" \
-d '{
"tip": {
"amount": 50.00,
"message": "Incredible performance tonight!",
"user_id": "USER_ID_HERE"
}
}'Run the API integration tests:
bundle exec rspec spec/requests/api/The test suite includes:
- CRUD operations for all resources (Users, Events, Performers, Tips)
- Many-to-many relationship testing
- Single Table Inheritance (STI) testing
- Error handling and validation
- Content type validation
- Integration workflows
- Cascading delete operations
Currently, there are no rate limits implemented. Consider adding rate limiting for production use.
The API is versioned using URL path versioning (/api/v1/). Future versions will be available at /api/v2/, etc.