L
LUUP One
Architecture Pack
Prepared for external CTO validation

LUUP One
Architecture Pack

A CTO-ready architecture reference for validating the LUUP One build across platform structure, system context, containers, components, data relationships, security, permissions, financial controls, webhooks, automation, AI services, and operational readiness.

This pack explains how LUUP One should be structured as a multi-tenant customer commerce platform connecting merchants, customers, ambassadors, creators, missions, referrals, attribution, commissions, wallets, payouts, admin operations, automations, AI services, and external integrations.

01

Overview

This architecture pack defines LUUP One as a practical multi-tenant customer commerce platform. It is designed to help an external CTO validate whether the build has the right technical foundations for merchants, ambassadors, customers, missions, referrals, attribution, commissions, wallets, payouts, admin controls, automations, integrations, AI services, and security.

What this pack covers

  • How LUUP One sits in the wider ecosystem
  • Which users and external systems interact with the platform
  • The expected Lovable, Supabase, GitHub, n8n, and AI services architecture
  • How the main application containers fit together
  • How backend components should be organised
  • How the data model should support merchants, ecosystems, referrals, commissions, wallets, and payouts
  • How roles, permissions, and tenant isolation should work
  • How financial events, webhooks, files, and audit logs should be secured
  • What the external CTO should validate before beta, paid merchants, and scale

Core validation question

Is LUUP One built as a real multi-tenant SaaS platform, or is it a high-fidelity prototype that needs a production-grade backend?

02

Build Architecture

LUUP runs on a Lovable + Supabase application stack with a Capacitor native shell, an Everflow-backed affiliate engine, Stripe Connect for payments, and the Lovable AI Gateway (Gemini 2.5 Pro) for every generative feature. The CTO should validate the actual implementation against this chain and confirm the handoff from AI-generated build to professional engineering process is in place.

React 18 / Vite SPA (+ Capacitor 8 native shell)
Supabase Auth (email + Google OAuth)
Supabase Postgres (87 tables, RLS-first)
Supabase Storage (private buckets)
Supabase Edge Functions (72 Deno fns)
Lovable AI Gateway (Gemini 2.5 Pro)
n8n (long-running orchestration)
External services: Stripe, Everflow, Resend, Mux, Qdrant, Sliplane, Smartlead, Google Workspace, Apify, Firecrawl

Actual technical stack

React 18.3 + TypeScript 5, Vite 5 (SWC)
Tailwind v3 + shadcn-ui (Radix), framer-motion v11
@tanstack/react-query v5, react-hook-form + zod
react-router-dom v6 (nested routes)
Capacitor 8 (iOS + Android, com.luup.app)
Supabase Auth - email/password + Google OAuth
Postgres 15 (Supabase) - 87 tables, ~300 RLS, 136 migrations
Supabase Edge Functions - 72 Deno fns
Supabase Storage - 9 dedicated buckets
Supabase Realtime (missions, wallets, community)
GitHub - auto-deploy on push to main
Stripe + Stripe Connect (Founding $675/mo)
Everflow (source of truth, sub1 = user UUID)
Resend via custom auth-email-hook
Mux direct upload + HLS playback + webhook
Lovable AI Gateway - Gemini 2.5 Pro + embeddings
Qdrant vector DB + Sliplane Postgres dataset
Smartlead + Google Workspace per-brand mailboxes
Apify + Firecrawl (avatar / page scraping)
n8n (long-running jobs beyond 60s edge limit)
CTO note
The robustness of the application does not come from AI-generated code alone. It comes from the use of standard technologies, source-code ownership, PostgreSQL as the database foundation, proper security controls, scalable infrastructure options, and engineering review processes.

What the CTO should confirm

  • The Lovable frontend is connected to a real Supabase backend
  • The source code is connected to GitHub and owned by LUUP
  • Supabase Auth is used properly for user identity and session management
  • PostgreSQL is being used as the database foundation
  • Row Level Security is enabled and tested
  • Business logic is handled through backend functions, not only frontend code
  • Supabase Storage is configured with private buckets where needed
  • Edge Functions are used for sensitive operations
  • n8n is used only for appropriate automations, not critical financial logic without controls
  • External API keys are stored securely
  • AI services are called from secure backend functions, not directly from the frontend
  • Production and staging environments are separated
  • The app can be maintained by engineers outside Lovable
