Skip to content

Repository files navigation

🍽️ Restaurant Management & Ordering System

A comprehensive, production-ready restaurant management and online ordering platform. This full-stack application provides seamless ordering experiences for customers while giving restaurant owners powerful tools for operations management, analytics, and business intelligence.

⚑ Quick Start

Prerequisites

  • Node.js 18+
  • PostgreSQL database
  • Stripe account

Installation

# 1. Install dependencies
npm install

# 2. Setup environment variables
cp .env.example .env.local
# Edit .env.local with your database and Stripe keys

# 3. Setup database
npm run db:push
npm run db:seed  # Optional: load sample data

# 4. Start development server
npm run dev

Open http://localhost:3000 to see the application.


🎯 Key Features

πŸ‘₯ Customer Features

  • βœ… User Authentication - Secure signup/signin with email & password
  • βœ… Menu Browsing - Browse items by category with detailed descriptions
  • βœ… Item Customization - Add options, sizes, toppings with dynamic pricing
  • βœ… Shopping Cart - Full cart management with real-time calculations
  • βœ… Checkout - Streamlined checkout with delivery info & special notes
  • βœ… Multiple Payments - Stripe card payments or Cash on Delivery
  • βœ… Order Tracking - Real-time order status updates (PENDING β†’ IN_KITCHEN β†’ READY β†’ COMPLETED)
  • βœ… Digital Receipts - Download and print PDF receipts
  • βœ… Order History - Complete record of all past orders

πŸ“Š Admin Dashboard

  • βœ… Real-time KPIs - Today's orders, revenue, AOV, completion time
  • βœ… Menu Management - Create/edit categories and items with images
  • βœ… Order Management - View, update status, and manage all orders
  • βœ… Payment Tracking - Monitor Stripe and COD transactions
  • βœ… Expense Tracking - Log expenses by category with receipt storage
  • βœ… Advanced Reports - Revenue, profit, and order analytics with CSV export
  • βœ… Audit Logs - Full change history for compliance
  • βœ… System Settings - Configure restaurant info, taxes, fees, and policies

πŸ”§ Technical Highlights

  • βœ… Type-Safe - Full TypeScript implementation
  • βœ… API Documentation - Interactive Swagger/Scalar UI at /api-docs
  • βœ… Secure Auth - NextAuth.js with role-based access control
  • βœ… Payment Processing - Integrated Stripe with webhooks
  • βœ… Database - PostgreSQL with Prisma ORM
  • βœ… Responsive UI - Mobile-first design with Tailwind CSS
  • βœ… Real-time Updates - React Query for data synchronization

πŸ“¦ Tech Stack

Category Technology
Frontend Next.js 15, React 19, TypeScript
Styling Tailwind CSS, Radix UI, Lucide Icons
Forms React Hook Form, Zod validation
State TanStack Query (React Query)
Database PostgreSQL, Prisma ORM
Auth NextAuth.js v4
Payments Stripe API
PDF PDFMake, jsPDF, html2canvas
3D Three.js, @react-three/fiber
Dev ESLint, TypeScript Strict Mode

πŸ“‚ Project Structure

