Skip to content

KrishSharma4406/Booking-Web

Repository files navigation

Booking Web

Modern Restaurant Table Booking System with AI Integration

Next.js TypeScript MongoDB Tailwind CSS OpenAI License

A full-stack restaurant booking platform with AI-powered recommendations, real-time table management, secure authentication, and an intuitive admin dashboard. Built with modern web technologies for performance, scalability, and exceptional user experience.

Live Demo β€’ AI Features Guide β€’ Report Bug β€’ Request Feature


✨ Features

πŸ€– AI-Powered Intelligence (NEW!)

  • Smart Chatbot Assistant - 24/7 AI support for reservations and inquiries
  • Intelligent Table Recommendations - ML-based dining area suggestions
  • Sentiment Analysis - Automated review analysis and insights
  • Smart Booking Suggestions - AI-optimized time slot recommendations
  • Personalized Experience - Learns from guest preferences

πŸ” Authentication & Security

  • NextAuth.js integration with multiple providers (Credentials, Google, GitHub, Facebook)
  • Secure password hashing with bcrypt
  • Email verification and password reset via SendGrid
  • JWT-based session management
  • Role-based access control (Admin/User)
  • User approval workflow
  • Online-only payment enforcement (NEW!)

πŸ“Š Admin Dashboard

  • Comprehensive analytics and statistics
  • User management (approve, reject, delete)
  • Table CRUD operations with real-time updates
  • Booking management and confirmation system
  • Dynamic role assignment

πŸͺ‘ Smart Table Management

  • Create tables with customizable properties:
    • Capacity (1-20 guests)
    • Location types (Indoor, Outdoor, Private Room, Bar Area, Terrace)
    • Features (Window View, Romantic, VIP, Wheelchair Accessible, etc.)
    • Status tracking (Available, Occupied, Reserved, Maintenance)
  • Real-time availability checking
  • Automatic or manual table assignment
  • AI-recommended table assignments (NEW!)

πŸ“… Enhanced Booking System

  • Intelligent date and time selection
  • Guest count-based filtering
  • Instant availability verification
  • Real-time connectivity monitoring (NEW!)
  • AI-powered table area recommendations (NEW!)
  • Booking status workflow (Pending β†’ Confirmed β†’ Completed/Cancelled)
  • User booking history and management
  • Email notifications for bookings

🎨 Modern UI/UX

  • Responsive design for all devices
  • Framer Motion animations for smooth interactions
  • Glass morphism effects and gradient backgrounds
  • Dark mode optimized interface
  • Toast notifications for user feedback
  • Loading states and error handling

Tech Stack

Category Technologies
Frontend Next.js 14 (App Router), TypeScript, React 18, Tailwind CSS, Framer Motion
Backend Next.js API Routes, MongoDB, Mongoose ODM
Authentication NextAuth.js, bcrypt, JWT
Email Service SendGrid API
UI Components React Toastify, Custom Components
Development ESLint, PostCSS, TypeScript

Quick Start

Prerequisites

Before you begin, ensure you have the following installed:

  • Node.js 18.x or higher
  • npm or yarn package manager
  • MongoDB (local installation or MongoDB Atlas account)
  • SendGrid account (for email features)

Installation

  1. Clone the repository

    git clone https://github.com/yourusername/booking-web.git
    cd booking-web
  2. Install dependencies

    npm install
    # or
    yarn install
  3. Set up environment variables

    Create a .env.local file in the root directory:

    # Database
    MONGODB_URI=mongodb://localhost:27017/bookingweb
    # For MongoDB Atlas:
    # MONGODB_URI=mongodb+srv://username:password@cluster.mongodb.net/bookingweb
    
    # NextAuth Configuration
    NEXTAUTH_URL=http://localhost:3001
    NEXTAUTH_SECRET=your-secret-key-here-generate-with-openssl-rand-base64-32
    
    # SendGrid Email Service
    SENDGRID_API_KEY=your-sendgrid-api-key
    EMAIL_FROM=noreply@yourdomain.com
    EMAIL_FROM_NAME=Booking Web
    
    # OAuth Providers (Optional)
    GOOGLE_CLIENT_ID=your-google-client-id
    GOOGLE_CLIENT_SECRET=your-google-client-secret
    GITHUB_ID=your-github-client-id
    GITHUB_SECRET=your-github-client-secret
  4. Start MongoDB (if using local installation)

    # Windows
    net start MongoDB
    
    # macOS
    brew services start mongodb-community
    
    # Linux
    sudo systemctl start mongod
  5. Run the development server

    npm run dev
    # or
    yarn dev
  6. Open your browser

    Navigate to http://localhost:3001