Boundary for n8n
n8n is appropriate for automations, notifications, enrichment, internal workflows, and operational processes. It should not be the core place for wallet logic, commission calculations, payouts, tenant security, or critical financial decisions unless strong controls, logs, and backend validation exist around it.
03

C4 Architecture Model

The C4 model breaks the architecture into clear levels so the CTO can move from a high-level system view into the technical containers and backend components.

System Context

Shows where LUUP One sits in the world, who uses it, and which external systems it depends on.

Container Architecture

Shows the major technical blocks that make up LUUP One, including frontend applications, Supabase Auth, Supabase PostgreSQL, Supabase Storage, Edge Functions, webhook processing, commission engine, wallet ledger, n8n automation layer, AI services, notifications, and reporting.

Component Architecture

Shows how the backend should be organised into services such as user, tenant, merchant, mission, referral, attribution, commission, wallet, payout, billing, admin, audit, notification, automation, and AI orchestration services.

Code-Level Detail

Only needed later by the development team. This review pack focuses on Levels 1 to 3.

For the external CTO review, Levels 1 to 3 are enough to assess whether the build has the right architectural foundations.

04

C4 Level 1: System Context

This shows where LUUP One sits in the world, who uses it, and what external systems it depends on.

System Context
100%

LUUP One Platform

LUUP One Platform is the central system that allows merchants to launch customer, creator, affiliate, and ambassador-led growth campaigns.

Platform users

Luup Admin Team

Operates the Admin Panel (/admin) - Platform Overview, Monitoring, AI Monitoring, Alerts, Cron Runs, Financial, Everflow Health & Mapping, Users & Roles, Ecosystem Assignments, Communities, Content & Bug Reports, Missions, Trial Merchants, Avatar / Embed Backfill, Sandbox seeding, and Stewart Console.

Merchant / Brand Team

Founding Member subscribers ($675/mo, 14-day trial). Run onboarding wizard, fund merchant_topups wallet, create AI-generated missions via mission-engine (Gemini 2.5 Pro), publish products (Everflow- verified), approve submissions, recruit creators through the AI scout (Qdrant + Sliplane), run Smartlead sequences, and review revenue / ROI.

End User

Single user account that can act as customer, influencer, ambassador, creator, or affiliate. Joins one or more ecosystems via the Join Gate (per-ecosystem handle, avatar, cover), completes brand- funded missions, shares storefront links (/:ecosystem/:handle) carrying their Everflow sub1 = user UUID, earns cash + points + streaks, and withdraws via Stripe Connect Express.

External systems

Stripe + Stripe Connect

Merchant subscriptions ($675/mo Founding plan), wallet top-ups, Connect Express onboarding and payouts. Webhook signed via STRIPE_WEBHOOK_SECRET.

Everflow

Affiliate tracking source of truth - conversions, advertisers, affiliates, offers. Each user auto-provisioned via everflow-affiliate-create; sub1 = user UUID. Hidden behind 'Luup Tracking' branding.

Resend

All transactional + auth emails routed through the custom auth-email-hook edge function (signup, password reset, magic link, digests).

Mux

Direct upload + HLS playback + HMAC-verified asset webhook (mux-create-upload, mux-webhook).

Lovable AI Gateway

Every LLM call - Gemini 2.5 Pro for missions, agent chat, moderation, recruitment, plus embeddings. Tracked in ai_function_metrics.

Qdrant

Vector DB for creator semantic search (lead_embeddings collection synced by recruitment-embed-backfill).

Sliplane Postgres

Read-only external creator dataset (Instagram / TikTok / YouTube) - v_creator_research_search view.

Smartlead + Google Workspace

Cold-email outreach sequences with per-brand sender mailboxes provisioned via Admin SDK. Webhook fails closed when secret missing.

Apify + Firecrawl

