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.
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?
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.
Actual technical stack
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
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
Container Architecture
Component Architecture
Code-Level Detail
For the external CTO review, Levels 1 to 3 are enough to assess whether the build has the right architectural foundations.
C4 Level 1: System Context
This shows where LUUP One sits in the world, who uses it, and what external systems it depends on.
LUUP One Platform
Platform users
Luup Admin Team
Merchant / Brand Team
End User
External systems
Stripe + Stripe Connect
Everflow
Resend
Mux
Lovable AI Gateway
Qdrant
Sliplane Postgres
Smartlead + Google Workspace
Apify + Firecrawl
n8n
Supabase Storage
GitHub
C4 Level 2: Container Diagram
This shows the major technical blocks that make up LUUP One.
Lovable React / Vite Frontend
- Mission discovery
- Ecosystem joining
- Profile setup
- Referral links
- Storefronts
- Wallet view
- Earnings tracking
- Payout requests
- Leaderboards
- Badges and gamification
GitHub
- 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
- 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
- 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
- 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
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
Supabase Storage
- User avatars
- Merchant logos
- Mission images
- Product images
- Screenshot proofs
- Uploaded UGC
- Campaign files
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
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
Configurable per merchant; tier and streak modifiers layer on top.
Wallet Ledger Service
Dual-wallet model per user, plus a merchant float wallet.
- 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
- Internal alerts
- Admin notifications
- CRM sync
- Email workflows
- Data enrichment
- Scheduled checks
- Operational handoffs
- Non-critical integration glue
AI Orchestration Layer
- AI-assisted mission creation
- Content suggestions
- Campaign recommendations
- Support workflows
- Data enrichment
- Admin productivity tools
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
C4 Level 3: Component Architecture
Backend component view.
Component responsibilities
User Service
- User profiles
- Account creation
- Identity
- Avatar
- Display name
- Contact details
- Status
- Account suspension
Tenant / Workspace Service
- Merchant workspaces
- Brand workspaces
- Ecosystem access
- Tenant boundaries
- User membership
- Role assignment per workspace
Merchant Service
- Merchant profile
- Merchant settings
- Billing status
- Wallet funding status
- Commission settings
- Platform fee settings
- Team members
- Store connections
Ecosystem Service
- 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
Submission Review Service
- User submissions
- Proof uploads
- Approval
- Rejection
- Reviewer feedback
- Submission history
- Fraud flags
- Bulk approvals
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
- 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
- Order creation
- Order value
- Customer ID
- Merchant ID
- Product line items
- Refund status
- Cancellation status
- Attribution status
- Commission status
Commission Engine
- 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
- 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
- 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
- Role changed
- Mission created
- Mission approved
- Commission generated
- Wallet adjusted
- Payout requested
- Payout approved
- Merchant fee changed
- Webhook received
- Admin override performed
Notification Service
File Upload Service
Automation Orchestration Service
AI Orchestration Service
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
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
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.
Authentication proves who the user is
Authorization controls what they can do
Tenant isolation controls what data they can access
Audit logs record important actions
Financial actions must be ledger-based
External webhooks must be verified
Sensitive files must be private
No sensitive logic should live only in the frontend
AI service calls must happen through backend-controlled functions
Automation workflows must not bypass security or financial controls
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
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.
Platform role
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 role
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
User role
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
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.
| Action | Super Admin | Merchant Admin | User |
|---|---|---|---|
| View all merchants | Yes | No | No |
| Create merchant | Yes | No | No |
| Suspend merchant | Yes | No | No |
| Manage billing | Yes | Yes | No |
| Top up merchant wallet | Yes | Yes | No |
| Create mission | Yes | Yes | No |
| Edit mission | Yes | Yes | No |
| Approve submission | Yes | Yes | No |
| Reject submission | Yes | Yes | No |
| Join mission | No | No | Yes |
| Submit proof | No | No | Yes |
| Generate referral link | No | No | Yes |
| View own earnings | No | No | Yes |
| View all user earnings | Yes | Merchant only | No |
| Adjust wallet | Yes | No | No |
| Request payout | No | No | Yes |
| Approve payout | Yes | Optional | No |
| View audit logs | Yes | Merchant only | No |
| Change platform fees | Yes | No | No |
| Manage team members | Yes | Yes | No |
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
Need merchant_id and ecosystem_id.
Need merchant_id and brand_id.
Need merchant_id.
Need merchant_id and earning_user_id.
Need owner_type and owner_id.
Need user_id and wallet_id.
Need actor_user_id and merchant_id where relevant.
Access control rules
Merchant data access
Ecosystem access
Wallet access
A merchant can only view merchant float wallets where wallet.owner_type = merchant and wallet.owner_id = merchant_id they belong to.
Admin access
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
Security Architecture Diagram
Every protected action should pass through authentication, role validation, tenant scope validation, permission validation, and audit logging.
Every protected action should pass through
- Authentication
- Role validation
- Tenant scope validation
- Permission validation
- Row Level Security where applicable
- Audit logging
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
Required protections
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.
Required webhook controls
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.
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
- 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
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
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
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.