restaurant-app/
β”œβ”€β”€ src/
β”‚   β”œβ”€β”€ app/                    # Next.js App Router
β”‚   β”‚   β”œβ”€β”€ (customer)/         # Customer routes
β”‚   β”‚   β”‚   β”œβ”€β”€ cart/
β”‚   β”‚   β”‚   β”œβ”€β”€ checkout/
β”‚   β”‚   β”‚   β”œβ”€β”€ menu/
β”‚   β”‚   β”‚   β”œβ”€β”€ orders/
β”‚   β”‚   β”‚   └── payment/
β”‚   β”‚   β”œβ”€β”€ admin/              # Admin dashboard
β”‚   β”‚   β”‚   β”œβ”€β”€ dashboard/
β”‚   β”‚   β”‚   β”œβ”€β”€ menu/
β”‚   β”‚   β”‚   β”œβ”€β”€ orders/
β”‚   β”‚   β”‚   β”œβ”€β”€ expenses/
β”‚   β”‚   β”‚   β”œβ”€β”€ reports/
β”‚   β”‚   β”‚   β”œβ”€β”€ audit/
β”‚   β”‚   β”‚   └── settings/
β”‚   β”‚   └── api/                # RESTful API endpoints
β”‚   β”œβ”€β”€ components/             # React components
β”‚   β”‚   β”œβ”€β”€ admin/
β”‚   β”‚   β”œβ”€β”€ customer/
β”‚   β”‚   β”œβ”€β”€ auth/
β”‚   β”‚   └── ui/
β”‚   β”œβ”€β”€ hooks/                  # Custom React hooks
β”‚   β”œβ”€β”€ lib/
β”‚   β”‚   β”œβ”€β”€ services/           # Business logic
β”‚   β”‚   β”œβ”€β”€ validations/        # Zod schemas
β”‚   β”‚   └── auth.ts
β”‚   β”œβ”€β”€ types/                  # TypeScript types
β”‚   └── contexts/               # React contexts
β”œβ”€β”€ prisma/
β”‚   β”œβ”€β”€ schema.prisma           # Database schema
β”‚   └── seed.ts                 # Sample data
β”œβ”€β”€ public/
β”‚   β”œβ”€β”€ openapi.json            # API spec
β”‚   └── images/
└── package.json

πŸ“‹ Available Scripts

Development

npm run dev              # Start dev server (http://localhost:3000)
npm run build            # Build for production
npm run start            # Start production server
npm run lint             # Run ESLint

Database Management

npm run db:generate      # Generate Prisma client
npm run db:push          # Push schema changes to DB
npm run db:studio        # Open Prisma Studio GUI
npm run db:seed          # Load sample data
npm run db:reset         # Reset DB and reseed (CAUTION!)

Stripe Integration

npm run stripe:listen    # Listen for Stripe webhooks locally

Utilities

npm run clean            # Clear build cache
npm run postinstall      # Auto-run on npm install

πŸ” Authentication & Authorization

User Roles

  • ADMIN - Full system access including dashboard, menu, orders, reports
  • STAFF - Limited access (kitchen staff, delivery partners)
  • CUSTOMER - Customer ordering functionality only

Security Features

  • πŸ”’ Passwords hashed with bcryptjs
  • πŸ”’ Secure session management via NextAuth.js
  • πŸ”’ CSRF protection on all forms
  • πŸ”’ Role-based access control (RBAC)
  • πŸ”’ Input validation with Zod schemas
  • πŸ”’ Stripe PCI compliance (no direct card storage)

πŸ’³ Payment Integration

Stripe Setup

  1. Get API keys from Stripe Dashboard
  2. Set STRIPE_PUBLIC_KEY and STRIPE_SECRET_KEY in .env.local
  3. Configure webhook in Stripe Dashboard β†’ Webhooks
  4. Point webhook to: https://yourdomain.com/api/stripe/webhook

Payment Methods

  • Card Payments - Via Stripe for secure online payments
  • Cash on Delivery - Traditional payment at delivery
  • Refunds - Full refund capability through Stripe

πŸ—„οΈ Database Overview

Core Models

  • User - Customers, admins, staff with roles
  • Category - Menu categories
  • Item - Menu items with pricing
  • ItemOptionGroup & ItemOption - Customizations (sizes, toppings, etc.)
  • Order - Customer orders with status tracking
  • OrderItem & OrderItemOption - Order line items and selections
  • Payment - Payment records and transactions
  • Coupon - Discount codes and promotions
  • Expense - Business expenses by category
  • AuditLog - Change tracking for compliance
  • Settings - System configuration

See Database Schema Documentation for full details.


πŸ“‘ API Documentation

Access API Docs

API Endpoints

Authentication

POST   /api/auth/signup          - Register new user
POST   /api/auth/signin          - Login user
POST   /api/auth/signout         - Logout user

Menu (Public)

GET    /api/menu                 - Get all menu items
GET    /api/menu/[id]            - Get item details
GET    /api/menu/categories      - Get categories

Orders & Cart

GET    /api/cart                 - Get cart
POST   /api/cart/add             - Add to cart
DELETE /api/cart/remove          - Remove from cart
POST   /api/orders               - Create order
GET    /api/orders               - Get order history
GET    /api/orders/[id]          - Get order details