Avatar enrichment and brand page discovery. Apify rate-limited - prefer Sliplane cache when possible.

n8n

External orchestration for long-running jobs (avatar pipeline, sandbox seeding) that exceed the 60s edge function timeout.

Supabase Storage

Private buckets: creator-profile-images, brand-logos, brand-covers, profile-avatars, profile-covers, community-media, onboarding-videos, brand-products, mission-images.

GitHub

Source of truth. Every commit to main auto-builds and publishes via Lovable, aliased to luup.com / www.luup.com.
05

C4 Level 2: Container Diagram

This shows the major technical blocks that make up LUUP One.

Container Diagram
100%

Lovable React / Vite Frontend

The frontend application generated through Lovable and built on a modern React / Vite architecture. It includes the main user-facing application for ambassadors, customers, creators, and advocates.
  • Mission discovery
  • Ecosystem joining
  • Profile setup
  • Referral links
  • Storefronts
  • Wallet view
  • Earnings tracking
  • Payout requests
  • Leaderboards
  • Badges and gamification

GitHub

The source-code repository and version-control layer.
  • The project is connected to GitHub
  • LUUP owns the repository
  • Changes can be reviewed through pull requests
  • Engineers can work on the codebase outside Lovable
  • Deployment and rollback practices are clear

Merchant Dashboard

The brand-facing control centre.
  • Merchant onboarding
  • Plan selection
  • Billing card setup
  • Wallet top-up
  • Mission creation
  • Product management
  • Submission review
  • Ambassador management
  • Campaign analytics
  • Revenue and ROI reporting
  • Team member management

Admin Dashboard

The internal Luup control panel.
  • Merchant management
  • User management
  • Platform fee configuration
  • Commission rules
  • Payout reviews
  • Manual adjustments
  • Fraud flags
  • White-label settings
  • Audit logs
  • System-wide reporting

Supabase Edge Functions / Backend APIs

The main application logic layer.
  • Authentication checks
  • Role checks
  • Tenant scoping
  • Mission logic
  • Referral logic
  • Commission calculations
  • Wallet transactions
  • Payout requests
  • Merchant settings
  • Admin actions
  • Data validation
  • Secure external API calls
  • AI service calls
  • Webhook processing support
  • API responses
Sensitive business logic should be handled through backend functions or database-level controls, not only in frontend code.

Supabase Auth

  • Signup
  • Login
  • Password reset
  • Email verification
  • Session management
  • Role assignment
  • OAuth, if used
  • Multi-factor authentication, if introduced later

Supabase PostgreSQL

  • Users
  • Merchants
  • Brands
  • Ecosystems
  • Missions
  • Submissions
  • Products
  • Referral links
  • Clicks
  • Orders
  • Commission rules
  • Commissions
  • Wallets
  • Wallet transactions
  • Payouts
  • Billing records
  • Audit logs
PostgreSQL should be treated as the database foundation for scalable relational modelling, tenant isolation, financial traceability, and auditability.

Supabase Storage

  • User avatars
  • Merchant logos
  • Mission images
  • Product images
  • Screenshot proofs
  • Uploaded UGC
  • Campaign files
Files should be stored in private buckets with signed URLs where needed.

Webhook Processor

  • Stripe (stripe-webhook, signature verified)
  • Mux (mux-webhook, HMAC verified)
  • Everflow (everflow-conversions postback)
  • Smartlead (smartlead-webhook, fails closed if secret missing)
  • Subscription created / renewed / failed
  • Wallet top-up completed
  • Conversion tracked (writes everflow_conversions + everflow_postback_logs)
  • Mux asset ready
  • Smartlead reply / bounce
Receivers run with verify_jwt=false and rely on HMAC / origin checks. Hourly reconciliation jobs (everflow-status-refresh, everflow-refunds-reconcile) keep the DB in sync with Everflow.

Commission & Earnings Engine

Splits each verified Everflow conversion into a creator credit and a platform markup.

  • Merchant commission to user wallet (mission_earnings or referral_earnings)
  • Platform markup / revshare to platform
  • Pending vs cleared balance (14-day anti-chargeback hold)
  • Refund clawbacks via everflow-refunds-reconcile
  • Tier and streak boosts via commission_tiers and tier_thresholds
