Overview
Port: 4001 The Auth Service handles authentication, user and organization management, RBAC enforcement, platform configuration (encrypted key-value store), email verification, and the prompt type registry.Endpoints
Authentication
Email Verification and Password
Organization Management
Platform Config (Superadmin)
Prompt Type Registry (Superadmin)
System Prompt Defaults (Superadmin)
JWT Pattern
- The auth service issues and signs JWTs (
signJwt); the gateway verifies them on every request (verifyJwt(token, JWT_SECRET)); downstream services trust the auth context the gateway forwards as headers: - Payload structure:
- Access token: 24h, Refresh token: 7d (configurable)
- First registered user is auto-promoted to superadmin
Platform Config System
The platform configuration system provides an encrypted key-value store:- Repository:
ConfigRepositorymanages theplatform_configtable - Encryption: AES-256-GCM using JWT_SECRET as key (via
@brainstormer/sharedencrypt/decrypt) - Precedence: DB values take precedence over env vars (
getConfigValue()checks DB first, falls back toprocess.env) - Categories:
ai,voice,knowledge,feature_flags - Admin UI: Manages all API keys (OPENROUTER, OPENAI, ELEVENLABS, LIVEKIT, PINECONE, etc.)
Prompt Registry and Defaults
Superadmin Only
Superadmin Only
All
/admin/prompt-types/* and /admin/prompt-defaults/* endpoints require x-platform-role: superadmin (checked via gateway-forwarded header).Key Immutability
Key Immutability
prompt_type_registry.key cannot be changed after creation. Update only label, description, and category.Deprecation Before Deletion
Deprecation Before Deletion
Set
deprecated_at via the deprecate endpoint. Cannot delete a type with existing configs or defaults.Versioning on PUT
Versioning on PUT
Every update to a system default auto-increments the version (minor unless mode changes, which triggers major) and snapshots to
system_prompt_default_versions.Rollback
Rollback
Creates a new version entry (does not rewrite history). Changelog notes “Rolled back to vX.Y”.
Database Tables
Email (Resend)
The auth service sends emails via Resend:- Email types: verification, OTP, password reset, invitation, welcome
- Fallback: Console logging if
RESEND_API_KEYnot set - Config:
RESEND_API_KEY,EMAIL_FROM,WEB_APP_URL

