Technical Architecture · v1.0
RUH AERIOS TECHNOLOGIES LLC
Complete App Architecture, Cloudflare Strategy & Zero-Budget Infrastructure Plan
🏗 System Architecture Overview 01
Core principle: Every layer of this stack is free at launch. Cloudflare handles edge, CDN, and compute. Supabase handles auth and database. Together they replace $2,000+/month of traditional infrastructure — at zero cost until significant scale.
Full System Architecture — RUH AERIOS Platform
Users →
Browser / Mobile App
Cloudflare DNS + CDN
Cloudflare Pages (Next.js)
API Layer →
Cloudflare Workers (Edge Functions)
Supabase (Auth + PostgreSQL)
Cloudflare D1 (SQLite Edge)
Storage →
Cloudflare R2 (Files / Videos)
Cloudflare Images (Thumbnails)
Payments →
Credit Ledger (D1/Supabase)
Stripe / Wise / Razorpay
Real Payout on Withdrawal
Email →
Cloudflare Email Routing
Resend.com (Transactional)
Security →
Cloudflare Tunnel (Zero-Trust)
CF WAF + DDoS Protection
☁️ Cloudflare — Complete Free Tier Analysis 02
YES — Cloudflare works perfectly for RUH AERIOS at zero cost. The free tier is enterprise-grade and scales to 100,000+ users before any paid upgrade is needed. Here is the complete breakdown:
Cloudflare ProductFree Tier LimitsRUH AERIOS UsageVerdict
CF Pages (Hosting)500 builds/mo · Unlimited bandwidthPlatform frontend, landing pages✓ Perfect
CF Workers (Compute)100,000 req/day · 10ms CPU/reqAPI routes, credit logic, webhooks✓ Excellent
CF D1 (SQLite DB)5GB storage · 5M reads/day freeCredit ledger, user aliases, projects✓ Sufficient to 100k users
CF R2 (Object Store)10GB/mo · Zero egress feesCourse videos, project files, docs✓ Zero egress = massive saving
CF DNSUnlimited · DDoS protectedruhaeriostech.com routing✓ Free forever
CF SSL/TLSFree HTTPS for all domainsAll endpoints secured✓ Enterprise SSL free
CF WAF (Basic)Free managed rulesetOWASP top 10 protection✓ Good enough at launch
CF Email RoutingUnlimited email addresseshello@, support@, noreply@✓ Perfect
CF TunnelFree foreverSecure origin, zero-trust access✓ Enterprise security free
CF ImagesPaid ($5/mo for 100k)Profile avatars, course thumbnailsUse R2 + transform instead
CF Stream (Video)Paid ($5/mo per 1k min)Course video hostingUse R2 + direct play at launch
Video strategy at launch (zero cost): Store course videos in Cloudflare R2. Use signed URLs with 24-hour expiry for access control. Serve via CF CDN. This replaces CF Stream ($5+/mo) entirely. When revenue allows, upgrade to Stream for better analytics.

Cloudflare Workers — Credit Ledger Logic

// Cloudflare Worker: Credit Transfer Handler
// Deploy free at: workers.dev

export default {
  async fetch(request, env) {
    const { action, from, to, amount, projectId } = 
      await request.json();

    // All operations are atomic via D1 transactions
    const db = env.DB; // Cloudflare D1 binding

    if (action === 'transfer') {
      await db.batch([
        // Debit sender
        db.prepare(`UPDATE credit_ledger 
          SET balance = balance - ? 
          WHERE alias_id = ? AND balance >= ?`)
          .bind(amount, from, amount),
        // Credit receiver (90% of amount)
        db.prepare(`UPDATE credit_ledger 
          SET balance = balance + ? 
          WHERE alias_id = ?`)
          .bind(amount * 0.9, to),
        // Platform fee (10%) goes to RUH AERIOS treasury
        db.prepare(`UPDATE credit_ledger 
          SET balance = balance + ? 
          WHERE alias_id = 'RUHAERIOSLLC'`)
          .bind(amount * 0.1),
        // Log transaction
        db.prepare(`INSERT INTO transactions 
          (from_alias, to_alias, amount, fee, project_id, ts) 
          VALUES (?, ?, ?, ?, ?, datetime('now'))`)
          .bind(from, to, amount, amount * 0.1, projectId)
      ]);
      return Response.json({ success: true });
    }
  }
}

Cloudflare Pages — Next.js Deployment

# wrangler.toml — Cloudflare configuration
name = "ruh-aerios"
compatibility_date = "2024-01-01"
pages_build_output_dir = ".next"