Creator
Merchant commission
Platform
~5% revshare markup
Hold
14-day pending

Configurable per merchant; tier and streak modifiers layer on top.

Wallet Ledger Service

Dual-wallet model per user, plus a merchant float wallet.

Never render balances without the safeNum() utility - prevents NaN on freshly created wallets.
  • cash_balance - withdrawable after pending clears
  • pending_balance - 14-day hold (anti-chargeback)
  • points_balance - gamification, non-monetary
  • mission_earnings + referral_earnings - lifetime counters
  • Pending credit → cleared after 14d
  • Withdrawal request via stripe-payout-create (Stripe Connect Express)
  • Refund reversal / clawback
  • Manual admin adjustment (audit-logged)
  • Merchant wallet top-up via merchant-topup
  • Merchant spend on mission funding
  • Platform fee deduction

n8n Automation Layer

Used for non-critical automations, internal workflows, notification routing, enrichment, operational processes, and integrations where appropriate.
  • Internal alerts
  • Admin notifications
  • CRM sync
  • Email workflows
  • Data enrichment
  • Scheduled checks
  • Operational handoffs
  • Non-critical integration glue
n8n should not be the primary source of truth for commissions, wallets, payouts, tenant security, or critical financial logic unless it is backed by backend validation, audit logs, idempotency, and clear operational controls.

AI Orchestration Layer

Controls secure AI service calls through backend functions.
  • AI-assisted mission creation
  • Content suggestions
  • Campaign recommendations
  • Support workflows
  • Data enrichment
  • Admin productivity tools
AI service calls should be made through secure backend-controlled functions. API keys must not be exposed in the frontend.

Notification Service

  • Mission updates
  • Submission approvals
  • Submission rejections
  • Payout updates
  • Wallet changes
  • Merchant billing notices
  • Campaign alerts
  • Admin alerts

Analytics and Reporting Layer

  • Merchant GMV
  • Revenue generated
  • Clicks
  • Conversions
  • Commission paid
  • Mission performance
  • Ambassador ranking
  • Campaign ROI
  • Luup platform revenue
  • Payout liability
  • User growth
06

C4 Level 3: Component Architecture

Backend component view.

Component Architecture
100%

Component responsibilities

User Service

  • User profiles
  • Account creation
  • Identity
  • Avatar
  • Display name
  • Contact details
  • Status
  • Account suspension

Tenant / Workspace Service

Manages the multi-tenant structure. This is critical.
  • Merchant workspaces
  • Brand workspaces
  • Ecosystem access
  • Tenant boundaries
  • User membership
  • Role assignment per workspace
This prevents one merchant from seeing or modifying another merchant's data.

Merchant Service

  • Merchant profile
  • Merchant settings
  • Billing status
  • Wallet funding status
  • Commission settings
  • Platform fee settings
  • Team members
  • Store connections

Ecosystem Service

Manages ecosystems such as LUUP One, Combat Market, FanFuel, future verticals, and white-label environments.
  • Theme
  • Branding
  • Missions
  • Products
  • Users
  • Ranks
  • Badges
  • Commission rules
  • Campaign logic

Mission Service

  • Mission creation
  • Mission editing
  • Mission status
  • Mission capacity
  • Mission deadlines
  • Reward rules
  • Mission visibility
  • Mission duplication
  • Mission analytics
DraftLivePausedCompletedArchived

Submission Review Service

  • User submissions
  • Proof uploads
  • Approval
  • Rejection
  • Reviewer feedback
  • Submission history
  • Fraud flags
  • Bulk approvals
SubmittedIn reviewApprovedRejectedRewarded

Product Service

  • Product catalogue
  • Product images
  • Product pricing
  • Product categories
  • Product tags
  • Featured products
  • Storefront products
  • Affiliate link generation

Referral Service

  • Referral codes
  • Referral links
  • Ambassador links
  • Customer referral links
  • Storefront links
  • Referral tree
  • Referral ownership
  • Referral hierarchy

