Brain Configuration
Environment Variables
| Variable | Default | Description |
|---|---|---|
BRAIN_DATABASE_URL | — | PostgreSQL connection string (required) |
BRAIN_PORT | 50051 | gRPC server port |
BRAIN_SCHEMA | brain | PostgreSQL schema name |
BRAIN_TENANTS | — | Comma-separated list of allowed tenants |
BRAIN_NEWS_ENGINE | false | Enable news engine tables |
EMBEDDER_TYPE | auto | openai or local (auto-selects based on API key) |
PGVECTOR_DIM | 1536 | Vector dimensions (must match embedder) |
OPENAI_API_KEY | — | Required for OpenAI embeddings |
OPENAI_EMBEDDING_MODEL | text-embedding-3-small | OpenAI embedding model |
Database Setup
# Create databasecreatedb brain
# Enable required extensionspsql brain -c "CREATE EXTENSION IF NOT EXISTS vector;"psql brain -c "CREATE EXTENSION IF NOT EXISTS ltree;"
# Initialize schemauv run python scripts/init_db.pyRunning
# Start gRPC serveruv run python -m contextbrainDatabase Roles
| Role | RLS | Purpose |
|---|---|---|
brain_app | Enforced | Used by ContextBrain service |
brain_admin | Bypassed | Used by ContextView dashboard |
The brain_app role has Row-Level Security enforced. Wildcard '*' tenant is available for admin access via ContextView.