[[d1_databases]]
binding = "DB"
database_name = "ruh-aerios-prod"
database_id = "your-d1-id-here"

[[r2_buckets]]
binding = "STORAGE"
bucket_name = "ruh-aerios-files"

[vars]
PLATFORM_ALIAS = "RUHAERIOSLLC"
PROJECT_FEE_PCT = "0.10"
TRAINING_FEE_PCT = "0.15"
🗄 Database Schema — Supabase + Cloudflare D1 03
Strategy: Use Supabase PostgreSQL for complex relational queries (auth, profiles, projects). Use Cloudflare D1 (SQLite at edge) for the hot credit ledger — it needs to be globally fast and always available.
-- ═══════════════════════════════════════ -- SUPABASE POSTGRESQL SCHEMA -- RUH AERIOS Platform Database v1.0 -- ═══════════════════════════════════════ -- USERS (real identity, server-side only, never exposed) CREATE TABLE users ( id UUID PRIMARY KEY DEFAULT gen_random_uuid(), email TEXT UNIQUE NOT NULL, alias_id TEXT UNIQUE NOT NULL, -- NX-XXXX format created_at TIMESTAMPTZ DEFAULT now(), kyc_status TEXT DEFAULT 'pending', -- for withdrawals only is_founder BOOLEAN DEFAULT false ); -- ALTER EGOS (public-facing anonymous profiles) CREATE TABLE alter_egos ( alias_id TEXT PRIMARY KEY, -- NX-4471 format display_name TEXT, -- optional custom alias name role TEXT, -- 'talent' | 'client' | 'trainer' skills TEXT[], skill_score NUMERIC DEFAULT 0, rep_score NUMERIC DEFAULT 0, total_earned NUMERIC DEFAULT 0, badges TEXT[] DEFAULT '{}', created_at TIMESTAMPTZ DEFAULT now() ); -- PROJECTS CREATE TABLE projects ( id UUID PRIMARY KEY DEFAULT gen_random_uuid(), client_alias TEXT REFERENCES alter_egos(alias_id), title TEXT NOT NULL, description TEXT, skills_needed TEXT[], budget NUMERIC NOT NULL, -- in credits (₳) status TEXT DEFAULT 'open', -- open|active|complete|disputed talent_alias TEXT REFERENCES alter_egos(alias_id), coown_pct NUMERIC DEFAULT 10, -- platform co-ownership % created_at TIMESTAMPTZ DEFAULT now(), completed_at TIMESTAMPTZ ); -- BIDS CREATE TABLE bids ( id UUID PRIMARY KEY DEFAULT gen_random_uuid(), project_id UUID REFERENCES projects(id), talent_alias TEXT REFERENCES alter_egos(alias_id), amount NUMERIC, proposal TEXT, status TEXT DEFAULT 'pending', created_at TIMESTAMPTZ DEFAULT now() ); -- COURSES CREATE TABLE courses ( id UUID PRIMARY KEY DEFAULT gen_random_uuid(), trainer_alias TEXT REFERENCES alter_egos(alias_id), title TEXT, description TEXT, price NUMERIC, -- in credits r2_path TEXT, -- Cloudflare R2 storage path coown_pct NUMERIC DEFAULT 15, -- platform share total_sales INT DEFAULT 0, created_at TIMESTAMPTZ DEFAULT now() ); -- CO-OWNERSHIP REGISTRY (permanent ledger) CREATE TABLE coownership ( id UUID PRIMARY KEY DEFAULT gen_random_uuid(), delivery_id TEXT NOT NULL, -- project_id or course_id delivery_type TEXT, -- 'project'|'course'|'product'|'ip' creator_alias TEXT, platform_pct NUMERIC, revenue_share NUMERIC DEFAULT 0, -- total earned so far status TEXT DEFAULT 'active', registered_at TIMESTAMPTZ DEFAULT now() ); -- WITHDRAWALS CREATE TABLE withdrawals ( id UUID PRIMARY KEY DEFAULT gen_random_uuid(), alias_id TEXT, credits NUMERIC, -- credits being converted real_amount NUMERIC, -- real money paid out currency TEXT DEFAULT 'USD', stripe_id TEXT, status TEXT DEFAULT 'pending', created_at TIMESTAMPTZ DEFAULT now() );
-- ═══════════════════════════════ -- CLOUDFLARE D1 SCHEMA (Edge) -- Hot Credit Ledger — globally fast -- ═══════════════════════════════ CREATE TABLE credit_ledger ( alias_id TEXT PRIMARY KEY, balance REAL NOT NULL DEFAULT 0, locked REAL DEFAULT 0, -- escrowed credits updated_at TEXT DEFAULT (datetime('now')) ); CREATE TABLE transactions ( id TEXT PRIMARY KEY, from_alias TEXT, to_alias TEXT, amount REAL, fee REAL, type TEXT, -- 'project'|'training'|'consulting' project_id TEXT, ts TEXT DEFAULT (datetime('now')) ); CREATE INDEX idx_tx_alias ON transactions(from_alias); CREATE INDEX idx_tx_ts ON transactions(ts);
🔄 Core Application Flows 04