Attribution Service

Determines who gets credit for a sale.
  • Click tracking
  • Signup tracking
  • Customer attribution
  • Order attribution
  • Repeat purchase attribution
  • First-click or last-click rules
  • Everflow data matching
  • Manual attribution corrections

Order Service

Stores commerce events.
  • Order creation
  • Order value
  • Customer ID
  • Merchant ID
  • Product line items
  • Refund status
  • Cancellation status
  • Attribution status
  • Commission status

Commission Engine

Calculates financial rewards.
  • Tier 1 commission
  • Tier 2 commission
  • Tier 3 commission
  • Tier 4 commission
  • Mission rewards
  • Product-specific commission
  • Merchant-specific rules
  • Refund clawbacks
  • Fee deductions
  • Pending and cleared states

Wallet Ledger Service

The financial source of truth.
  • User wallet
  • Merchant float wallet
  • Platform fee wallet
  • Ledger entries
  • Balance calculation
  • Pending funds
  • Cleared funds
  • Adjustments
  • Reversals

Payout Service

  • Payout requests
  • Minimum payout threshold
  • Payout approval
  • Payout method
  • Payout status
  • Payout failure
  • Payout retry
  • Withdrawal fees
  • Payout audit logs

Billing Service

  • Merchant subscriptions
  • Stripe billing
  • Plan changes
  • Card setup
  • Subscription renewal
  • Failed payments
  • Trial status
  • Wallet top-ups
  • Invoices

Admin Service

Handles internal platform operations. Allows Luup to:
  • View all merchants
  • View all users
  • Pause merchants
  • Suspend users
  • Adjust wallet transactions
  • Configure platform fees
  • Resolve disputes
  • Approve payouts
  • Manage white-label settings

Audit Log Service

Stores important actions.
  • Role changed
  • Mission created
  • Mission approved
  • Commission generated
  • Wallet adjusted
  • Payout requested
  • Payout approved
  • Merchant fee changed
  • Webhook received
  • Admin override performed

Notification Service

Sends system, merchant, user, and admin notifications.

File Upload Service

Controls secure uploads, private storage, signed URLs, file ownership, tenant-scoped access, and proof file retrieval.

Automation Orchestration Service

Coordinates appropriate n8n workflows for non-critical automations, internal workflows, enrichment, scheduled tasks, and operational processes.

AI Orchestration Service

Controls AI service calls through backend functions so API keys stay secure and AI outputs can be validated before affecting important system records.
07

Data Model / ERD

This is one of the most important parts for the CTO. The data model should prove that LUUP One can support multiple merchants, multiple ecosystems, multiple brands, multiple users, multiple roles, referral hierarchies, attribution, commissions, wallets, payouts, and audit logs.

The data model should support

  • Multiple merchants
  • Multiple ecosystems
  • Multiple brands
  • Multiple users
  • Multiple roles
  • Referral hierarchies
  • Attribution
  • Commissions
  • Wallets
  • Payouts
  • Audit logs
Entity Relationship Diagram
100%

Do not include detailed table definitions in this section. The ERD and high-level entity relationship model are enough for this page.

Core entity groups (87 user tables)

Identity & access

  • profiles
  • user_roles (enum: admin / merchant / user)
  • ecosystem_profiles
  • ecosystem_memberships
  • user_blocks
  • user_follows
  • notification_preferences

Ecosystem content

  • ecosystems
  • brands
  • brand_ecosystems
  • brand_owners
  • brand_products
  • products
  • storefronts
  • storefront_products
  • storefront_product_clicks

Missions & gamification

  • missions
  • user_missions
  • mission_submissions
  • weekly_challenges
  • weekly_challenge_completions
  • streak_rewards
  • user_streaks
  • tier_thresholds
  • commission_tiers
  • badges
  • user_badges

Financial

  • wallets (cash / pending / points)
  • wallet_transactions
  • earnings
  • transactions
  • user_payout_methods
  • user_payouts
  • merchant_subscriptions
  • merchant_topups
  • merchant_founding_whitelist
  • brand_prize_funds
  • referrals

