Skip to content

ibhf13/qrbites

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

55 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

🍽️ QRBites

Restaurant Menu Digitization Platform

QRBites is a modern, full-stack web application that enables restaurants to digitize their menus and provide customers with a seamless, contactless dining experience through QR codes. Built with cutting-edge technologies, QRBites offers a comprehensive solution for restaurant menu management, QR code generation, and customer menu viewing.

License Node Status

🌐 Live Demo

✨ Features

  • 🍽️ Digital Menu Management - Create, update, and organize restaurant menus with ease
  • πŸ“± QR Code Generation - Automatic QR code creation for instant menu access
  • πŸ” Secure Authentication - JWT-based authentication with role-based access control
  • πŸ‘₯ Multi-Role Support - Admin, Restaurant Owner, and Customer roles
  • πŸ–ΌοΈ Image Management - Cloudinary integration for efficient image upload and optimization
  • πŸ” Advanced Search - Powerful menu search and filtering capabilities
  • πŸ“Š API Documentation - Interactive Swagger/OpenAPI documentation
  • ⚑ High Performance - Redis caching and rate limiting for optimal performance
  • 🎨 Modern UI - Beautiful, responsive interface built with React and Tailwind CSS
  • 🌐 PWA Ready - Progressive Web App capabilities for mobile experience

πŸ—οΈ Architecture

QRBites follows a modern monorepo structure with separated frontend and backend:

qrbites/
β”œβ”€β”€ frontend/          # React + TypeScript + Vite
β”œβ”€β”€ backend/           # Node.js + Express + MongoDB
β”œβ”€β”€ .husky/            # Git hooks for code quality
└── package.json       # Root workspace configuration

Technology Stack

Backend

  • Runtime: Node.js 20+
  • Framework: Express.js 5.1
  • Database: MongoDB with Mongoose ODM
  • Authentication: JWT (JSON Web Tokens)
  • File Storage: Cloudinary
  • Caching: Redis with ioredis
  • Documentation: Swagger/OpenAPI
  • Testing: Jest with Supertest
  • Code Quality: ESLint, Prettier

Frontend

  • Library: React 18
  • Language: TypeScript
  • Build Tool: Vite
  • Styling: Tailwind CSS
  • Routing: React Router 7
  • State Management: TanStack Query (React Query)
  • Forms: React Hook Form + Zod validation
  • UI Components: Headless UI, Heroicons
  • Notifications: Notistack

πŸš€ Getting Started

Prerequisites

  • Node.js >= 20.0.0
  • npm >= 10.0.0
  • MongoDB (local or cloud instance)
  • Redis (optional, for caching)
  • Cloudinary Account (for image uploads)

Installation

  1. Clone the repository

    git clone https://github.com/yourusername/qrbites.git
    cd qrbites
  2. Install root dependencies

    npm install
  3. Install backend dependencies

    cd backend
    npm install
  4. Install frontend dependencies

    cd ../frontend
    npm install

Environment Configuration

Backend (.env)

Create a .env file in the backend directory:

# Server Configuration
NODE_ENV=development
PORT=5000
HOST=localhost

# Database
MONGODB_URI=mongodb://localhost:27017/qrbites

# JWT Configuration
JWT_SECRET=your-super-secret-jwt-key-min-32-characters
JWT_EXPIRES_IN=7d
JWT_REFRESH_EXPIRES_IN=30d

# Cloudinary Configuration
CLOUDINARY_CLOUD_NAME=your-cloudinary-cloud-name
CLOUDINARY_API_KEY=your-cloudinary-api-key
CLOUDINARY_API_SECRET=your-cloudinary-api-secret

# CORS Configuration
ALLOWED_ORIGINS=http://localhost:3000,http://localhost:5173

# File Upload
MAX_FILE_SIZE=5242880

# Rate Limiting
RATE_LIMIT_WINDOW_MS=900000
RATE_LIMIT_MAX_REQUESTS=100
AUTH_RATE_LIMIT_MAX=5
CREATE_USER_RATE_LIMIT_MAX=3

# Frontend URL
FRONTEND_URL=http://localhost:5173

# Logging
LOG_LEVEL=debug

Frontend (.env)

Create a .env file in the frontend directory:

VITE_API_URL=http://localhost:5000
VITE_DEMO_EMAIL=demo@example.com
VITE_DEMO_PASSWORD=demo123

Running the Application

Development Mode

  1. Start the backend

    cd backend
    npm run dev

    Backend will run on http://localhost:5000

  2. Start the frontend (in a new terminal)

    cd frontend
    npm run dev

    Frontend will run on http://localhost:5173

Production Mode

  1. Build the frontend

    cd frontend
    npm run build
  2. Start the backend in production

    cd backend
    npm run start:prod

