## RestroAgent - AI-Powered Restaurant Management Platform

RestroAgent is a complete, production-ready SaaS platform that brings artificial intelligence to every aspect of restaurant operations. From handling customer orders and table reservations through an AI chat widget and voice calls, to managing menus, staff, branches, billing, and analytics -- RestroAgent is a full-stack solution built for restaurant owners and SaaS operators alike.

Built with Next.js 15, React 19, TypeScript, Tailwind CSS, PostgreSQL, and Drizzle ORM, this platform is designed to be deployed as a multi-tenant SaaS product or a standalone restaurant management system. It ships with a complete admin panel for platform operators, a restaurant dashboard for business owners, an embeddable AI chat widget, Twilio voice integration, Stripe billing, multi-language support, and much more.

### Key Highlights

AI Chat Widget | Embeddable chat widget that takes orders, books tables, and answers customer questions using OpenAI
AI Voice Agent | Twilio-powered phone agent that handles inbound/outbound calls with real-time AI voice responses
Multi-Agent System | Create multiple AI agents per restaurant, each with their own LLM model, voice, personality, and capabilities
Knowledge Base (RAG) | Upload PDFs, crawl URLs, add Q&A pairs and articles -- all vectorized with pgvector for semantic search
Full SaaS Platform | Multi-tenant with Stripe billing, subscription plans, admin panel, branding, and user management
Multi-Language | 6 languages included (English, Hindi, German, French, Russian, Arabic) with RTL support and AI auto-translation
QR Storefront | Public-facing mobile-first ordering storefront with QR code per table -- customers browse, build cart, and place orders directly
WhatsApp Business | Connect Meta WhatsApp Cloud API per branch for inbound messages, template sending, and marketing campaigns
Loyalty, Coupons & Gift Cards | Point-based loyalty program, percentage/fixed coupons with usage limits, and gift card issuance with ledger tracking
Marketing Campaigns | Rule-based audience segments and campaign builder for sending WhatsApp template messages to targeted customer groups
White-Label Ready | Custom branding: site title, logo, favicon, primary color, Google Fonts -- all configurable from the admin panel
Modern Tech Stack | Next.js 15, React 19, TypeScript, Tailwind CSS, PostgreSQL, Drizzle ORM v0.45, Zod validation

### AI Agent and Conversations

- Multi-Agent Dashboard -- Create, configure, and manage multiple AI agents per restaurant. Each agent has its own identity, LLM model, voice model, system prompt, greeting/closing scripts, capabilities, and fallback rules.
- LLM Provider Catalogue -- Database-backed catalogue of LLM providers (OpenAI, OpenRouter, Anthropic) and models (GPT-4o, Claude 3.5, Gemini 2.0, Llama 3.3, Mistral Large, and more). Fully editable from the admin panel.
- Voice Provider Catalogue -- Voice models from OpenAI TTS (6 voices) and Sarvam AI (11 Indian language voices). Admin-editable.
- Embeddable Chat Widget -- JavaScript-based widget that can be embedded on any restaurant website. Handles live chat, order placement, table booking, and Q&A. Customizable colors, bot name, avatar, welcome message, and placeholder text.
- Widget Preview -- Real-time visual preview of the chat widget with all customizations applied.
- Conversations Inbox -- Unified inbox for all chat and voice conversations. Filter by status, channel, date range. Slide-over detail panel with full message thread, AI confidence scores, and metadata.
- Bulk Operations -- Select multiple conversations to change status, assign agent, delete, or export to CSV.
- AI-to-Human Handover -- When the AI cannot handle a request, it escalates to a human operator with full context preserved.
- BYOK (Bring Your Own Keys) -- Restaurant owners can enter their own API keys for OpenAI, OpenRouter, or Sarvam AI. Keys are encrypted with AES-256-GCM and stored per-restaurant.

### Knowledge Base (RAG - Retrieval Augmented Generation)