🎯 Initial Setup

  1. Create an account - Navigate to /SignUp and register
  2. Become admin - Visit /make-admin (only works when no admin exists)
  3. Add tables - Go to /admin-tables to create tables
  4. Start booking - Users can now book tables at /bookings

Project Structure

booking-web/
β”œβ”€β”€ app/                          # Next.js App Router
β”‚   β”œβ”€β”€ api/                      # API Routes
β”‚   β”‚   β”œβ”€β”€ auth/                 # Authentication endpoints
β”‚   β”‚   β”‚   β”œβ”€β”€ [...nextauth]/    # NextAuth handler
β”‚   β”‚   β”‚   β”œβ”€β”€ signup/           # User registration
β”‚   β”‚   β”‚   β”œβ”€β”€ forgot-password/  # Password reset request
β”‚   β”‚   β”‚   β”œβ”€β”€ reset-password/   # Password reset
β”‚   β”‚   β”‚   β”œβ”€β”€ send-otp/         # OTP generation
β”‚   β”‚   β”‚   └── verify-otp/       # OTP verification
β”‚   β”‚   β”œβ”€β”€ bookings/             # Booking management
β”‚   β”‚   β”œβ”€β”€ tables/               # Table management
β”‚   β”‚   β”œβ”€β”€ users/                # User management
β”‚   β”‚   β”œβ”€β”€ payment/              # Payment processing
β”‚   β”‚   └── admin/                # Admin operations
β”‚   β”œβ”€β”€ admin-dashboard/          # Admin dashboard page
β”‚   β”œβ”€β”€ admin-users/              # User management UI
β”‚   β”œβ”€β”€ admin-tables/             # Table management UI
β”‚   β”œβ”€β”€ bookings/                 # User bookings page
β”‚   β”œβ”€β”€ dashboard/                # User dashboard
β”‚   β”œβ”€β”€ settings/                 # User settings
β”‚   β”œβ”€β”€ Login/                    # Login page
β”‚   β”œβ”€β”€ SignUp/                   # Registration page
β”‚   β”œβ”€β”€ Forgotpwd/                # Forgot password page
β”‚   β”œβ”€β”€ reset-password/           # Reset password page
β”‚   β”œβ”€β”€ make-admin/               # Admin creation page
β”‚   β”œβ”€β”€ portal/                   # Role-based redirect
β”‚   β”œβ”€β”€ about/                    # About page
β”‚   β”œβ”€β”€ privacy-policy/           # Privacy policy
β”‚   β”œβ”€β”€ layout.tsx                # Root layout
β”‚   β”œβ”€β”€ page.tsx                  # Home page
β”‚   └── globals.css               # Global styles
β”œβ”€β”€ components/                   # Reusable components
β”‚   β”œβ”€β”€ Navbar.tsx                # Navigation bar
β”‚   β”œβ”€β”€ Footer.tsx                # Footer component
β”‚   β”œβ”€β”€ SessionProvider.tsx       # Auth session provider
β”‚   β”œβ”€β”€ PaymentForm.tsx           # Payment form
β”‚   └── SmoothScroll.tsx          # Smooth scroll wrapper
β”œβ”€β”€ lib/                          # Utility functions
β”‚   β”œβ”€β”€ mongodb.ts                # MongoDB connection
β”‚   β”œβ”€β”€ email.ts                  # SendGrid email service
β”‚   β”œβ”€β”€ users.ts                  # User utilities
β”‚   β”œβ”€β”€ pricing.ts                # Pricing calculations
β”‚   β”œβ”€β”€ sms.ts                    # SMS service
β”‚   └── useTimezone.ts            # Timezone utilities
β”œβ”€β”€ models/                       # Mongoose schemas
β”‚   β”œβ”€β”€ User.ts                   # User model
β”‚   β”œβ”€β”€ Booking.ts                # Booking model
β”‚   └── Table.ts                  # Table model
β”œβ”€β”€ types/                        # TypeScript definitions
β”‚   β”œβ”€β”€ models.ts                 # Model types
β”‚   └── next-auth.d.ts            # NextAuth types
β”œβ”€β”€ public/                       # Static assets
β”‚   └── newlogo.png               # Application logo
β”œβ”€β”€ .env.local                    # Environment variables (create this)
β”œβ”€β”€ next.config.mjs               # Next.js configuration
β”œβ”€β”€ tailwind.config.js            # Tailwind CSS configuration
β”œβ”€β”€ tsconfig.json                 # TypeScript configuration
└── package.json                  # Dependencies

