State architecture
DualMind Lab frontend uses no state management library. State is managed through:window.DUALMIND_CONFIG— global runtime configuration- Supabase session — authentication state in localStorage
- DOM state — UI state lives in the DOM
- In-memory caches — API responses cached with TTL
Global configuration state
All configuration is set once inconfig.js and accessed via window.DUALMIND_CONFIG:
Configuration categories
| Namespace | Purpose | Example values |
|---|---|---|
apiBaseUrl | Backend URL | https://api.dualmindlab.tech |
supabase.* | Supabase credentials | url, anonKey |
streaming.* | SSE behavior | enabled, chunkDelay: 50 |
api.* | HTTP settings | timeout: 30000, retryAttempts: 2 |
models.* | Model defaults | defaultModel, maxTokens: 4096 |
ui.* | UI behavior | autoResizeTextarea, scrollBehavior |
cache.* | Cache TTLs | leaderboardExpiry: 300000 |
features.* | Feature flags | streaming, voting, threads |
Authentication state
Managed entirely by the Supabase JS client. The session is stored inlocalStorage and includes:
access_token— JWT for API callsrefresh_token— for token renewaluser— user profile (id, email, name)
Caching strategy
The frontend caches certain API responses in memory with configurable TTLs:| Data | Cache key | Default TTL | Invalidation |
|---|---|---|---|
| Leaderboard stats | In-memory | 5 minutes | Manual refresh |
| Model list | In-memory | 1 hour | Page reload |
| Thread list | In-memory | 30 minutes | On thread create/delete |