Using Docker

Backend

cd backend

# Build the image
npm run docker:build

# Run the container
npm run docker:run

πŸ“š Documentation

API Documentation

Access the interactive API documentation:

Project Documentation

πŸ§ͺ Testing

Backend Tests

cd backend

# Run all tests
npm test

# Run tests with coverage
npm run test:coverage

# Run tests in watch mode
npm run test:watch

# Run specific test suites
npm run test:unit
npm run test:integration

Test Coverage

The backend maintains high test coverage with:

  • Unit tests for models, controllers, and services
  • Integration tests for API endpoints
  • Middleware tests for authentication and validation

🎨 Code Quality

The project uses pre-commit hooks via Husky to ensure code quality:

  • ESLint - Code linting
  • Prettier - Code formatting
  • Lint-staged - Run checks on staged files

Manual Code Quality Checks

# Lint backend
npm run lint:backend

# Lint frontend
npm run lint:frontend

# Format backend
npm run format:backend

# Format frontend
npm run format:frontend

# Run all pre-commit checks
npm run pre

πŸ“ Project Structure

Backend Structure

backend/
β”œβ”€β”€ src/
β”‚   β”œβ”€β”€ common/              # Shared utilities
β”‚   β”‚   β”œβ”€β”€ errors/          # Error classes
β”‚   β”‚   β”œβ”€β”€ middlewares/     # Express middlewares
β”‚   β”‚   β”œβ”€β”€ services/        # Common services
β”‚   β”‚   β”œβ”€β”€ utils/           # Utility functions
β”‚   β”‚   └── validation/      # Validation schemas
β”‚   β”œβ”€β”€ config/              # Configuration files
β”‚   β”œβ”€β”€ modules/             # Feature modules
β”‚   β”‚   β”œβ”€β”€ users/           # User management
β”‚   β”‚   β”œβ”€β”€ restaurants/     # Restaurant management
β”‚   β”‚   β”œβ”€β”€ menus/           # Menu management
β”‚   β”‚   β”œβ”€β”€ menuItems/       # Menu items management
β”‚   β”‚   └── health/          # Health check
β”‚   β”œβ”€β”€ app.js               # Express app setup
β”‚   └── server.js            # Server entry point
β”œβ”€β”€ __tests__/               # Test files
β”œβ”€β”€ docs/                    # API documentation
└── package.json

Frontend Structure

frontend/
β”œβ”€β”€ src/
β”‚   β”œβ”€β”€ api/                 # API client
β”‚   β”œβ”€β”€ assets/              # Static assets
β”‚   β”œβ”€β”€ components/          # Reusable components
β”‚   β”‚   β”œβ”€β”€ common/          # Common UI components
β”‚   β”‚   └── app/             # App-level components
β”‚   β”œβ”€β”€ config/              # Configuration
β”‚   β”‚   └── routes/          # Route definitions
β”‚   β”œβ”€β”€ contexts/            # React contexts
β”‚   β”œβ”€β”€ features/            # Feature modules
β”‚   β”‚   β”œβ”€β”€ auth/            # Authentication
β”‚   β”‚   β”œβ”€β”€ restaurants/     # Restaurant management
β”‚   β”‚   β”œβ”€β”€ menus/           # Menu management
β”‚   β”‚   β”œβ”€β”€ viewer/          # Menu viewer
β”‚   β”‚   └── qr/              # QR code generation
β”‚   β”œβ”€β”€ hooks/               # Custom React hooks
β”‚   β”œβ”€β”€ providers/           # App providers
β”‚   β”œβ”€β”€ styles/              # Global styles
β”‚   β”œβ”€β”€ types/               # TypeScript types
β”‚   β”œβ”€β”€ utils/               # Utility functions
β”‚   β”œβ”€β”€ App.tsx              # Root component
β”‚   └── main.tsx             # Entry point
└── package.json

πŸ”’ Security

QRBites implements multiple security best practices:

  • Authentication: JWT-based stateless authentication
  • Authorization: Role-based access control (RBAC)
  • Password Hashing: Bcrypt with configurable rounds
  • Rate Limiting: Protection against brute force attacks
  • Input Validation: Joi schemas for request validation
  • Sanitization: MongoDB query sanitization
  • CORS: Configurable cross-origin resource sharing
  • Helmet: Security headers middleware
  • File Upload: Validated and restricted file uploads

🚒 Deployment

Backend Deployment (Vercel)

The backend is configured for Vercel deployment with vercel.json.

cd backend
vercel deploy

Frontend Deployment (Vercel)

The frontend is also configured for Vercel deployment.

cd frontend
vercel deploy

Environment Variables

Ensure all required environment variables are configured in your deployment platform.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors