SaaS Case Study
5 min read
2026-08-10

Case Study: Engineering a Rate-Limited Food Ordering AI & Real-Time CRM Dashboard

MJ
Muhammad Jahaanzeb
AI Automation & SaaS Developer
Case Study: Engineering a Rate-Limited Food Ordering AI & Real-Time CRM Dashboard
"A deep dive into architecting Pizza Bites — combining Next.js, 98.1% TypeScript, rate-limited guest chat flows, and a custom admin CRM for real-time customer analytics."

Executive Summary

Conversational AI in e-commerce often suffers from two major problems: API token burn from spam bots and a lack of actionable business intelligence for store owners. Most ordering chatbots act merely as fancy wrappers over LLMs without saving structured customer data or offering a management portal.

Pizza Bites was engineered as a full-stack solution to bridge this gap. Built with 98.1% pure TypeScript, Next.js, and Supabase, it pairs a public-facing food ordering assistant with an isolated, real-time Admin CRM for restaurant managers.


The Problem: Spam, Friction, and Missing Analytics

When deploying public-facing AI assistants for local businesses, unauthenticated users can quickly drain API quotas through spam messages. Conversely, forcing immediate login creates high friction for users who just want to inspect the menu.

Furthermore, restaurant owners need to answer key business questions:

  1. 1.Customer LTV: Which specific clients generate the highest lifetime revenue?
  2. 2.Popular Inventory: What exact items are being ordered or inquired about most frequently?
  3. 3.Contextual History: What was the conversation log leading up to a specific transaction?

Architectural Breakdown

CODE_SNIPPETUTF-8
+------------------------------------------------------------------+
| CLIENT / CUSTOMER LAYER                                          |
| - Floating Side Widget & Full-Screen Conversational Interface    |
| - Guest State Tracking (5-Message Exploration Limit)             |
+------------------------------------------------------------------+
                               │
                               ▼
+------------------------------------------------------------------+
| NEXT.JS & SUPABASE BACKEND                                       |
| - Server-side Session Management & Profile Persistence           |
| - Structured Menu & Pricing Context                              |
+------------------------------------------------------------------+
                               │
                               ▼
+------------------------------------------------------------------+
| ADMIN CRM & ANALYTICS                                            |
| - Private Admin Authentication Gateway (/admin)                  |
| - Customer LTV Calculation & Live Chat History View              |
| - Sales Analytics & Popular Product Graphs                       |
+------------------------------------------------------------------+

Key Technical Features

1. Anti-Spam Rate Limiting Guardrails

To balance guest exploration with spam prevention, the assistant tracks message count state during guest sessions:

  • Phase 1 (Exploration): Guest users can send up to 5 messages to ask about the menu, dietary rules, and prices.
  • Phase 2 (Mandatory Profile Enrolment): On the 6th message or when attempting to finalize an order, the chat enforces profile creation (Name, Phone Number, and Delivery Address).
  • Phase 3 (Order Placement): Once authenticated, the user’s order context is saved permanently to the database, linking the chat log to their customer record.

2. Isolated Admin CRM Dashboard

The shop owner accesses a dedicated portal (/admin) designed to convert raw chat conversations into business intelligence:

  • Customer & Chat History (CRM View): A real-time sidebar lists registered customers and guest sessions. Selecting a customer displays profile details and live chat logs while automatically calculating Total Lifetime Revenue.
  • Sales Analytics & Visual Graphs: A dedicated analytics tab tracks overall store progress, rendering charts for top-selling menu items, completed order counts, and gross revenue generated.

3. Strict Type Safety Across Ordering Flows

Written almost entirely in TypeScript (98.1%), the codebase uses strict interfaces for cart state, menu items, and admin telemetry to prevent runtime errors during conversation parsing:

TYPESCRIPT_SNIPPETUTF-8
// Core Data Models for Cart & Customer Telemetry
export interface MenuItem {
  id: string;
  name: string;
  category: 'pizza' | 'sides' | 'drinks' | 'dessert';
  price: number;
  description: string;
}

export interface CustomerProfile {
  id: string;
  fullName: string;
  phoneNumber: string;
  deliveryAddress: string;
  totalOrders: number;
  totalSpent: number;
  createdAt: string;
}

export interface ChatSession {
  sessionId: string;
  customerId?: string;
  messages: Array<{
    role: 'user' | 'assistant' | 'system';
    content: string;
    timestamp: string;
  }>;
}

Results & Production Links

The application is deployed on Vercel with real-time Supabase database bindings.

Need an Architecture Built or Automated?

Let's discuss how n8n workflows, custom tool-calling agents, or a modern SaaS MVP can accelerate your business.