API Reference

Authentication

Endpoint Method Description Auth Required
/api/auth/signup POST Register new user No
/api/auth/[...nextauth] POST Sign in No
/api/auth/forgot-password POST Request password reset No
/api/auth/reset-password POST Reset password with token No
/api/auth/send-otp POST Send OTP for verification No
/api/auth/verify-otp POST Verify OTP code No

Bookings

Endpoint Method Description Auth Required
/api/bookings GET List user bookings Yes
/api/bookings POST Create new booking Yes
/api/bookings/[id] PATCH Update booking Yes
/api/bookings/[id] DELETE Cancel booking Yes

Tables

Endpoint Method Description Auth Required
/api/tables GET List all tables No
/api/tables POST Create table Admin
/api/tables/[id] PUT Update table Admin
/api/tables/[id] DELETE Delete table Admin

Users

Endpoint Method Description Auth Required
/api/users GET List all users Admin
/api/users/me GET Get current user Yes
/api/users/approve POST Approve/reject user Admin

Admin

Endpoint Method Description Auth Required
/api/admin/make-admin POST Create first admin No*

*Only works when no admin exists


Key Features Explained

Table Management System

Admins have full control over table configurations:

  • Capacity Management: Support for 1-20 guests per table
  • Location Categories:
    • Indoor seating
    • Outdoor patio
    • Private dining rooms
    • Bar area
    • Terrace
  • Special Features:
    • Window views
    • Romantic ambiance
    • VIP sections
    • Wheelchair accessibility
    • Quiet zones
  • Status Tracking: Available, Occupied, Reserved, Under Maintenance

Intelligent Booking Flow

  1. Selection: User selects date, time, and guest count
  2. Availability: System filters tables by capacity and availability
  3. Choice: User can select specific table or let system auto-assign
  4. Confirmation: Booking enters pending status
  5. Admin Review: Admin confirms or adjusts booking
  6. Notification: User receives email confirmation
  7. Completion: Booking marked as completed after service

Admin Dashboard Analytics

  • Total users, bookings, and tables
  • Real-time booking status overview
  • Recent activity feed
  • Quick action buttons
  • User approval queue
  • Revenue tracking (if payment integration enabled)

Security Features

  • Password Security: bcrypt hashing with salt rounds
  • Session Management: Secure JWT tokens with HttpOnly cookies
  • CSRF Protection: Built-in NextAuth CSRF protection
  • Input Validation: Server-side validation on all endpoints
  • Rate Limiting: Prevents brute force attacks (recommended to implement)
  • Role Verification: Middleware checks for admin routes
  • Email Verification: Token-based email confirmation
  • Secure Headers: Recommended security headers in production

Configuration

Customization Options

Branding

  • Update logo in /public/newlogo.png
  • Modify colors in tailwind.config.js
  • Edit site name in layout.tsx

Email Templates

  • Customize email content in lib/email.ts
  • Update SendGrid templates

Booking Rules

  • Adjust time slots in booking page
  • Modify capacity limits in table creation
  • Set booking advance notice period

Contributing

We welcome contributions! Please follow these guidelines:

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

About

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages