Overview
The admin panel is a separate Cloudflare Workers application providing a management dashboard for all DualMind Lab entities: users, AI models, threads, comparisons, votes, and providers.Technology stack
| Aspect | Choice |
|---|---|
| Language | Vanilla JavaScript |
| Hosting | Cloudflare Workers |
| Bundler | Wrangler (Cloudflare CLI) |
| API Access | Proxied through Worker to backend |
Directory structure
Worker proxy pattern
Theworker.js is the entry point. It handles three responsibilities:
1. API proxy (/api/*)
All requests starting with /api/ are forwarded to the backend:
worker.js
2. Static file serving
Non-API requests are served from theASSETS binding (Cloudflare Workers Sites KV):
3. Clean URL routing
- Extensionless paths try
.htmlsuffix (e.g.,/usersservesusers.html) - Unmatched routes fall back to
index.html
Admin API endpoints
All admin endpoints are at/api/admin/* on the backend. The admin panel calls these through its Worker proxy.
| Page | Backend endpoints | Operations |
|---|---|---|
| Dashboard | /api/admin/dashboard/stats, /recent-activity, /model-performance | Read-only stats |
| Users | /api/admin/users | List, create, update, delete, search |
| Models | /api/admin/models | List, create, update, delete, search, toggle status |
| Threads | /api/admin/threads | List, create, update, delete, search by user |
| Comparisons | /api/admin/comparisons | List, delete, search, filter by user/model |
| Votes | /api/admin/votes | List, delete, stats by model |
| Providers | /api/admin/providers | CRUD providers, manage API keys |
Authentication
The admin panel uses the same Supabase JWT as the main frontend. Theauth-gate.js script checks for a valid session on page load and redirects to login if missing.
Admin endpoints on the backend currently do not enforce role-based access control. Any authenticated user can access admin APIs. This is a known limitation for the college project scope.
Deployment
wrangler.toml:
BACKEND_URL— Backend API base URL