Skip to content

Brain Configuration

Environment Variables

VariableDefaultDescription
BRAIN_DATABASE_URLPostgreSQL connection string (required)
BRAIN_PORT50051gRPC server port
BRAIN_SCHEMAbrainPostgreSQL schema name
BRAIN_TENANTSComma-separated list of allowed tenants
BRAIN_NEWS_ENGINEfalseEnable news engine tables
EMBEDDER_TYPEautoopenai or local (auto-selects based on API key)
PGVECTOR_DIM1536Vector dimensions (must match embedder)
OPENAI_API_KEYRequired for OpenAI embeddings
OPENAI_EMBEDDING_MODELtext-embedding-3-smallOpenAI embedding model

Database Setup

Terminal window
# Create database
createdb brain
# Enable required extensions
psql brain -c "CREATE EXTENSION IF NOT EXISTS vector;"
psql brain -c "CREATE EXTENSION IF NOT EXISTS ltree;"
# Initialize schema
uv run python scripts/init_db.py

Running

Terminal window
# Start gRPC server
uv run python -m contextbrain

Database Roles

RoleRLSPurpose
brain_appEnforcedUsed by ContextBrain service
brain_adminBypassedUsed by ContextView dashboard

The brain_app role has Row-Level Security enforced. Wildcard '*' tenant is available for admin access via ContextView.