From Sofra to Menew
The product wasn't designed all at once — it was discovered through dozens of build-and-harden cycles. This is the honest sequence, because the scars explain the architecture.
It started as Sofra. The first real work was unglamorous and important: converting two restaurants' HTML menus (Capri and Pablo's — ~193 items across 22 JSON files) into a clean schema, complete with Arabic translations. From there grew a marketing landing page and the core multi-role architecture that still stands today: Master Admin, Restaurant Admin, Kitchen, Waiter, and the Customer menu. Animated logo concepts (the Menu → Menew morph) were explored in parallel.
The diner-facing menu received the most design attention: multiple restaurant themes, a hamburger drawer, a category-card grid, dark/light mode, item photos with emoji fallbacks, "pairs well with" recommendations, dietary filter chips, and a service worker for offline caching. Group ordering arrived with a shared countdown and ref-based dispatch to dodge stale-closure bugs.
The hardest bug in the project's history. When several phones at one table confirmed within the same second, an in-flight cart-sync write could land on top of the submit and erase the session's submitted status — stranding everyone else in their cart even though the order reached the kitchen. The fix was layered: an atomic, row-locked Postgres function (confirm_seat); a deterministic per-sitting order id every device can compute independently; a seat lock that stops background syncing once a device confirms; and guards that refuse to resurrect a submitted session. Exactly one order per group, guaranteed.
A staged lockdown. Phase 1 added the auth/tenancy scaffolding (app_admins, restaurant_members, RLS helper functions). Phase 2 replaced a bundled master password and sessionStorage flags with real Supabase Auth. Later phases moved every public operation behind SECURITY DEFINER functions and locked Row-Level Security across all tables, so the public anon key can no longer read or write anything it shouldn't. A Deno Edge Function was added to provision admin logins server-side, with a forced password change on first login.
A large, multi-session feature wave. A "Waiter Confirmation" gate parks customer orders at pending until a waiter verifies them. Each waiter became their own person — individual token, PIN, and personal link — so every confirm, edit, void, and table order is attributed server-side and can't be spoofed. The kitchen learned to flash when a waiter edits a live ticket, with a "Got it" acknowledgement. Device tracking arrived so a stolen link stands out. Order-level notes, allergy flags, payment status (cash/card), discounts, refunds, daily sales summaries, and Web-Audio notifications all landed in this era.
The final push toward sales-readiness: systematic overflow fixes across every page, a premium animated hamburger drawer, delivery/pickup quick orders, "add items to any order" (even completed ones), shared-bill splitting, and a thorough Arabic sweep so RTL admin matches LTR exactly. PII-stripping public RPCs, Web-Crypto-grade randomness, and PIN handling were tightened. And the app was renamed Sofra → Menew across every surface — with internal storage keys deliberately left unchanged to preserve saved carts and preferences.