src/DualMind.API, with tests in tests/DualMind.API.Tests and the Cloudflare host in cf-worker/.
Repository layout
DualMind_Back
src
Dockerfile
DualMind.API
AI
Bot
Controllers
Core
Infrastructure
Program.cs
tests
cf-worker
.github/workflows
Service registrations
Conventions
JSON
JSON
Newtonsoft.Json with camelCase property names,
null values omitted and UTC dates. Admin DTOs override names with snake_case [JsonProperty] attributes that match the database.Errors
Errors
Arena routes return
{ "object": "ai.error", "code", "message", "timestamp" }. Thread, vote and settings routes return { "success": false, "error", "code" }. Admin routes return the { success, error } envelope. Codes include INVALID_REQUEST, UNAUTHORIZED, FORBIDDEN, NOT_FOUND, API_ERROR, VOTE_ERROR, THREADS_ERROR and MODELS_ERROR.Identity
Identity
Controllers read the user ID from the
sub claim (falling back to NameIdentifier) and the email and name from email, full_name or name. Before writing anything tied to a user they call UserSyncService.EnsureUserExistsAsync so the public.users row exists.Data access
Data access
Filters are PostgREST query strings (
user_id=eq.{id}&order=created_at.desc). Always escape user input with Uri.EscapeDataString and prefer typed IDs (Guid) in routes, as the admin controllers do with {id:guid}.Tests
Tests
xUnit tests cover model selection, AI Gateway settings, Supabase headers, the Telegram bot (options, auth, sessions, state cache, update handling, webhook, commands) and a startup smoke test. Run them with
dotnet test tests/DualMind.API.Tests.Packages
Swagger
Swagger UI is on in theDevelopment environment (http://localhost:5079/swagger), or anywhere ENABLE_SWAGGER=true. These docs carry a hand-checked OpenAPI description of every route instead: see the API reference.