Skip to main content

Stack

DualMind Lab’s frontend is a vanilla JavaScript application with no build step. It uses ES modules, custom CSS, and is served via Cloudflare Workers in production.
AspectDetails
LanguageVanilla JavaScript (ES modules)
BuildNone — served as-is
AuthSupabase JS client via CDN
StylingCustom CSS (no framework)
Dev servernpx serve . -p 8000
ProductionCloudflare Workers

Key files

FilePurpose
config.jsRuntime configuration: API URL, Supabase keys, feature flags, streaming settings
js/api/DualMindApi.jsAPI client facade — singleton api export
js/app-final.jsApplication entry point
js/arena-core.jsArena battle mode logic
js/chat-handler.jsChat message send/receive
components/chat/ChatView.jsChat message rendering
components/ChatInput.jsUser input with auto-resize
worker.jsCloudflare Worker for production

API client

The DualMindApi class provides a clean interface to the backend:
import { api } from './js/api/DualMindApi.js';

// Single chat
const res = await api.arena.chat({ prompt: "Hello" });

// Dual chat battle
const battle = await api.arena.dualChat({
    prompt: "Explain quantum computing",
    threadId: "optional-thread-id"
});

// Vote on comparison
await api.arena.vote({
    comparisonId: battle.comparisonId,
    winner: "agent1"
});

// Get leaderboard stats
const stats = await api.arena.getStats();

// Thread management
const threads = await api.threads.getThreads();
const thread = await api.threads.createThread({ title: "New Chat" });
const messages = await api.threads.getMessages(thread.threadId);

Configuration

All runtime configuration is in config.js via window.DUALMIND_CONFIG:
  • apiBaseUrl — Auto-detected: localhost:5079 for dev, api.dualmindlab.tech for production
  • supabase.url / supabase.anonKey — Supabase project credentials
  • streaming.enabled — SSE streaming toggle (default: true)
  • features.* — Feature flags for streaming, voting, threads, leaderboard
  • speedPreset'fast', 'balanced', or 'quality' presets

Auth flow

  1. User visits /login page
  2. Clicks “Login with Google” → Supabase OAuth redirect
  3. After consent, redirected back with JWT in URL hash
  4. Supabase JS client stores session (localStorage)
  5. All subsequent API calls include Authorization: Bearer <jwt> header automatically via HttpClient

Pages

URL pathHTML fileDescription
/index.htmlMain chat/arena interface
/loginlogin/index.htmlAuthentication
/leaderboardleaderboard/index.htmlModel rankings
/modelsmodels/index.htmlBrowse AI models
/shareshare/index.htmlView shared threads
/aboutabout/index.htmlAbout page