- Document Upload -- Drag-and-drop PDF and TXT file uploads. Text is extracted automatically (PDF via pdf-parse) and indexed.
- Website Crawling -- Enter a URL and the system automatically crawls the page content, strips HTML, and stores the text as a knowledge entry.
- Q&A Pairs -- Create question-and-answer pairs that the AI agent can reference during conversations.
- Articles -- Create titled articles with rich content for comprehensive knowledge coverage.
- Vector Embeddings -- All knowledge entries are automatically embedded using OpenAI text-embedding-3-small and stored with pgvector for semantic search.
- Auto-Available to All Agents -- Knowledge base entries are automatically available to every chat and voice agent for the restaurant.
- Re-Index -- One-click re-index button to regenerate embeddings for all entries.
- Embedding Status -- Visual badges showing embedding status (pending, indexing, indexed, error) for each entry.

### Telephone and Voice AI

- Twilio Integration -- Connect your Twilio account directly from the dashboard. Manage phone numbers, assign AI agents, and configure per-number settings.
- Auto-Webhook Provisioning -- When you assign an agent to a phone number, the system automatically configures Twilio webhooks for voice and status callbacks.
- OpenAI Realtime Voice -- All voice calls use the OpenAI Realtime API for natural, low-latency AI conversations over the phone.
- Inbound and Outbound Calls -- Handle incoming customer calls automatically. Initiate outbound calls from the dashboard.
- Call Transfer -- AI agent can escalate calls to a human operator via configurable fallback/transfer numbers.
- Conference Calls -- Move active calls into a conference room for three-way handoff between AI, customer, and staff.
- Number Purchase -- Search and buy phone numbers directly through the Twilio API from within the dashboard.
- Call Recording and Transcription -- Per-number settings for call recording and transcription with audio playback in the call detail panel.
- Call History -- Paginated call log with filters for direction, status, agent, and date range. Detailed call panel with transcript and recording player.
- SIP Trunks -- Full CRUD for SIP line configuration (display name, server, credentials, outbound proxy, agent assignment).

### WhatsApp Business Integration

- WhatsApp Cloud API -- Connect your Meta WhatsApp Business account directly from the dashboard per branch. Sensitive credentials (access token, app secret) are encrypted at rest with AES-256-GCM.
- Webhook Reception -- Per-branch webhook endpoint for inbound WhatsApp messages and status updates. App-secret signature verification enforced in production.
- Template Messages -- Fetch and send approved WhatsApp message templates from within the dashboard. Used for outbound customer notifications and marketing campaigns.
- Conversation Integration -- Inbound WhatsApp messages are routed into the unified Conversations inbox alongside chat and voice interactions.
- Marketing Campaigns -- WhatsApp channel support in the marketing campaign dispatcher for sending bulk template messages to customer segments.
- Throughput Controls -- Per-branch and per-campaign send limits on outbound WhatsApp messages to avoid overloading the Cloud API.

### Restaurant Operations

#### Order Management

- Full order lifecycle: pending, confirmed, preparing, ready, delivered, cancelled
- Support for dine-in, takeaway, and delivery order types
- AI confidence scores for automated orders
- Detailed order view with item breakdown, modifiers, and pricing
- Real-time order count badges in the sidebar
- Email confirmation sent automatically when orders are placed
- 30-second background polling for live updates

#### Table Booking Management

- Full reservation lifecycle: confirmed, seated, completed, cancelled, no-show
- Guest name, party size, date, time, occasion, and special requests
- Booking confirmation emails with all reservation details
- Live badge count in the sidebar navigation
- Filter and search across all bookings

#### Menu Management

- Hierarchical structure: Categories, Items, and Modifier Groups
- Item details: name, description, price, image, spice level, veg/non-veg, prep time, calories
- Sort order for custom item arrangement
- Modifier groups with radio/checkbox types, required/optional, min/max selections
- Modifier options with price deltas, defaults, and availability toggles
- Bulk upload via CSV/JSON
- Image upload with automatic storage (local disk or S3)

