Base URL: https://smart-booking-api.herokuapp.com/api/v1
Swagger Documentation: https://smart-booking-api.herokuapp.com/api-docs
# Register a new user
curl -X POST "https://smart-booking-api.herokuapp.com/api/v1/auth/register" \
-H "Content-Type: application/json" \
-d '{
"email": "demo@example.com",
"password": "securePassword123",
"firstName": "Demo",
"lastName": "User"
}'
# Search available bookings
curl -X GET "https://smart-booking-api.herokuapp.com/api/v1/availability?date=2024-03-15&service=hotel"
Email: demo@smartbooking.com
Password: Demo123!
Role: Customer
smart-booking-api/
โโโ ๐ src/
โ โโโ ๐ controllers/ # Route controllers
โ โ โโโ authController.js
โ โ โโโ userController.js
โ โ โโโ bookingController.js
โ โ โโโ providerController.js
โ โโโ ๐ middleware/ # Custom middleware
โ โ โโโ auth.js
โ โ โโโ validation.js
โ โ โโโ errorHandler.js
โ โโโ ๐ models/ # Database models (Sequelize)
โ โ โโโ User.js
โ โ โโโ Provider.js
โ โ โโโ Booking.js
โ โ โโโ Availability.js
โ โโโ ๐ routes/ # API routes
โ โ โโโ auth.js
โ โ โโโ users.js
โ โ โโโ bookings.js
โ โ โโโ providers.js
โ โโโ ๐ services/ # Business logic
โ โ โโโ authService.js
โ โ โโโ bookingService.js
โ โ โโโ aiService.js
โ โโโ ๐ utils/ # Utility functions
โ โ โโโ jwt.js
โ โ โโโ validation.js
โ โ โโโ logger.js
โ โโโ ๐ config/ # Configuration files
โ โ โโโ database.js
โ โ โโโ swagger.js
โ โ โโโ env.js
โ โโโ app.js # Express app setup
โโโ ๐ tests/ # Test files
โ โโโ ๐ unit/
โ โโโ ๐ integration/
โ โโโ ๐ fixtures/
โโโ ๐ docs/ # Documentation
โ โโโ api.md
โ โโโ deployment.md
โโโ ๐ migrations/ # Database migrations
โโโ ๐ seeders/ # Database seeders
โโโ .github/ # GitHub workflows
โ โโโ workflows/
โ โโโ ci.yml
โโโ .env.example # Environment variables template
โโโ .gitignore
โโโ package.json
โโโ README.md
โโโ server.js # Entry point
# Clone the repository
git clone https://github.com/username/smart-booking-api.git
cd smart-booking-api
# Install dependencies
npm install
# Set up environment variables
cp .env.example .env
# Edit .env with your database credentials
# Run database migrations
npm run migrate
# Seed the database (optional)
npm run seed
# Start development server
npm run dev
The API will be available at http://localhost:3000
git clone https://github.com/username/smart-booking-api.git
cd smart-booking-api
npm install
cp .env.example .env
Update .env
with your settings:
NODE_ENV=development
PORT=3000
DB_HOST=localhost
DB_PORT=5432
DB_NAME=smart_booking_db
DB_USER=your_username
DB_PASS=your_password
JWT_SECRET=your_super_secret_jwt_key
OPENAI_API_KEY=your_openai_api_key
# Create database
createdb smart_booking_db
# Run migrations
npm run migrate
# Seed with sample data
npm run seed
npm run dev
# Using Docker Compose
docker-compose up -d
# The API will be available at http://localhost:3000
Endpoint | Method | Description | Auth Required |
---|---|---|---|
/auth/register |
POST | User registration | โ |
/auth/login |
POST | User login | โ |
/users/me |
GET | Get current user | โ |
/providers |
POST | Register as provider | โ |
/availability |
GET | Search availability | โ |
/bookings |
POST | Create booking | โ |
/bookings/:id |
GET | Get booking details | โ |
/nlp/book |
POST | AI-powered booking | โ |
User Registration
POST /api/v1/auth/register
Content-Type: application/json
{
"email": "user@example.com",
"password": "securePass123!",
"firstName": "John",
"lastName": "Doe",
"role": "user"
}
AI Natural Language Booking
POST /api/v1/nlp/book
Authorization: Bearer YOUR_JWT_TOKEN
Content-Type: application/json
{
"request": "I need a hotel room in New York for next Friday night for 2 people"
}
/api-docs
when running locally# Run all tests
npm test
# Run unit tests only
npm run test:unit
# Run integration tests
npm run test:integration
# Generate coverage report
npm run test:coverage
# Watch mode for development
npm run test:watch
tests/
โโโ unit/
โ โโโ controllers/
โ โโโ services/
โ โโโ utils/
โโโ integration/
โ โโโ auth.test.js
โ โโโ booking.test.js
โ โโโ provider.test.js
โโโ fixtures/
โโโ sampleData.js
# Install Heroku CLI
npm install -g heroku
# Login and create app
heroku login
heroku create smart-booking-api
# Set environment variables
heroku config:set NODE_ENV=production
heroku config:set JWT_SECRET=your_production_secret
# Deploy
git push heroku main
# Build image
docker build -t smart-booking-api .
# Run container
docker run -p 3000:3000 \
-e NODE_ENV=production \
-e DB_HOST=your_db_host \
smart-booking-api
The project includes automated CI/CD with GitHub Actions:
We love contributions! Please see our Contributing Guide for details.
git checkout -b feature/amazing-feature
npm test
git commit -m 'Add amazing feature'
git push origin feature/amazing-feature
This project is licensed under the MIT License - see the LICENSE file for details.