Flow 1: User Registration → Alter Ego Creation

REGISTRATION FLOW
1. User enters email + sets passwordSupabase Auth
2. System generates unique NexaID (NX-XXXX)CF Worker
3. Alter Ego record created in alter_egos tableSupabase DB
4. Credit ledger entry created with 0 balanceCF D1
5. Welcome email sent via ResendResend API
6. User sees their Alter Ego dashboard (NexaID only)✓ Complete

Flow 2: Project Lifecycle

PROJECT FLOW — CREDIT ESCROW MODEL
1. Client posts project with ₳X budgetProject created, status: open
2. Client's ₳X locked in escrow (locked field)CF D1 ledger
3. Talent Alter Egos bid anonymouslyBids table
4. Client selects bid → project status: activeProject updated
5. Work delivered → client approves milestoneManual or auto approval
6. 90% credits → talent · 10% → RUH AERIOSCF Worker atomic batch
7. Co-ownership record registered in coownership tableSupabase DB
8. Talent can now withdraw real moneyStripe / Wise payout

Flow 3: Withdrawal (Credits → Real Money)

WITHDRAWAL FLOW — THIS IS RUH AERIOS REAL REVENUE EVENT
1. Talent requests withdrawal of ₳1,000 creditsWithdrawal request created
2. KYC check (only needed at first withdrawal)Supabase users.kyc_status
3. System calculates: credits × conversion ratee.g., ₳1,000 = $100 USD
4. Platform deducts 1–2% FX/processing feeRUH AERIOS earns real $$$
5. Stripe / Wise payout initiated to talent's bankReal money out
6. Credits deducted from D1 ledger✓ Transaction complete
🎭 Alter Ego System — Technical Design 05
// lib/alterEgo.ts — Alter Ego generation and management

export function generateNexaId(): string {
  // Format: NX-XXXX where X is alphanumeric
  const chars = 'ABCDEFGHJKLMNPQRSTUVWXYZ23456789';
  const code = Array.from(
    { length: 4 }, 
    () => chars[Math.floor(Math.random() * chars.length)]
  ).join('');
  return `NX-${code}`;
}

export async function createAlterEgo(
  supabase: SupabaseClient,
  userId: string,
  role: 'talent' | 'client' | 'trainer',
  skills: string[]
) {
  const alias_id = generateNexaId();
  
  // Create in Supabase (profile data)
  const { data } = await supabase
    .from('alter_egos')
    .insert({ alias_id, role, skills, skill_score: 0 });
  
  // Create in D1 (credit ledger)
  await fetch('/api/ledger/create', {
    method: 'POST',
    body: JSON.stringify({ alias_id, balance: 0 })
  });
  
  // Link real user to alias (server-side only)
  await supabase.from('users')
    .update({ alias_id }).eq('id', userId);
    
  return alias_id;
}

// Reputation score calculation
export function calcRepScore(stats: {
  completedProjects: number;
  avgRating: number;
  onTimeDelivery: number;
  coownAssets: number;
}): number {
  return (
    stats.completedProjects * 10 +
    stats.avgRating * 20 +
    stats.onTimeDelivery * 15 +
    stats.coownAssets * 5
  );
}
🤝 Co-Ownership Engine 06
Delivery TypeAuto-Detect TriggerPlatform %Record Type
Freelance ProjectProject milestone approved10%Revenue share per payment
SaaS / SoftwareProject tagged 'product-build'20%Equity stake on all sales
Training CourseCourse published to marketplace15%Per-sale royalty forever
ConsultingConsulting session completed12%Per-session revenue share
IP / PatentProject tagged 'ip-creation'30%Licensing royalty stream
// Co-ownership registration — runs on every delivery completion
export async function registerCoOwnership(
  delivery: Delivery,
  creatorAlias: string
) {
  const platformPct = getPlatformPct(delivery.type);
  
  await supabase.from('coownership').insert({
    delivery_id:   delivery.id,
    delivery_type: delivery.type,
    creator_alias: creatorAlias,
    platform_pct:  platformPct,
    status:        'active'
  });

  // Generate on-platform "certificate" for the creator
  await issueCertificate(creatorAlias, delivery, platformPct);
}