#### QR Storefront

- Public-facing mobile-first ordering storefront accessible via unique restaurant and branch URL
- Browse menu categories and items, add to cart, select modifiers, and place orders directly
- Support for dine-in (with table number), takeaway, and delivery order types
- Branch operating hours shown inline with open/closed status indicator
- QR code generation for each table links directly to the storefront

#### Customer CRM

- Centralized customer database with name, email, phone, and notes
- Order history and conversation history per customer
- Search and filter across the customer base

#### Loyalty Program

- Point-based loyalty system configurable per restaurant (points per currency unit, expiry)
- Customer point balances tracked per restaurant with full ledger history
- Loyalty settings managed from the dashboard with enable/disable toggle

#### Coupons

- Full coupon management: percentage or fixed-amount discounts with configurable minimum order value
- Per-coupon usage limits (global and per-customer), expiry dates, and active/inactive toggle
- Redemption history with per-coupon usage tracking
- Search and filter across the coupon catalogue

#### Gift Cards

- Gift card issuance with configurable balance, expiry, and unique code generation
- Full ledger tracking of gift card balance changes (issue, redeem, adjust)
- Gift card settings configurable per restaurant

#### Performance Analytics

- Revenue and order charts (Recharts)
- Channel breakdown (chat vs. voice)
- Hourly order distribution
- AI resolution rate and response time metrics
- KPI cards with active conversations, total orders, and agent performance

### Marketing and Campaigns

- Audience Segments -- Build reusable customer segments using rule-based filters (order count, total spend, last order date, tags, and more). Estimated audience size shown before sending.
- Campaign Builder -- Create and schedule marketing campaigns targeting specific audience segments. Campaigns support WhatsApp template messages as the delivery channel.
- Campaign Dispatch -- Automated campaign dispatcher sends messages to all matched customers with per-recipient rate limiting and delivery status tracking.
- Test Send -- Send a test campaign message to a specified number before launching to the full audience.
- Customer Opt-Out -- Customers can opt out of marketing communications. Opt-out is respected across all campaign sends.

### Staff, Roles, and Branches

- Role-Based Access Control -- Granular CRUD permissions across 9 sections: dashboard, orders, reservations, menu, customers, conversations, staff, analytics, and settings.
- System Roles -- 6 pre-built roles seeded per restaurant: Owner, Manager, Supervisor, Waiter, Host, and Kitchen Staff. Each with appropriate default permissions.
- Custom Roles -- Create unlimited custom roles with a visual permission matrix (section x CRUD toggles).
- Staff Management -- Add, edit, and manage team members. Assign roles with automatic permission inheritance. Visual indicator when a staff member's permissions diverge from their assigned role.
- Multi-Branch -- Manage multiple restaurant locations under one account. Each branch has its own operating hours, staff, and settings. Branch hours are automatically injected into the AI agent's context.

### Billing and Subscriptions

- Stripe Integration -- Full Stripe Checkout and Customer Portal integration for subscription management.
- Subscription Plans -- Create and manage plans with monthly/annual billing cycles. Sync plans with Stripe from the admin panel.
- Invoice History -- View past invoices and payment history.
- Payment Method Management -- Update credit card and payment methods via Stripe SetupIntent.
- Webhook Handling -- Automated webhook processing for subscription lifecycle events (created, updated, cancelled, payment failures).
- Trial Period Support -- Configurable trial periods with visual trial status in the dashboard.

### Platform Admin Panel

The admin panel provides platform operators with full control over the SaaS infrastructure. Accessible via the "Switch to Admin" toggle for superadmin accounts.