Payments

POST   /api/payments/create-intent - Create Stripe payment intent
POST   /api/stripe/webhook       - Stripe webhook receiver

Admin Only

GET    /api/admin/dashboard      - Dashboard KPIs
GET    /api/admin/orders         - All orders
PUT    /api/admin/orders/[id]    - Update order status
GET    /api/admin/reports        - Generate reports
GET    /api/admin/expenses       - Expense list
POST   /api/admin/expenses       - Create expense
GET    /api/admin/audit-logs     - Audit trail

βš™οΈ Environment Variables

Required

# Database
DATABASE_URL=postgresql://user:password@localhost:5432/restaurant_db

# NextAuth.js Authentication
NEXTAUTH_URL=http://localhost:3000
NEXTAUTH_SECRET=your-random-secret-key

# Stripe Payment Processing
STRIPE_PUBLIC_KEY=pk_test_...
STRIPE_SECRET_KEY=sk_test_...
STRIPE_WEBHOOK_SECRET=whsec_...

Optional

# App Configuration
NEXT_PUBLIC_APP_URL=http://localhost:3000
NODE_ENV=development

# Email (if configured)
SMTP_HOST=smtp.gmail.com
SMTP_PORT=587
SMTP_USER=your-email@gmail.com
SMTP_PASSWORD=your-password

πŸš€ Deployment

Vercel (Recommended)

# Connect your GitHub repository to Vercel
# Automatic deployment on push
# Set environment variables in Vercel dashboard

Self-Hosted

# Build
npm run build

# Set environment variables
export DATABASE_URL=...
export NEXTAUTH_SECRET=...
export STRIPE_SECRET_KEY=...

# Start
npm run start

πŸ› οΈ Development Guide

Adding a New Feature

  1. Create database model in prisma/schema.prisma

    npm run db:push
  2. Create API endpoint in src/app/api/...

  3. Create custom hook in src/hooks/

  4. Create components in src/components/

  5. Add validation schema in src/lib/validations/

  6. Add types in src/types/

Database Changes

# Edit schema.prisma
npm run db:push           # Apply changes
npm run db:studio         # Verify in GUI

πŸ“Š Dashboard Features

Admin Dashboard Includes:

  • πŸ“ˆ Real-time KPI metrics (orders, revenue, AOV)
  • πŸ“Š Payment method breakdown (pie chart)
  • πŸƒ Recent orders feed
  • πŸ“… Daily/weekly/monthly analytics
  • πŸ’° Revenue and expense tracking
  • 🎯 Profit margin calculations
  • πŸ“ Audit trail logging
  • βš™οΈ System settings management

πŸ§ͺ Testing

Test Order Flow

  1. Visit http://localhost:3000
  2. Browse menu and add items to cart
  3. Proceed to checkout
  4. Use Stripe test card: 4242 4242 4242 4242
  5. Complete order
  6. View in admin dashboard at http://localhost:3000/admin

Test Admin Features

  1. Login with admin account
  2. Navigate to Dashboard, Orders, Menu, Reports
  3. Create/edit menu items
  4. Update order statuses
  5. View analytics and reports

πŸ“š Learn More


πŸ› Troubleshooting

Database Connection Issues

# Verify connection string
echo $DATABASE_URL

# Reset database
npm run db:reset

Stripe Webhook Not Receiving Events

# Ensure webhook is running
npm run stripe:listen

# Check webhook signing secret matches
# Dashboard β†’ Developers β†’ Webhooks β†’ Signing secret

Build Errors

npm run clean
npm install
npm run db:generate
npm run build

πŸ“„ License

This project is provided as-is for restaurant management purposes.


🀝 Contributing

Contributions are welcome! Please feel free to submit pull requests.


πŸ“ž Support

For issues and questions, please check the project documentation or create an issue in the repository.


Version: 0.1.0
Last Updated: September 2026
Framework: Next.js 15 + React 19

About

Building a small-business restaurant web app that allows customers to browse the menu, place orders, pay via Stripe (test mode) or Cash on Delivery (COD), and download a printable receipt. Provides an admin area to manage menu items, orders, and a basic fund tracker (earnings and expenses).

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages