Skip to content

Repository files navigation

🍕 OrderHere - Multi-Tenant Restaurant Ordering Platform

A modern, production-ready QR code-based restaurant ordering system built with Node.js, React, and PostgreSQL.

🏗️ Architecture

  • Full-Stack Application: Monorepo structure with integrated frontend/backend
  • Backend: Node.js + Express.js + TypeScript
  • Frontend: React + Vite + TypeScript + TailwindCSS
  • Database: PostgreSQL 16 with Row-Level Security
  • Multi-Tenancy: Complete tenant isolation with RLS policies
  • Real-time: Server-Sent Events for live updates

🚀 Quick Start

Prerequisites

  • Node.js 18+
  • npm 9+
  • PostgreSQL 13+

Installation

  1. Clone the repository:
git clone <repository-url>
cd OrderHere
  1. Install dependencies:
npm install
  1. Set up environment variables:
cp .env.example .env
# Edit .env with your database credentials and other settings
  1. Set up the database:
# Create database
createdb orderhere_dev

# Run migrations
psql -d orderhere_dev -f src/backend/src/database/schema.sql

# (Optional) Load sample data
psql -d orderhere_dev -f src/backend/src/database/seeds/001_sample_data.sql
  1. Start development servers:
# Start both frontend and backend
npm run dev

# Or start individually:
# Backend only: npm run dev --workspace=@orderhere/backend
# Frontend only: npm run dev --workspace=@orderhere/frontend

📁 Project Structure

OrderHere/
├── src/
│   ├── backend/                 # Node.js API server
│   │   ├── src/
│   │   │   ├── database/        # Database schema and migrations
│   │   │   │   ├── migrations/
│   │   │   │   ├── seeds/
│   │   │   │   ├── schema.sql
│   │   │   │   └── connection.ts
│   │   │   └── index.ts
│   │   ├── package.json
│   │   └── tsconfig.json
│   └── frontend/                # React frontend
│       ├── src/
│       │   ├── App.tsx
│       │   ├── main.tsx
│       │   └── index.css
│       ├── index.html
│       ├── package.json
│       ├── tsconfig.json
│       └── vite.config.ts
├── package.json                 # Root workspace configuration
├── .eslintrc.js                # Shared ESLint configuration
├── .gitignore
├── .env.example
└── README.md

🔑 Key Features

Multi-Tenant Architecture

  • Tenant Isolation: Complete data separation using PostgreSQL RLS
  • User Management: GitLab-style user and team management
  • Role-Based Access: Owner, Admin, Manager, Staff roles per tenant
  • Email Invitations: Secure user invitation system

QR Code Ordering

  • Table-Specific QR Codes: Each table has unique QR code
  • Real-Time Orders: Server-Sent Events for live order updates
  • Order Management: Complete order lifecycle management

Database Schema

  • Row-Level Security: Automatic tenant isolation
  • Optimized Indexes: Performance-focused database design
  • Audit Trail: Created/updated timestamps on all tables

🗄️ Database Schema

Core Tables

  • tenants - Restaurant information
  • users - Global user accounts
  • tenant_memberships - User-tenant relationships with roles
  • invitations - Email invitation system
  • categories - Menu categories per tenant
  • menu_items - Restaurant menu items
  • qr_codes - Table-specific QR codes
  • orders - Customer orders
  • order_items - Individual order line items

Security

  • Row-Level Security policies ensure complete tenant isolation
  • Users can only access data for tenants they belong to
  • Automatic context setting for RLS policies

🛠️ Development

Available Scripts

# Development
npm run dev                      # Start all workspaces
npm run dev --workspace=backend  # Backend only
npm run dev --workspace=frontend # Frontend only

# Building
npm run build                    # Build all workspaces
npm run typecheck               # Type check all workspaces
npm run lint                    # Lint all workspaces

# Testing
npm run test                    # Run tests in all workspaces

Environment Variables

Key environment variables (see .env.example):

  • DATABASE_URL - PostgreSQL connection string
  • JWT_SECRET - JWT signing secret
  • SMTP_* - Email configuration for invitations
  • FRONTEND_URL - Frontend URL for CORS

🚀 Production Deployment

Quick Deploy

# Upload deployment script to server
scp orderhere-manager.sh root@your-server:/root/

# Full deployment process
sudo ./orderhere-manager.sh update
sudo ./orderhere-manager.sh backup

Management Scripts

  • 📋 orderhere-manager.sh - All-in-one management script
  • 📚 ORDERHERE_MANAGER_GUIDE.md - Complete deployment guide
  • 🗂️ huongdan.md - Vietnamese deployment manual

Key Features ✅

  • Multi-tenant SaaS: Complete restaurant isolation
  • QR Code Ordering: Table-specific ordering system
  • Real-time Updates: Live order notifications via SSE
  • Team Management: Owner/Administrator/Staff role system
  • Menu Management: Full CRUD menu and item management
  • Order Management: Complete order lifecycle
  • Payment Integration: Table-based payment requests
  • File Uploads: Logo and image management with S3
  • Notifications: Real-time notification system
  • Mobile Responsive: Optimized for all devices

📝 License

MIT License - OrderHere Restaurant Ordering Platform

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages