Skip to main content
DualMind is a small number of HTTP services on Cloudflare in front of Supabase. There are no queues and no background workers apart from the API container’s keep-alive cron and the Telegram bot’s hosted service.

Runtime topology (October 2026)

Components

Backend

Project layout, services and conventions.

Arena web app

Structure, routing and API client.

Admin panel

Access model, pages and endpoint map.

Design choices worth knowing

SupabaseService and AdminSupabaseClient call {SUPABASE_URL}/rest/v1/... with HttpClient and filter strings. There is no ORM and no migrations project. Every request carries the service-role key in both the apikey and Authorization headers (the September 2026 fix), so row-level security doesn’t apply to API calls; authorization is done in the controllers.
Supabase tokens don’t carry an app role. RoleClaimsTransformation reads public.users.role for the sub of every authenticated request and adds it as a role claim. The AdminOnly policy requires admin. See Authentication.
The Worker sends every request to a single named container (default). A multi-instance setup was tried in August 2026 and reverted the next day. The API keeps some state in memory (the model cache and provider key cooldowns), so several instances would need that state shared first. See Cloudflare Containers.
IChatProvider has ChatAsync and StreamAsync. ChatProviderFactory maps provider_name to GroqService, GoogleService or CloudflareWorkersAiService, defaulting to Groq. See Provider integration.
Controllers serialize with Newtonsoft’s camelCase resolver and omit nulls. Admin DTOs set explicit snake_case JsonProperty names that match the database columns, so admin responses are snake_case. GET /api/arena/model-stats is the public exception: it returns snake_case aliases next to the camelCase fields.

Where to go next

Request lifecycle

A battle and a vote, step by step through the code.

Invariants

Rules the code relies on. Read before you change behaviour.
Last modified on October 18, 2026