Affiliate tracking (Everflow)

  • everflow_conversions (35 cols mirroring postback)
  • everflow_postback_logs
  • brand_tracking_verifications

Community

  • social_posts
  • social_post_likes / comments / reposts
  • community_post_flags
  • community_user_strikes
  • community_groups + members
  • direct_messages
  • broadcasts
  • content_reports
  • moderation_actions
  • brand_moderation_settings
  • trending_tags

Recruitment (AI scout)

  • recruitment_candidates
  • recruitment_campaigns + candidates
  • recruitment_activity
  • recruitment_lead_scores
  • recruitment_backfill_runs / state
  • lead_embeddings
  • lead_search_chunks / scalar
  • brand_recruitment_profile

Sandbox / demo

  • sandbox_demo_users
  • sandbox_ambassadors
  • sandbox_activity_queue
  • sandbox_template_meta - hidden from prod feeds by RLS

Ops & telemetry

  • system_alerts
  • cron_run_logs
  • ai_function_metrics
  • bug_reports
  • email_verification_audit / tokens
  • notification_email_log
  • send_email_audit
  • avatar_enrich_runs
  • app_runtime_settings
  • waitlist_signups
CTO note
The CTO should validate whether the actual database reflects these relationships, especially merchant isolation, referral ownership, order attribution, commission traceability, wallet ledger entries, and audit logs.
08

Security and Permissions Model

LUUP One should be designed around clear security principles. Authentication proves who the user is. Authorization controls what they can do. Tenant isolation controls what data they can access.

01

Authentication proves who the user is

02

Authorization controls what they can do

03

Tenant isolation controls what data they can access

04

Audit logs record important actions

05

Financial actions must be ledger-based

06

External webhooks must be verified

07

Sensitive files must be private

08

No sensitive logic should live only in the frontend

09

AI service calls must happen through backend-controlled functions

10

Automation workflows must not bypass security or financial controls

Frontend cannot enforce security
The frontend can hide buttons, but the backend must enforce the actual rules.
Row Level Security
Row Level Security should be enabled and tested in Supabase. If RLS is disabled, incomplete, or only partially implemented, tenant isolation must be considered a major risk.
09

Authentication Model

Supabase Auth handles identity, sessions, verification and recovery. Email + Google OAuth, with disposable-email blocking and a custom edge hook that routes every auth email through Resend with branded templates.

In production today

  • Email + password and Google OAuth
  • Disposable-email blocking (src/lib/verifyEmailDomain.ts) before signup
  • auth-email-hook edge function → Resend with branded templates
  • AuthContext side effects on every sign-in: ensureProfile, attach_referral_by_affiliate, everflow-affiliate-create, recordDailyStreakCheckIn
  • Per-ecosystem identity via ecosystem_profiles + EcosystemJoinGate (handle / avatar / cover)
  • Non-blocking session restore (skeletons while getSession resolves)
  • Stale-token handling: silent sign-out + redirect to /user/login on failed JWT refresh
  • Native deep-link OAuth callbacks via nativeBootstrap.ts (Capacitor)
  • Account deletion endpoint /account/delete + delete-account edge function (Apple App Store requirement)

Recommended hardening

  • MFA for platform admins (Super Admin role)
  • MFA for Merchant Admin owners
  • Session revocation UI + device / session visibility
  • Stronger password policy + breached-password check
  • Formal separation of staging vs production user pools
10

Role Model

The permission model is intentionally simple. There are three roles: Super Admin, Merchant Admin, and User. A User may act as a customer, influencer, ambassador, or affiliate depending on how they engage with a merchant.

Super Admin

Luup internal owner-level access across the entire platform.

  • View all merchants
  • View all users
  • View all payouts
  • Configure platform fees
  • Manage white-label settings
  • Suspend merchants
  • Suspend users
  • Approve payouts
  • Create admin users
  • Access audit logs
  • Adjust wallets
  • Change platform configuration

Merchant Admin

