Skip to content

rgl456/Book-My-Table

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Book-My-Table

A full-stack restaurant table booking system built with Spring Boot and React, featuring role-based authentication, restaurant management, table reservations, and review functionality.

Features

  • 🔐 Role-Based Authentication - Separate registration for Users, Managers, and Admins with JWT
  • 🍽️ Restaurant Management - Create, update, and view restaurants
  • 🪑 Table Management - Manage tables for each restaurant with capacity and availability
  • 📅 Booking System - Create, update, and track table reservations with status management
  • Review System - Users can leave reviews and ratings for restaurants
  • 🔒 Secure Sessions - JWT tokens stored in HTTP-only cookies
  • 👥 Multi-Role Support - Different access levels for Users, Managers, and Admins

Tech Stack

Backend

  • Spring Boot - REST API framework
  • Spring Security - Authentication and authorization
  • JWT - Token-based authentication with cookie storage
  • MySQL/PostgreSQL - Database (assumed)
  • Role-Based Access Control - USER, MANAGER, ADMIN roles

Frontend

  • React - UI library
  • React Router - Client-side routing
  • Axios - HTTP client (assumed)
  • CSS - Styling

API Endpoints

Authentication

POST /api/v1/auth/register/users     - User registration
POST /api/v1/auth/register/managers  - Manager registration
POST /api/v1/auth/register/admins    - Admin registration
POST /api/v1/auth/login              - User login (all roles)
POST /api/v1/auth/logout             - User logout
GET  /api/v1/auth/users              - Get all users

Restaurants

POST   /api/v1/restaurants     - Create restaurant
GET    /api/v1/restaurants     - Get all restaurants
GET    /api/v1/restaurants/{id} - Get restaurant by ID
PUT    /api/v1/restaurants/{id} - Update restaurant

Tables

POST   /api/v1/tables/restaurant/{restaurantId}                     - Create table
GET    /api/v1/tables                                               - Get all tables
GET    /api/v1/tables/restaurant/{restaurantId}                     - Get tables by restaurant
GET    /api/v1/tables/{tableId}/restaurant/{restaurantId}           - Get specific table
GET    /api/v1/tables/{tableId}/restaurant/{restaurantId}/bookings  - Get table bookings
PUT    /api/v1/tables/{tableId}/restaurant                          - Update table
DELETE /api/v1/tables/{tableId}                                     - Delete table

Bookings

POST   /api/v1/bookings/restaurant/{restaurantId}  - Create booking
GET    /api/v1/bookings                            - Get all bookings
GET    /api/v1/bookings/{id}                       - Get booking by ID
GET    /api/v1/bookings/user/{userId}              - Get bookings by user
GET    /api/v1/bookings/restaurant/{restaurantId}  - Get bookings by restaurant
GET    /api/v1/bookings/status?status={status}     - Get bookings by status
PUT    /api/v1/bookings/{id}                       - Update booking
PUT    /api/v1/bookings/{id}/status?status={status} - Update booking status
DELETE /api/v1/bookings/{id}                       - Delete booking

Reviews

POST   /api/v1/reviews                        - Create review
GET    /api/v1/reviews                        - Get all reviews
GET    /api/v1/reviews/{id}                   - Get review by ID
GET    /api/v1/reviews/restaurants/{restaurantId} - Get reviews by restaurant
GET    /api/v1/reviews/users/{userId}         - Get reviews by user
PUT    /api/v1/reviews/{id}                   - Update review
DELETE /api/v1/reviews/{id}                   - Delete review

Getting Started

Prerequisites

  • Java 17+
  • Node.js 16+
  • MySQL/PostgreSQL
  • Maven

Backend Setup

  1. Clone the repository
git clone https://github.com/rgl456/book-my-table.git
cd book-my-table
  1. Configure database in application.properties
spring.datasource.url=jdbc:mysql://localhost:3306/bookmytable
spring.datasource.username=your_username
spring.datasource.password=your_password

# JWT Configuration
jwt.secret=your_jwt_secret_key
jwt.expiration=86400000
  1. Run the application
mvn spring-boot:run

The API will be available at http://localhost:8080

Frontend Setup

  1. Navigate to frontend directory
cd frontend
  1. Install dependencies
npm install
  1. Start the development server
npm run dev

The application will be available at http://localhost:5173

Project Structure

book-my-table/
├── src/main/java/
│   ├── controllers/
│   │   ├── UserController.java
│   │   ├── RestaurantController.java
│   │   ├── TableEntityController.java
│   │   ├── BookingController.java
│   │   └── ReviewController.java
│   ├── services/
│   ├── repositories/
│   ├── models/
│   │   ├── User.java
│   │   ├── Restaurant.java
│   │   ├── TableEntity.java
│   │   ├── Booking.java
│   │   └── Review.java
│   ├── security/
│   └── dto/
└── frontend/
    ├── src/
    │   ├── pages/
    │   │   ├── UserRegister.jsx
    │   │   ├── ManagerRegister.jsx
    │   │   ├── Login.jsx
    │   │   ├── Home.jsx
    │   │   ├── Restaurant.jsx
    │   │   ├── Table.jsx
    │   │   └── TableDetails.jsx
    │   └── App.jsx
    └── package.json

User Roles & Permissions

User (Customer)

  • Browse restaurants
  • View available tables
  • Create and manage bookings
  • Leave reviews for restaurants

Manager (Restaurant Owner)

  • All User permissions
  • Create and manage restaurants
  • Create and manage tables
  • View all bookings for their restaurants
  • Update booking status

Admin

  • All Manager permissions
  • Access to all system resources
  • User management
  • System-wide oversight

Key Features Details

Authentication Flow

  • Role-based registration (User/Manager/Admin)
  • JWT token generated on successful login
  • Token stored in secure HTTP-only cookie with SameSite=Strict
  • Automatic logout functionality clears cookies
  • Role-based access control on backend endpoints

Booking Management

  • Create bookings for specific tables at restaurants
  • Update booking details
  • Track booking status (PENDING, CONFIRMED, CANCELLED, COMPLETED)
  • Filter bookings by user, restaurant, or status
  • Managers can update booking status

Table Management

  • Managers create tables with capacity and details
  • Tables linked to specific restaurants
  • View all bookings for a specific table
  • Update table information and availability

Review System

  • Users can review restaurants after booking
  • Rating and comment functionality
  • View reviews by restaurant or user
  • Update or delete own reviews

Booking Status Flow

PENDING → CONFIRMED → COMPLETED
    ↓
CANCELLED

Security Features

  • Passwords hashed using BCrypt
  • JWT tokens with configurable expiration
  • HTTP-only cookies prevent XSS attacks
  • SameSite=Strict cookie attribute prevents CSRF
  • Secure flag enabled for HTTPS
  • Role-based authorization on sensitive endpoints

API Response Format

Success Response

{
  "id": "uuid",
  "data": {},
  "timestamp": "2024-01-01T00:00:00"
}

Error Response

{
  "error": "Error message",
  "status": 400,
  "timestamp": "2024-01-01T00:00:00"
}

Contributing

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

Future Enhancements

  • Email notifications for booking confirmations
  • Payment integration
  • Real-time table availability
  • Restaurant search and filtering
  • Photo upload for restaurants and reviews
  • Booking cancellation policies
  • SMS notifications
  • Admin dashboard analytics

License

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

Contact

Email - ragul7690@gmail.com

Project Link: https://github.com/rgl456/book-my-table


Made with ❤️ using Spring Boot and React

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors