A comprehensive RESTful API for a music artist booking platform. This API enables users to discover and book musicians for events, while artists can manage their profiles, availability, and bookings.
- Features
- Tech Stack
- Getting Started
- API Documentation
- Database Models
- Authentication
- Payment Processing
- Error Handling
- Testing
- Recent Updates
- User Authentication: Register, login, and manage user profiles with JWT authentication
- Role-Based Access Control: Three user roles - Admin, Artist, and User (Customer)
- Artist Profiles: Create and manage detailed artist profiles with genres, hourly rates, and availability
- Event Management: Create and browse events with detailed information
- Booking System: Request, confirm, and manage bookings between users and artists
- Reviews & Ratings: Leave and view reviews for artists
- Search & Filtering: Find artists and events based on various criteria
- Payment Processing: Simulated payment processing with different payment methods
- Node.js & Express: Backend framework
- TypeScript: Type-safe JavaScript
- MongoDB & Mongoose: Database and ODM
- JWT: Authentication
- bcryptjs: Password hashing
- Express Validator: Request validation
- Helmet: Security headers
- Node.js v14+
- MongoDB (local or Atlas)
- Clone the repository:
git clone https://github.com/yourusername/harmony-booking-api.git
cd harmony-booking-api
- Install dependencies:
npm install
- Set up environment variables: Create a .env file with:
PORT=3000
MONGODB_URI=mongodb+srv://your-mongodb-connection-string
JWT_SECRET=your_jwt_secret_key_here
JWT_EXPIRE=30d
NODE_ENV=development
- Start the development server:
npm run dev
Note: The following connection string is provided temporarily for evaluation purposes only and will be disabled after review. In a real production environment, connection details would never be included in documentation.
For evaluation of this API, use the following MongoDB connection string:
mongodb+srv://damolaadegbite77:UA5ft5FFtvAiE5Hr@cluster0.kst2mqi.mongodb.net/harmony-booking?retryWrites=true&w=majority
This database is pre-populated with sample data including users, artists, events, bookings, and reviews for testing the API endpoints.
You can use these pre-created user accounts for testing:
Admin User:
- Email: admin@example.com
- Password: Password123
Artist User:
- Email: artist@example.com
- Password: Password123
Regular User:
- Email: user@example.com
- Password: Password123
A Postman collection is included in the repository (Harmony_Booking_API.postman_collection.json
). Import this collection into Postman to test all available endpoints.
The collection includes:
- Authentication requests
- Artist management (create, read, update, delete)
- Event management (create, read, update, delete)
- Booking operations
- Review functionality
All API requests should be made to: http://localhost:3000/api
- URL:
/auth/register
- Method:
POST
- Body:
{
"name": "User Name",
"email": "user@example.com",
"password": "password123",
"role": "user" // "admin", "artist", or "user"
}
- Response: User object and JWT token
- URL:
/auth/#
- Method:
POST
- Body:
{
"email": "user@example.com",
"password": "password123"
}
- Response: User object and JWT token
- URL:
/auth/me
- Method:
GET
- Auth: Required
- Response: User profile
- URL:
/artists
- Method:
GET
- Query Parameters:
genre
: Filter by genrehourlyRate[lte]
: Max hourly ratesort
: Sort field (e.g.,-rating
for highest rated)select
: Fields to returnpage
: Page numberlimit
: Results per page
- Response: List of artists
- URL:
/artists/:id
- Method:
GET
- Response: Artist details
- URL:
/artists
- Method:
POST
- Auth: Required (role: artist)
- Body:
{
"stageName": "Artist Name",
"bio": "Professional artist with experience",
"genres": ["Rock", "Jazz"],
"hourlyRate": 100,
"profileImage": "default-profile.jpg",
"gallery": ["image1.jpg", "image2.jpg"],
"socialLinks": {
"website": "website.com",
"instagram": "artist_insta",
"twitter": "artist_twitter"
},
"availability": [
{
"date": "2023-07-15T00:00:00.000Z",
"isAvailable": true
}
]
}
- Response: Created artist profile
- URL:
/artists/:id/availability
- Method:
PUT
- Auth: Required (own profile or admin)
- Body:
{
"availability": [
{
"date": "2023-07-15T00:00:00.000Z",
"isAvailable": true
}
]
}
- Response: Updated artist with availability
- URL:
/events
- Method:
GET
- Query Parameters: Similar filtering as artists
- Response: List of events
- URL:
/events/:id
- Method:
GET
- Response: Event details
- URL:
/events
- Method:
POST
- Auth: Required
- Body:
{
"title": "Event Title",
"description": "Event description",
"eventType": "wedding",
"date": "2023-12-15T18:00:00Z",
"duration": 4,
"location": {
"address": "123 Main Street",
"city": "New York",
"state": "NY",
"country": "USA",
"zipCode": "10001"
},
"budget": 2000,
"requiredGenres": ["Jazz", "Pop"]
}
- Response: Created event
- URL:
/bookings
- Method:
GET
- Auth: Required - Response: List of bookings (filtered by user role)
- URL:
/bookings/:id
- Method:
GET
- Auth: Required
- Response: Booking details
- URL:
/bookings
- Method:
POST
- Auth: Required
- Body:
{
"artist": "artist_id_here",
"event": "event_id_here",
"message": "We would like to hire you for our event"
}
- Response: Created booking
- URL:
/bookings/:id/status
- Method:
PUT
- Auth: Required (artist being booked or admin)
- Body:
{
"status": "accepted" // or "rejected", "canceled", "completed"
}
- Response: Updated booking
- URL:
/bookings/:id/payment
- Method:
POST
- Auth: Required
- Body:
{
"paymentMethod": "credit_card" // or "paypal", "bank_transfer", "cash"
}
- Response: Updated booking with payment information
- URL:
/artists/:artistId/reviews
- Method:
GET
- Response: List of reviews for the artist
- URL:
/artists/:artistId/reviews
- Method:
POST
- Auth: Required
- Body:
{
"rating": 5,
"title": "Amazing Performance",
"text": "The artist was fantastic and professional."
}
- Response: Created review
- name: String
- email: String (unique)
- password: String (hashed)
- role: String (enum: "admin", "artist", "user")
- createdAt: Date
- user: Reference to User
- stageName: String
- bio: String
- genres: [String]
- hourlyRate: Number
- profileImage: String
- gallery: [String]
- socialLinks: Object
- availability: Array of date objects
- createdAt: Date
- title: String
- description: String
- organizer: Reference to User
- eventType: String (enum)
- date: Date
- duration: Number (hours)
- location: Object
- budget: Number
- requiredGenres: [String]
- status: String (enum)
- createdAt: Date
- user: Reference to User
- artist: Reference to Artist
- event: Reference to Event
- message: String
- status: String (enum: "pending", "accepted", "rejected", "canceled", "completed")
- price: Number
- startTime: Date
- endTime: Date
- payment: Object
- createdAt: Date
- user: Reference to User
- artist: Reference to Artist
- rating: Number (1-5)
- title: String
- text: String
- createdAt: Date
The API uses JSON Web Tokens (JWT) for authentication. To access protected routes:
- Login to obtain a token
- Include the token in the Authorization header of your requests:
Authorization: Bearer YOUR_TOKEN_HERE
The API includes a simulated payment system for handling booking payments. In the current implementation:
- Users can process payments for bookings using various payment methods
- The system updates booking status to 'confirmed' once payment is processed
- Payment details are stored with the booking
Supported Payment Methods:
- Credit Card
- PayPal
- Bank Transfer
- Cash
Note: The current implementation simulates payment processing. In a production environment, this would be integrated with a real payment gateway like Stripe, PayPal, or Square.
- Added consistent error handling with appropriate HTTP status codes
- Fixed type issues with Mongoose models and controllers
- Added TypeScript support for all API components
- Improved query handling with proper type safety
- Updated Mongoose model hooks to use current supported methods
- Initial release of the Harmony Booking API
- Basic CRUD operations for all resources
- Authentication with JWT
- Role-based access control
The API returns consistent error responses with appropriate HTTP status codes:
{
"success": false,
"message": "Error message",
"stack": "Error stack trace (in development mode)"
}