Black Friday sale: $30 off until 30 Nov 2026

For developers

QR ordering system source code: a Next.js + Supabase architecture, explained

By Zxro, maker of myrestos Updated

Short answer

A production QR ordering system can be built as one Next.js App Router app with three areas — guest ordering, restaurant dashboard and platform admin — on Supabase for Postgres, auth, realtime and storage. The parts that matter most are row-level security for tenant isolation, realtime subscriptions for the kitchen, table sessions that only staff can open, and idempotency keys enforced in the database. myrestos is source code built this way.

Key takeaways

  • One Next.js app, three route groups: guest ordering, restaurant dashboard and platform admin.
  • Postgres row-level security is the real security boundary; the UI only hides what RLS already blocks.
  • Orders are idempotent twice: a client-side guard and a unique (restaurant_id, idempotency_key) constraint.
  • Prices are snapshotted on the cart line, so menu edits never change a past bill.

The stack

LayerChoiceWhy
FrameworkNext.js 16 (App Router), TypeScript strictServer components for fast menus on cheap phones; one deploy for all three apps
UITailwind CSS v4, shadcn/ui, lucide iconsConsistent, accessible components that are easy to restyle per brand
Client stateZustand (cart), TanStack Query v5 (server data)A small cart store plus cached, refetchable server data
Formsreact-hook-form + ZodTyped validation shared with the API
Database & authSupabase Postgres + AuthRow-level security, triggers and SQL you fully own
Live updatesSupabase RealtimeOrders and status changes pushed to screens, no polling
ImagesSupabase StorageMenu photos and brand logos
HostingVercel (any Node host works)Zero-config Next.js deploys

How the app is organised

Everything is a single Next.js app split into route groups:

  • (ordering) — the guest app opened from a table QR code.
  • (dashboard) — each restaurant's orders, tables, menu, analytics, customers and team.
  • (platform) — the platform owner's admin: branding, invites, leads and restaurants.
  • Public pages — the platform's own marketing site, sign-up and a one-time /setup bootstrap.

Code follows a strict page → hook → service layering. Pages render, hooks manage state and caching, and only the service layer talks to Supabase. When you change how data is fetched, there's one place to look.

Multi-tenancy with row-level security

Every restaurant's data lives in the same tables, scoped by restaurant_id. Postgres row-level security (RLS) policies decide which rows each signed-in user can read or write, so a bug in the UI can't leak another restaurant's orders. Platform-admin checks run on the server, not by hiding the URL.

Table sessions and the ordering flow

A table visit is modelled as a session with a small state machine:

StateEntered whenWhat it allows
PENDINGStaff open the table, or a guest scans its secret QRGuests join and build the shared cart
ACTIVEThe first order is placedMore orders, live status, bill
CLOSEDStaff confirm payment, or an optional cleanup job closes a forgotten tableNothing — the next scan starts fresh

Guests can only join a session through the table's secret QR code, with rate limits against spam. The cart is shared by everyone at the table, and each cart line stores the unit_price at the moment it was added.

Placing an order is idempotent in two layers: a client-side guard stops double taps, and a unique constraint on (restaurant_id, idempotency_key) guarantees the database never stores the same order twice, even on a retry over a flaky network.

Realtime kitchen updates

The dashboard subscribes to order changes through Supabase Realtime, so new orders appear the moment they're placed and move through placed → preparing → served. The guest's phone subscribes to its own session, so they see each status change. Tables show at a glance whether they're free, ordering or waiting to pay.

White-label branding without code changes

Branding — platform name, tagline, logo, favicon, primary colour and support email — is stored in the database and read by the root layout, so it reaches page titles, metadata, the marketing site, every restaurant dashboard and every guest screen. The colour is validated as a hex value and exposed as a CSS variable. Saving in the admin panel revalidates the cached pages immediately.

Data you get for free

  • A customers table, deduplicated by phone per restaurant, kept up to date by Postgres triggers on visits and orders — visit count, last visit and total spend.
  • Revenue, order and best-seller analytics rendered as lightweight SVG charts (no chart library).
  • Soft delete for menu items, so order history keeps pointing at the right dish.
  • Single-use invite links and an optional open sign-up for restaurants.

Setup and customisation

The whole database — tables, policies and triggers — is one setup.sql file you paste into the Supabase SQL editor. Deploy to Vercel with a handful of environment variables, open /setup once with your setup key to create the platform admin, and the route disables itself.

From there it's an ordinary Next.js codebase: add a payment gateway, a printer integration or a loyalty programme like you would in any app. For the business case versus writing it yourself, see build vs buy.

Frequently asked questions

Is there open-source QR ordering system source code?

There are open-source QR menu projects, but most are single-restaurant demos without multi-tenant security, realtime kitchen updates or an admin for running many restaurants. Production-ready white-label code is usually sold under a commercial license.

Is myrestos open source?

No. myrestos is commercial source code: you get the full codebase to run and modify for one brand with unlimited restaurants, but you can't resell or redistribute the code itself.

Can I run it without Vercel?

Yes. It's a standard Next.js app, so any host that runs Next.js works. Vercel is recommended because it deploys Next.js with no configuration.

Does it need a native mobile app?

No. Guests order in the phone's browser after scanning the QR code, and restaurant staff use the dashboard in any browser, on a tablet, laptop or phone.

Skip the build

Launch your own QR ordering platform with myrestos

The complete codebase and the guide to launch it as your own brand. Pay once, keep 100% of what restaurants pay you.

  • Customer QR ordering app
  • Restaurant dashboard (orders, menu, tables, analytics)
  • Platform admin panel: branding, invites & leads
  • One-file database setup + step-by-step SETUP.md
  • License for 1 brand
  • Unlimited restaurants

Sources