System Topology Diagram

Interactive SVG Representation
FRONTEND APPLICATIONS 𓋹 Duat (duatplay.com) React 19 / Expo • Three.js R3F Senet, Mehen, Thoth, Multiplayer 🏀 Common Court (commoncourt.app) Expo SDK 57 • Leaflet • cc-scores Live Scores/Odds, LA Map, Reels & Fitness ⚡ Weather Witch (weatherwitch.app) React 18 / Vite • Standalone Utility No Auth • Open APIs (Open-Meteo, NWS, Radar) 🔑 Clerk Auth (Production) Dedicated Duat App Key JWT token generation for player ID 🔑 Clerk Auth (Development) Separate Common Court App Key JWT token generation for hooper profile 🌐 Public Scientific APIs Direct Client Ingestion (No Backend) • Open-Meteo (Hourly/10-Day Forecasts) • NWS Weather.gov (Active Hazard Alerts) • RainViewer (Live Doppler Radar Loops) • US Drought Monitor & NOAA Climate CLOUDFLARE EDGE WORKERS (lightmeup-api & cc-scores) ⚡ lightmeup-api (Worker Gateway) Global Edge Network • Multi-App JWT Verification ✓ Verifies Duat (prod) & Common Court (dev) Clerk JWTs ✓ Real-time WebSockets (Duat game lobbies & matchmaking) ✓ Cross-game badges, player titles, and profile records ✓ Common Court user bookmarks and court check-ins ✓ REST API routing + Edge rate limiting & CORS guards 🏀 cc-scores Edge Score Worker • NBA, NFL, MLB • WNBA, College • Live betting odds • LA venue radar • Sub-second edge cache PERSISTENCE LAYER (CLOUDFLARE D1 SQL DATABASE) 🗄️ lightmeup-db (Serverless SQLite at the Edge) Zero-cold-start SQL tables partitioned by application ID with foreign key integrity Tables: users • accounts • badges • games_history • duat_pyramids • cc_saved_courts • streak_logs ARCHITECTURE HIGHLIGHTS 🔒 Separation of Auth: Duat (prod) & Common Court (dev) keys. ⚡ Shared Backend: lightmeup-api validates both apps against D1. ☀️ Standalone App: Weather Witch queries scientific APIs directly.
01

Client Applications Layer

Cross-Platform Web & Native Frontends

Frontend architectures tailored for maximum responsiveness and specialized domain rendering:

  • Duat Play (duatplay.com): React 19 / Expo Web with Three.js / React Three Fiber 3D board rendering, 5 deterministic rules engines, and hieroglyphic deciphering tools.
  • Common Court (commoncourt.app): React Native / Expo SDK 57, Leaflet map, Top 24 streetball video pipeline, dynamic elemental day/night themes, and science-based fitness calculators.
  • Weather Witch (weatherwitch.app): React 18 / Vite standalone weather web application rendering real-time sky backdrops and multi-layer meteorological maps.
React 19 / Expo Three.js / R3F Leaflet Maps
02

Separate Clerk Authentication

Dedicated App Instances & Edge JWT Verification

Authentication is scoped per application with dedicated Clerk environments to ensure strict security boundaries:

  • Duat (Production Key): Dedicated production Clerk application managing verified board game player credentials, milestone progression, and match statistics.
  • Common Court (Development Key): Dedicated development Clerk application managing basketball profiles, court bookmarks, and workout streak logs.
  • Edge JWT Verification: lightmeup-api validates both distinct JWKS endpoints locally on Cloudflare edge nodes without external auth round-trips.
  • Weather Witch: Zero authentication required — fully accessible public utility querying open APIs directly.
Clerk Auth (Prod & Dev) RS256 JWKS Zero-Auth Public App
03

Cloudflare Workers Edge Layer

lightmeup-api Gateway & cc-scores Ingestion