Full administrative access scoped to a single merchant workspace.

  • Manage merchant settings
  • Manage billing
  • Top up wallet
  • Create and edit missions
  • Approve or reject submissions
  • Manage products
  • Invite team members
  • View merchant analytics
  • Export merchant data
  • Manage ambassadors
  • View merchant audit logs
  • Access other merchants' data
  • Change platform fees
  • Suspend other merchants
  • Create platform admins

A single User account that can act as a customer, influencer, ambassador, or affiliate. Capabilities depend on how the user engages with a merchant or mission, not on a separate role.

User

Customer, influencer, ambassador, or affiliate.

  • Sign up and complete profile
  • Join ecosystems
  • Join missions
  • Submit proof
  • Generate referral links
  • Refer friends and customers
  • View own clicks, sales, and earnings
  • Request payouts
  • View own wallet ledger
  • Purchase through referral links
  • Access merchant dashboards
  • Approve submissions
  • Change commissions
  • View other users' earnings
  • Access platform admin tools
11

Permission Matrix

This matrix shows which roles can perform core platform actions. Use it as the basis for backend permission checks, not just frontend visibility rules.

ActionSuper AdminMerchant AdminUser
View all merchantsYesNoNo
Create merchantYesNoNo
Suspend merchantYesNoNo
Manage billingYesYesNo
Top up merchant walletYesYesNo
Create missionYesYesNo
Edit missionYesYesNo
Approve submissionYesYesNo
Reject submissionYesYesNo
Join missionNoNoYes
Submit proofNoNoYes
Generate referral linkNoNoYes
View own earningsNoNoYes
View all user earningsYesMerchant onlyNo
Adjust walletYesNoNo
Request payoutNoNoYes
Approve payoutYesOptionalNo
View audit logsYesMerchant onlyNo
Change platform feesYesNoNo
Manage team membersYesYesNo
12

Tenant Isolation Model

Tenant isolation is one of the most important parts of LUUP One because multiple merchants, brands, ecosystems, users, campaigns, referrals, wallets, and payouts exist inside the same platform.

Recommended tenant boundary

The recommended tenant boundary is merchant_id as the commercial workspace boundary.

  • brand_id for brands under a merchant
  • ecosystem_id for verticals or white-label environments
  • user_id for individual user ownership

Core rule

Every sensitive table should be scoped by at least one of these:

  • merchant_id
  • brand_id
  • ecosystem_id
  • user_id

Scope examples

Missions

Need merchant_id and ecosystem_id.

Products

Need merchant_id and brand_id.

Orders

Need merchant_id.

Commissions

Need merchant_id and earning_user_id.

Wallets

Need owner_type and owner_id.

Payouts

Need user_id and wallet_id.

Audit logs

Need actor_user_id and merchant_id where relevant.

Access control rules

Merchant data access

A merchant user can only access records where merchant_id matches one of their merchant_team_members records.

Ecosystem access

An ambassador can only access private ecosystem content where they have an active ecosystem_memberships record.

Wallet access

A user can only view wallet records where wallet.owner_type = user and wallet.owner_id = current_user.id.

A merchant can only view merchant float wallets where wallet.owner_type = merchant and wallet.owner_id = merchant_id they belong to.

Admin access

Admins can access cross-tenant data, but every action should be recorded in audit_logs.

Supabase Row Level Security validation

  • RLS should be enabled on sensitive tables
  • Policies should scope data by merchant_id, ecosystem_id, brand_id, or user_id
  • Users should not be able to access data by changing IDs in URLs or API calls
  • Service role keys must not be exposed in frontend code
  • Admin cross-tenant access should be performed through secure backend functions
  • RLS policies should be tested with real test users across different roles
13

Security Architecture Diagram

Every protected action should pass through authentication, role validation, tenant scope validation, permission validation, and audit logging.

Security Architecture
100%

Every protected action should pass through

  • Authentication
  • Role validation
  • Tenant scope validation
  • Permission validation
  • Row Level Security where applicable
  • Audit logging
Source of truth
The frontend can improve usability by hiding unavailable actions, but it must not be the source of security truth.
14

Financial Security Model

Because LUUP One handles commissions, wallets, merchant float, payout requests, withdrawal fees, platform fees, refunds, and clawbacks, the financial model must be ledger-based.

