Smart_Booking_API

๐Ÿจ Smart Booking API Suite

![Smart Booking Logo](/Smart_Booking_API/frontend/src/assets/pictures/Home.png) **A comprehensive hotel booking backend API with AI-powered natural language processing** [![Node.js](https://img.shields.io/badge/Node.js-339933?style=for-the-badge&logo=nodedotjs&logoColor=white)](https://nodejs.org/) [![Express.js](https://img.shields.io/badge/Express.js-000000?style=for-the-badge&logo=express&logoColor=white)](https://expressjs.com/) [![PostgreSQL](https://img.shields.io/badge/PostgreSQL-316192?style=for-the-badge&logo=postgresql&logoColor=white)](https://postgresql.org/) [![JWT](https://img.shields.io/badge/JWT-000000?style=for-the-badge&logo=JSON%20web%20tokens&logoColor=white)](https://jwt.io/) [![Swagger](https://img.shields.io/badge/Swagger-85EA2D?style=for-the-badge&logo=swagger&logoColor=black)](https://swagger.io/) [![Build Status](https://img.shields.io/github/actions/workflow/status/username/smart-booking-api/ci.yml?branch=main)](https://github.com/username/smart-booking-api/actions) [![Coverage](https://img.shields.io/codecov/c/github/username/smart-booking-api)](https://codecov.io/gh/username/smart-booking-api) [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT) [![Version](https://img.shields.io/github/v/release/username/smart-booking-api)](https://github.com/username/smart-booking-api/releases) [๐Ÿš€ Live Demo](#-live-demo) โ€ข [๐Ÿ“– Documentation](#-api-documentation) โ€ข [๐Ÿ› ๏ธ Installation](#-installation) โ€ข [๐Ÿ‘ฅ Team](#-team)

๐Ÿ“‹ Table of Contents


๐ŸŒŸ Features

| Authentication | Booking System | AI Integration | Management | |:---:|:---:|:---:|:---:| | ๐Ÿ” **JWT Security** | ๐Ÿ“… **Real-time Booking** | ๐Ÿค– **NLP Processing** | ๐Ÿ‘ค **User Profiles** | | Role-based access | Conflict detection | Natural language booking | Provider management | | Secure passwords | Availability search | GPT-4 integration | Booking history |

โœจ Core Capabilities


๐Ÿš€ Live Demo

๐ŸŒ API Endpoints

Base URL: https://smart-booking-api.herokuapp.com/api/v1

Swagger Documentation: https://smart-booking-api.herokuapp.com/api-docs

๐ŸŽฎ Try It Out

# 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"

๐Ÿ“ฑ Demo Credentials

Email: demo@smartbooking.com
Password: Demo123!
Role: Customer

๐Ÿ“ธ Screenshots

๐ŸŽฏ Provider Page

Provider Page

๐Ÿ“Š Dashboard Analytics

Dashboard

๐Ÿ” Authentication Page

Authentication

๐Ÿค– Signup Page

Signup


๐Ÿ‘ฅ Team

| Member | Role | Responsibilities | Contact | |:---:|:---:|:---:|:---:| | ๐Ÿ‘จโ€๐Ÿ’ป **Masingita Maluleke** | Full-stack Developer | Full-stack development, Architecture | [@Tinyu01](https://github.com/Tinyu01) | | ๐ŸŽจ **Khulekani Mtshali** | UI/UX Designer | API design, User experience | [@Khulekani](https://github.com/Mkhulekani?tab=repositories) | | ๐Ÿ—„๏ธ **Luyanda Xhakaza** | Backend & Database Engineer | Backend development, Database optimization, Migrations | [@luyandaaaa](https://github.com/luyandaaaa) | | ๐Ÿงช **Dembe Mkhari** | QA Engineer | Testing, Quality assurance | [@DembeMakharii](https://github.com/DembeMakharii) | | ๐Ÿค– **Arise Dzamukeri** | AI Integration Specialist | NLP features, GPT-4 integration | [@lisadavis](https://github.com/lisadavis) | | ๐Ÿš€ **Matimu Baloyi** | DevOps Engineer | CI/CD, Deployment, Monitoring | [@MatimuBaloyi](https://github.com/MatimuBaloyi) |

๐Ÿ—๏ธ Project Structure

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

โšก Quick Start

Prerequisites

๐Ÿš€ One-Click Setup

# 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


๐Ÿ› ๏ธ Installation

Detailed Setup

  1. Clone & Install
    git clone https://github.com/username/smart-booking-api.git
    cd smart-booking-api
    npm install
    
  2. Environment Configuration
    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
    
  3. Database Setup
    # Create database
    createdb smart_booking_db
       
    # Run migrations
    npm run migrate
       
    # Seed with sample data
    npm run seed
    
  4. Start Development
    npm run dev
    

๐Ÿณ Docker Setup (Alternative)

# Using Docker Compose
docker-compose up -d

# The API will be available at http://localhost:3000

๐Ÿ“– API Documentation

๐Ÿ”— Quick Reference

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 โœ…

๐Ÿ“ Example Requests

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"
}

๐Ÿ“š Full Documentation


๐Ÿงช Testing

Running Tests

# 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

Test Coverage

Test Structure

tests/
โ”œโ”€โ”€ unit/
โ”‚   โ”œโ”€โ”€ controllers/
โ”‚   โ”œโ”€โ”€ services/
โ”‚   โ””โ”€โ”€ utils/
โ”œโ”€โ”€ integration/
โ”‚   โ”œโ”€โ”€ auth.test.js
โ”‚   โ”œโ”€โ”€ booking.test.js
โ”‚   โ””โ”€โ”€ provider.test.js
โ””โ”€โ”€ fixtures/
    โ””โ”€โ”€ sampleData.js

๐Ÿš€ Deployment

Production Deployment

Heroku Deployment

# 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

Docker Deployment

# 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

CI/CD Pipeline

The project includes automated CI/CD with GitHub Actions:


๐Ÿค Contributing

We love contributions! Please see our Contributing Guide for details.

Development Workflow

  1. Fork the repository
  2. Create a feature branch: git checkout -b feature/amazing-feature
  3. Make your changes
  4. Run tests: npm test
  5. Commit changes: git commit -m 'Add amazing feature'
  6. Push to branch: git push origin feature/amazing-feature
  7. Open a Pull Request

Code Style


๐Ÿ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.


### ๐ŸŒŸ Star this repo if you found it helpful! **Made with โค๏ธ by the Smart Booking Team** [โฌ† Back to Top](#-smart-booking-api-suite)

๐Ÿ“ž Support & Contact


![Footer](https://via.placeholder.com/800x100/1F2937/FFFFFF?text=Thank+you+for+checking+out+Smart+Booking+API!)