Serverless V8 isolates distributed globally across Cloudflare edge datacenters for sub-20ms execution:

  • lightmeup-api: Shared REST gateway managing badges, user profiles, leaderboards, and real-time multiplayer WebSocket rooms.
  • cc-scores Worker: High-throughput sports score ingestion worker streaming real-time clocks, team odds, and betting lines for NBA, NFL, MLB, WNBA, and College Basketball.
  • Low Latency WebSockets: Sub-second state synchronization for Duat game lobbies and match moves.
Cloudflare Workers cc-scores Worker Edge WebSockets
04

Edge SQL Persistence

Cloudflare D1 (lightmeup-db)

Serverless SQLite database executing queries co-located with Worker compute at the edge:

  • Scoped Multi-App Schema: Tables partitioned with app_id constraints ensuring clear data boundaries between Duat and Common Court records.
  • Zero Cold Starts: Edge SQL reads and writes executed in under 15ms globally without connection pooling overhead.
  • Relational Integrity: Manages player profiles, unlocked cross-game badges, match histories, pyramid stone placements, and saved court check-ins.
Cloudflare D1 (SQL) SQLite Engine Schema Partitioning
D1 Edge Schema

lightmeup-db Core Relational Design

Engine: Cloudflare D1 (SQLite)

The database schema supports both Duat and Common Court while keeping authentication tokens tied to their respective Clerk application instances:

-- Core user profiles mapping to separate Clerk instances
CREATE TABLE users (
  id TEXT PRIMARY KEY,               -- UUID
  clerk_id TEXT UNIQUE NOT NULL,      -- Clerk User ID (scoped per app)
  app_id TEXT NOT NULL,              -- 'duat' | 'common-court'
  username TEXT NOT NULL,
  display_name TEXT,
  avatar_url TEXT,
  created_at INTEGER DEFAULT (unixepoch()),
  updated_at INTEGER DEFAULT (unixepoch())
);

-- Shared and app-specific badges
CREATE TABLE badges (
  id TEXT PRIMARY KEY,
  user_id TEXT NOT NULL REFERENCES users(id) ON DELETE CASCADE,
  app_id TEXT NOT NULL,              -- Origin app of badge achievement
  badge_key TEXT NOT NULL,           -- e.g. 'senet_master', 'top24_curator'
  tier TEXT NOT NULL,                -- 'bronze' | 'silver' | 'gold' | 'obsidian'
  unlocked_at INTEGER DEFAULT (unixepoch()),
  UNIQUE(user_id, badge_key)
);

-- Duat game match records
CREATE TABLE games_history (
  id TEXT PRIMARY KEY,
  game_type TEXT NOT NULL,          -- 'senet' | 'mehen' | 'hounds_jackals' | 'aseb' | 'tab'
  player_a_id TEXT REFERENCES users(id),
  player_b_id TEXT REFERENCES users(id),
  winner_id TEXT REFERENCES users(id),
  moves_count INTEGER NOT NULL,
  completed_at INTEGER DEFAULT (unixepoch())
);

-- Common Court saved courts and check-ins
CREATE TABLE cc_saved_courts (
  id TEXT PRIMARY KEY,
  user_id TEXT NOT NULL REFERENCES users(id) ON DELETE CASCADE,
  court_id TEXT NOT NULL,           -- Spot identifier (e.g. 'venice_beach')
  created_at INTEGER DEFAULT (unixepoch())
);

Why Cloudflare Workers + D1 at the Edge?

⚡

Zero Cold Starts

V8 isolates spin up in under 5 milliseconds globally, eliminating the latency spikes of traditional containerized and node-based serverless runtimes.

🌍

300+ Edge Datacenters

Auth validation, API routing, and WebSocket handshakes terminate at the user's nearest point of presence for consistent sub-30ms round-trips.

🛡️

Scoped Security

Each application maintains its own Clerk identity environment while sharing verified persistence and edge microservices without cross-contamination.

💰

Cost & Scale Efficiency

Serverless execution scaling to millions of daily requests with minimal base operational overhead and zero idle infrastructure costs.