function getPlatformPct(type: string): number {
  const rates: Record<string, number> = {
    project:    0.10,
    saas:       0.20,
    course:     0.15,
    consulting: 0.12,
    ip:         0.30,
    hardware:   0.25,
    ai_model:   0.30
  };
  return rates[type] ?? 0.10;
}
🚀 Zero-Budget Deployment Guide — Day 1 to Live 07
01

Create Cloudflare Account (Free)

Go to cloudflare.com → Create free account. Add your domain (ruhaeriostech.com from Namecheap ~$10). Point nameservers to Cloudflare. SSL automatically provisioned in <5 min.

02

Set Up Cloudflare D1 Database

Install Wrangler CLI: npm install -g wrangler. Run: wrangler d1 create ruh-aerios-prod. Copy the database_id. Run the D1 schema SQL above to initialize the credit ledger tables.

03

Set Up Supabase (Free)

Go to supabase.com → New project. Run the Supabase schema SQL above. Copy your SUPABASE_URL and SUPABASE_ANON_KEY. Enable Email auth. Set up Row Level Security (RLS) — critical: users can only see their own alias_id, never others' real emails.

04

Create Next.js App + Configure CF Pages

Run: npx create-next-app@latest ruh-aerios --typescript. Push to GitHub. In CF Pages → New Project → Connect GitHub → Select repo. Set build command: npm run build. Set env vars: SUPABASE_URL, SUPABASE_KEY, etc. Deploy. Done.

05

Deploy Cloudflare Workers (Credit Ledger API)

Create workers/ directory. Paste the credit transfer Worker code above. Run: wrangler deploy. Worker runs at: api.ruhaeriostech.com/ledger/*. 100,000 requests/day free.

06

Set Up R2 Storage (Course Files)

Run: wrangler r2 bucket create ruh-aerios-files. Use signed URLs for secure access: files are private, URLs expire in 24h. No egress fees ever — Cloudflare absorbs CDN bandwidth cost entirely.

07

Configure Stripe for Withdrawals

Create free Stripe account. Enable Stripe Connect (for paying out to talent globally). Add STRIPE_SECRET_KEY to CF Pages env vars. Stripe charges 0.25% + $0.25 per payout — only cost is on actual earned money, which is already revenue. Zero setup cost.

08

Set Up Email via Cloudflare Email Routing + Resend

In CF Dashboard → Email Routing → Add: [email protected], support@, noreply@. Route to a Gmail inbox. For transactional emails, create free Resend.com account (3,000 emails/month free). Add RESEND_API_KEY to env vars. Done.

Complete Zero-Budget Tech Stack 08
LayerToolCostFree UntilCloudflare?
Frontend HostingCloudflare Pages$0Forever✓ CF
Frontend FrameworkNext.js 14$0Forever
StylingTailwind CSS$0Forever
Edge ComputeCloudflare Workers$0100k req/day✓ CF
Edge DatabaseCloudflare D1$05GB / 5M reads/day✓ CF
Main DatabaseSupabase PostgreSQL$0500MB / 2 projects
AuthenticationSupabase Auth$050k MAU free
File StorageCloudflare R2$010GB/mo + free egress✓ CF
CDNCloudflare CDN$0Unlimited bandwidth✓ CF
SSL/HTTPSCloudflare SSL$0Forever✓ CF
DNSCloudflare DNS$0Forever✓ CF
Email RoutingCloudflare Email$0Forever✓ CF
Transactional EmailResend.com$03,000/mo free
Security / WAFCloudflare WAF$0Forever (basic)✓ CF
DDoS ProtectionCloudflare$0Forever✓ CF
Payments (payout)Stripe Connect% onlyOn earned money only
Intl PayoutsWise BusinessLow feeOn earned money only
CommunityDiscord$0Forever
SchedulingCal.com$0Forever (basic)
FormsTally.so$0Forever (basic)
NewsletterBeehiiv$02,500 subscribers
Total Infrastructure Cost at Launch: $0/month. The only costs are percentage-based payment processing fees — which only occur when real money flows out on withdrawal. This means RUH AERIOS has zero overhead until it generates revenue. The platform is profitable from the very first transaction.
Cloudflare advantage summary: By using Cloudflare as the backbone, RUH AERIOS eliminates bandwidth costs (R2 has no egress fees), gets global edge performance at zero cost (Workers run in 200+ cities), and replaces an entire DevOps team (no server management, auto-scaling, auto-SSL, auto-CDN). This is enterprise infrastructure at startup-zero cost.