A multi-tenant restaurant point-of-sale backend built on Supabase PostgreSQL, Deno Edge Functions, and N8N Webhooks.
Frontend
|
v
Supabase Auth + PostgREST + Edge Functions
|
v
PostgreSQL (Business Logic in PL/pgSQL)
|
v
N8N Webhooks (Notifications & Automations)
All core business logic lives in SECURITY DEFINER PL/pgSQL functions. Edge functions are thin HTTP wrappers that handle external API calls (Uber Direct, etc.). The database enforces Row-Level Security (RLS) on every table for tenant isolation.
Organization (tenant)
└── Location (store/branch)
├── Users (staff)
├── Orders
├── Inventory
├── Deliveries
└── Reservations
Every row is scoped to an organization_id. Location-level data is further scoped by location_id. RLS policies enforce this hierarchy automatically.
The core POS flow: menu items organized by categories, modifier groups for customization, order creation with line items, taxes, and payments.
| Tables | Purpose |
|---|---|
categories |
Menu item groupings |
menu_items |
Products available for sale |
modifier_groups, modifiers |
Customization options (e.g., size, extras) |
menu_item_modifier_groups |
Links menu items to their modifier groups |
orders |
Order headers with status tracking |
order_items |
Line items per order |
order_item_modifiers |
Modifiers selected per order item |
order_taxes |
Tax breakdown per order |
payments |
Payment records |
taxes, discounts |
Tax rates and discount rules |
Full delivery lifecycle management integrated with Uber Direct API -- quoting, dispatching, real-time status tracking via webhooks, courier tracking, alerts, and fee reconciliation.
| Tables | Purpose |
|---|---|
deliveries |
Delivery records with full status tracking |
delivery_quotes |
Uber Direct delivery quotes |
delivery_status_history |
Audit trail of every status change |
delivery_alerts |
Alerts for failures, delays, anomalies |
delivery_couriers |
Courier assignment and live location |
delivery_fees |
Fee breakdown per delivery |
uber_direct_configs |
Org-level Uber API credentials |
uber_direct_locations |
Per-location Uber store mapping |
uber_webhook_logs |
Raw webhook payload logging |
Edge Functions:
| Function | Purpose |
|---|---|
uber-auth |
OAuth token management |
uber-get-quote |
Request delivery quotes |
uber-create-delivery |
Dispatch a delivery |
uber-get-delivery |
Fetch delivery status |
uber-update-delivery |
Update delivery details |
uber-cancel-delivery |
Cancel an active delivery |
uber-webhook |
Receive Uber status webhooks |
Recipe-based inventory with automatic stock deduction on order completion, sub-recipe support (prep items), purchase orders, stock counts, waste tracking, batch/lot tracking, and cost analysis.
| Tables | Purpose |
|---|---|
inventory_categories |
Groupings for inventory items |
inventory_items |
Raw materials and stock levels |
recipe_ingredients |
Links menu items to their required ingredients |
Key Functions: calculate_daily_inventory_usage, process_end_of_day_inventory
Table management with floor plan support, session tracking, shifts, and a full reservation system with waitlist and confirmation codes.
| Tables | Purpose |
|---|---|
dining_areas |
Floor plans / sections |
tables |
Individual tables with positioning |
table_sessions |
Active table sessions |
table_blocks |
Blocked-off time slots |
shifts |
Staff shift records |
reservations |
Bookings with confirmation codes |
reservation_settings |
Per-location reservation config |
reservation_history |
Reservation change audit trail |
reservation_waitlist |
Walk-in waitlist management |
Customer profiles linked to Supabase Auth, with per-organization membership and multi-address support for delivery.
| Tables | Purpose |
|---|---|
customer_profiles |
Auth-linked customer identity |
organization_customers |
Per-org customer membership |
customer_addresses |
Saved delivery addresses with geocoding |
Multi-tenant user management with role-based access (admin, staff, customer) and location-level permissions.
| Tables | Purpose |
|---|---|
organizations |
Tenant accounts |
locations |
Physical stores/branches |
users |
Staff accounts with roles |
user_locations |
Staff-to-location assignments |
Key Functions: is_admin, is_staff_user, is_customer_user, get_user_organization_id, user_has_location_access
The close-location-day edge function and process_end_of_day_inventory database function handle daily reconciliation.
Automated cleanup functions prevent unbounded table growth:
| Function | Default Retention |
|---|---|
cleanup_delivery_status_history |
90 days |
cleanup_expired_quotes |
24 hours |
cleanup_uber_webhook_logs |
30 days |
| Layer | Technology |
|---|---|
| Database | Supabase PostgreSQL |
| Auth | Supabase Auth (JWT) |
| API | PostgREST (auto-generated) + Edge Functions |
| Edge Functions | Deno (TypeScript) |
| Automations | N8N Webhooks |
| Delivery Provider | Uber Direct |
| Multi-tenancy | RLS policies on every table |
38 tables / 67 database functions / 8 edge functions