- Admin Dashboard -- Aggregated statistics across all registered restaurants, orders, bookings, and revenue.
- Restaurant Management -- View, edit, and manage all restaurant accounts on the platform.
- Impersonation -- Log into any restaurant account for support and troubleshooting without needing their password.
- Plan Management -- Create, edit, and sync subscription plans with Stripe.
- Order and Booking Administration -- Platform-wide view of all orders and bookings across restaurants.
- AI Provider Management -- Add, edit, and remove LLM providers, LLM models, voice providers, and voice models from the catalogue.
- AI Settings -- Configure platform-level AI defaults and provider API keys.
- Branding -- White-label configuration: site title, logo upload, favicon upload, primary color picker, and Google Font selection. Applied globally across the platform.
- Language Management -- Add, edit, and manage languages. Translation editor with search and category filters. AI auto-translate button (powered by GPT-4o-mini) to fill untranslated keys in bulk. Coverage percentage tracking per language.
- Blog Management -- Create and manage blog posts for SEO and marketing.
- Support Tickets -- View and manage support tickets from restaurant users.
- Audit Logs -- Track administrative actions across the platform.

### Multi-Language and Localization

- 6 languages included out of the box: English, Hindi, German, French, Russian, and Arabic
- Translation keys across multiple categories covering the entire application
- Full RTL (right-to-left) support for Arabic and other RTL languages
- AI Auto-Translation: One-click button to translate all missing keys using GPT-4o-mini
- Per-user language preference saved to the database
- Add unlimited new languages from the admin panel
- Coverage tracking: visual progress bar showing translation completion percentage per language
- Both dashboard and landing pages are fully translated

### Restaurant Settings

- Restaurant Profile -- Business name, address, contact details, and description
- Logo Upload -- Upload restaurant logo (PNG, JPEG, GIF, WEBP) with magic byte validation
- Currency Configuration -- Set once and lock the restaurant's operating currency (ISO code allowlist)
- AI Provider Keys -- BYOK tab for entering restaurant-specific OpenAI, OpenRouter, or Sarvam API keys
- Notification Preferences -- Configure alert settings for new orders and bookings
- Alert Overlay -- Visual alert overlay for new orders and bookings with preview functionality
- Email Templates -- Pre-built HTML email templates for order confirmations and booking confirmations

### Public Landing Pages

- Responsive hero landing page with platform overview and demo credentials
- Dynamic pricing page with plan comparison
- Blog system with slug-based routing for SEO
- Legal pages: Privacy Policy, Terms of Service, Refund Policy, Cookie Policy
- FAQ and Contact/Support pages
- User registration and login with demo credential auto-fill
- Forgot password and password reset flow with email verification

### Security and Storage

- Authentication -- JWT stored in httpOnly cookies using the jose library. Bcrypt password hashing.
- Route Protection -- Middleware-based authentication and role-based authorization on all API routes.
- Input Validation -- Zod schema validation on all API endpoints (15+ validator files).
- Encryption -- AES-256-GCM encryption for sensitive data (API keys, Twilio tokens).
- Path Traversal Protection -- All file upload paths are validated and sanitized against directory traversal attacks.
- Redirect Validation -- Checkout redirect URLs are validated against a domain allowlist.
- File Storage -- Dual storage driver: local disk (default) or Amazon S3. Configurable via environment variable.
- File Upload Security -- Allowed extension allowlist, magic byte validation, and unique UUID filenames.

### Tech Stack

Layer | Technology
--- | ---
Framework | Next.js 15 (App Router)
UI Library | React 19
Language | TypeScript 5
Styling | Tailwind CSS 3.4
Database | PostgreSQL (with pgvector extension)
ORM | Drizzle ORM v0.45
Authentication | JWT (jose) + bcrypt
AI / LLM | OpenAI Agents SDK, OpenAI Realtime API
Voice | Twilio (voice, WebSocket streaming)
Payments | Stripe (Checkout, Customer Portal, Webhooks)
Email | Nodemailer (SMTP)
Validation | Zod v4
Charts | Recharts
Icons | Lucide React, Heroicons
File Storage | Local disk or Amazon S3

