1. Protected API
Accepts authenticated requests, validates payloads, enforces request limits and resolves store membership before making a database call.
The repository includes an executable PostgreSQL migration and an architecture guide. The browser has no database connection and cannot bypass the policy layer.
Accepts authenticated requests, validates payloads, enforces request limits and resolves store membership before making a database call.
Tables carry store scope, foreign keys protect relationships, and row-level security blocks accidental cross-store reads.
React web and future native clients share the same HTTP contracts; business decisions remain in API services.
The migration creates all required core entities, keyed by UUID with indexes on tenant filters and high-volume lookup paths.
users, stores, store_members, settings, audit_logs
products, product_variants, categories, collections, inventory, inventory_movements
customers, orders, order_items, payments, refunds, coupons, discounts, abandoned_carts
subscriptions, subscription_plans, invoices, commissions, feature_flags, feature_plan_access, ai_credits, ai_usage
shipping_zones, shipping_rates, deliveries, suppliers, purchase_orders, expenses, marketing_campaigns, automation_rules
domains, themes, apps, notifications, support_tickets, blog_posts, analytics, customer_segments, affiliate_accounts, affiliate_conversions
BEGIN;
SELECT set_config('app.user_id', :userId, true);
SELECT set_config('app.store_id', :storeId, true);
-- API query: RLS checks membership + store scope
COMMIT;The API must never accept a store ID as authority. It checks membership first, then the database enforces the same boundary independently.