Skip to main content

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

This is a critical pattern. All services must follow it exactly.
  • 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: ConfigRepository manages the platform_config table
  • Encryption: AES-256-GCM using JWT_SECRET as key (via @brainstormer/shared encrypt/decrypt)
  • Precedence: DB values take precedence over env vars (getConfigValue() checks DB first, falls back to process.env)
  • Categories: ai, voice, knowledge, feature_flags
  • Admin UI: Manages all API keys (OPENROUTER, OPENAI, ELEVENLABS, LIVEKIT, PINECONE, etc.)

Prompt Registry and Defaults

All /admin/prompt-types/* and /admin/prompt-defaults/* endpoints require x-platform-role: superadmin (checked via gateway-forwarded header).
prompt_type_registry.key cannot be changed after creation. Update only label, description, and category.
Set deprecated_at via the deprecate endpoint. Cannot delete a type with existing configs or defaults.
Every update to a system default auto-increments the version (minor unless mode changes, which triggers major) and snapshots to system_prompt_default_versions.
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_KEY not set
  • Config: RESEND_API_KEY, EMAIL_FROM, WEB_APP_URL

Configuration Variables