### Database Structure

The application uses 54 PostgreSQL tables with a fully typed Drizzle ORM schema. The database auto-initializes on first run and applies idempotent migrations on each restart. Key tables include:

- restaurants
- branches
- restaurant_tables
- users
- admin_users
- roles
- staff
- plans
- subscriptions
- orders
- bookings
- menu_categories
- menu_items
- menu_modifier_groups
- menu_modifier_options
- customers
- conversations
- ai_agents
- ai_agent_configs
- widget_settings
- knowledge_base
- agent_knowledge_bases
- llm_providers
- llm_models
- voice_providers
- voice_models
- phone_numbers
- telephone_settings
- sip_registrations
- sip_call_sessions
- call_logs
- branch_whatsapp_credentials
- whatsapp_message_log
- coupons
- coupon_redemptions
- gift_card_settings
- gift_cards
- gift_card_ledger
- notifications
- notification_preferences
- alert_settings
- message_templates
- languages
- translation_keys
- translations
- platform_settings
- audit_logs
- api_keys
- restaurant_api_keys
- webhooks
- webhook_delivery_logs
- blog_posts
- support_tickets
- password_reset_tokens

### What Is Included

- Full source code (TypeScript, no obfuscation)
- Drizzle ORM schema with auto-migration
- Production build script with ZIP packaging and version bump support
- Comprehensive documentation (HTML format)
- Demo seed data (users, menu items, sample data)
- Environment variable template (.env.example)
- 6 pre-configured languages with translation keys covering the full application
- Seeded AI provider catalogue (LLM and voice models)
- 6 system roles with granular permissions
- Landing pages with legal pages (Privacy, Terms, Refund, Cookie Policy)
- Future updates

### System Requirements

Node.js | v20 or higher
PostgreSQL | v14 or higher (with pgvector extension recommended)
npm | v10 or higher
OpenAI API Key | Required for AI chat, voice, embeddings, and auto-translation
Stripe Account | Optional -- required only if you want subscription billing
Twilio Account | Optional -- required only if you want AI voice/phone features
SMTP Server | Optional -- required for sending order/booking confirmation emails and password resets
Amazon S3 | Optional -- for cloud file storage (local disk used by default)

### Deployment

RestroAgent can be deployed on any server or platform that supports Node.js and PostgreSQL. Tested and compatible with:

- VPS (DigitalOcean, Hetzner, AWS EC2, Linode) with PM2 process manager
- Replit
- Netlify (with @netlify/plugin-nextjs)
- Any Node.js hosting with PostgreSQL database access

### Support

- 6 months of support included with purchase
- Comprehensive HTML documentation included
- Environment setup guide with all configuration options
- Contact: diploy.in

### Changelog

Version 1.0 -- Initial Release

- AI-powered restaurant management dashboard
- Multi-agent system with LLM and voice provider catalogues
- Embeddable chat widget with order and booking flows
- Twilio voice AI with OpenAI Realtime API
- Knowledge base with vector embeddings (RAG)
- Full order and booking management
- Menu management with categories, items, and modifiers
- Customer CRM
- Staff management with role-based access control
- Multi-branch support
- Stripe billing with subscription plans
- Multi-language with 6 languages and RTL support
- White-label branding (logo, favicon, colors, fonts)
- Platform admin panel with full management capabilities
- Email notifications for orders and bookings
- Performance analytics and charts
- BYOK (Bring Your Own Keys) for AI providers
- QR storefront for public ordering via mobile browser
- WhatsApp Business integration (Cloud API, inbound messages, templates)
- Loyalty program with point-based rewards
- Coupon management (percentage and fixed discounts)
- Gift card issuance and ledger tracking
- Marketing campaigns with audience segments
- Drizzle ORM v0.45 with typed schema (54 tables)
- Zero npm audit vulnerabilities

RestroAgent by diploy -- diploy.in