Ledger-based wallet principle

The wallet should be ledger-based. Do not rely on a single editable balance field. Every financial event should create an immutable wallet transaction.
Commission to payout flow
100%

Required protections

Users cannot edit commission values
Users cannot create their own wallet credits
Users cannot withdraw pending funds
Users cannot withdraw below the minimum threshold
Users cannot request duplicate payouts for the same funds
Refunds must reverse or claw back commissions
Admin wallet adjustments must be logged
Payout approval must be permission-controlled
Webhook events must be idempotent
n8n workflows must not bypass financial controls
AI-generated actions must not directly alter wallet, commission, payout, or ledger records without human or backend validation
15

Webhook Security Model

External systems are not trusted blindly. LUUP receives webhooks from Stripe, Mux, Everflow, and Smartlead. Each receiver is verify_jwt=false and validates an HMAC signature (Smartlead fails closed if its secret is missing) before persisting the raw payload and triggering downstream logic.

Webhook processing pipeline
100%

Required webhook controls

Verify signatures
Store raw payloads
Use idempotency keys
Process each event once
Retry failed events
Log failures
Alert on repeated failures
Never trust client-side payment confirmation alone
Trigger n8n only after the backend has validated and stored the event
Keep financial updates inside controlled backend logic
16

File Upload Security Model

LUUP missions may require screenshots, links, UGC, and proof files. These files should be private, tenant-scoped, and validated before storage. In the assumed build stack, this should use Supabase Storage.

Allowed file types only
Maximum file size
Private Supabase Storage buckets
Signed URLs
Tenant-scoped file access
Virus or malware scanning where possible
No executable uploads
Upload ownership stored in database
Access checked before file download
File deletion or retention policy
Sensitive proof files
Mission proof files can contain sensitive user or merchant information, so file access must be controlled through backend permission checks and storage policies.
17

Data Protection Model

LUUP One may store personal data, referral data, payout data, mission data, uploaded files, and earning history. The platform should minimise unnecessary storage and protect sensitive data throughout the lifecycle.

Personal data LUUP may store

  • Name
  • Email
  • Profile image
  • Country
  • Payment method references
  • Payout method references
  • Referral activity
  • Mission submissions
  • Wallet and earning history

Recommended controls

  • Encrypt data in transit
  • Encrypt data at rest
  • Hash sensitive identifiers where possible
  • Avoid storing unnecessary payment data
  • Use Stripe or payment providers for card data
  • Use private Supabase Storage buckets
  • Allow user data deletion where legally required
  • Keep audit logs for financial and compliance reasons
  • Create a clear data retention policy
  • Keep AI prompts and outputs out of sensitive records unless necessary
  • Avoid sending unnecessary personal or financial data to AI providers
  • Separate staging and production data
18

Admin and Audit Model

Every sensitive admin, financial, security, automation, AI, and operational action should be logged so Luup can reconstruct what happened during disputes, fraud reviews, payout reviews, and technical incidents.

Actions to log

Login
Failed login
Role change
Merchant created
Merchant suspended
Mission created
Mission edited
Submission approved
Submission rejected
Commission created
Commission reversed
Wallet adjusted
Payout requested
Payout approved
Payout rejected
Payout completed
Merchant fee changed
Webhook received
Webhook failed
Refund processed
n8n workflow triggered
AI service called
AI-generated recommendation accepted
Admin override performed

Audit log should include

  • Actor user ID
  • Action
  • Entity type
  • Entity ID
  • Merchant scope
  • Old value, where needed
  • New value, where needed
  • Timestamp
  • IP hash
  • Metadata
  • Source system
  • Related webhook event, where relevant
  • Related automation workflow, where relevant
19

The Most Important CTO Question

Is LUUP One built as a real multi-tenant SaaS platform, or is it a high-fidelity prototype that needs a production-grade backend?

This architecture pack gives the review structure needed to answer that honestly and professionally.

Recommended next stepValidate the real build against this architecture, then produce a truth table showing what is built, partially built, mocked, or missing.