Skip to content

Environment Variables

All environment variables can be set in your shell, a .env file (loaded by python-dotenv if installed), or as Docker -e / Compose environment: entries.

Core server

VariableDefaultDescription
PURPLE8_HOST0.0.0.0Interface the REST server binds to
PURPLE8_PORT8010TCP port
DATA_DIR./graph_dataRoot directory for graph storage
WORKERS1Number of Uvicorn worker processes
LOG_LEVELinfodebug / info / warning / error

Authentication

VariableDefaultRequiredDescription
JWT_SECRETYesHMAC-SHA256 signing secret — must be ≥32 random bytes in production
JWT_EXPIRY_SECONDS3600NoAccess token TTL (seconds)
JWT_REFRESH_EXPIRY_SECONDS86400NoRefresh token TTL (seconds)
ADMIN_EMAILYesEmail for the admin user created on first start
ADMIN_PASSWORDYesPassword for the admin user created on first start

JWT_SECRET

Never use the default or a short secret in production. Generate one with:

bash
python -c "import secrets; print(secrets.token_hex(32))"

Vector index

VariableDefaultDescription
P8G_VECTOR_BACKENDhnswlibhnswlib (in-memory HNSW) or diskann (on-disk, low memory)
P8G_VECTOR_QUANTIZATIONint8 (4× compression) or binary (32× compression, approximate)
P8G_VECTOR_CACHE_TTL300Seconds to keep decoded vectors in the read cache
P8G_INDEX_DEFERREDfalseSkip HNSW index updates during write (set true for bulk ingestion, then rebuild)

HNSW tuning (hnswlib backend)

VariableDefaultDescription
P8G_HNSW_M16HNSW M parameter — higher = better recall, more RAM
P8G_HNSW_EF_CONSTRUCTION200Build-time recall quality (higher = slower build, better index)
P8G_HNSW_EF_SEARCH50Search-time recall quality (higher = slower query, better recall)

DiskANN tuning (diskann backend)

VariableDefaultDescription
P8G_DISKANN_R64Graph degree bound
P8G_DISKANN_L100Search list size
P8G_DISKANN_ALPHA1.2Pruning slack parameter

Graph engine

VariableDefaultDescription
P8G_TRAVERSAL_CACHE_SIZE1000LRU cache entries for graph traversal results
P8G_TRAVERSAL_CACHE_TTL60TTL (seconds) for cached traversal results
P8G_MAX_TRAVERSAL_DEPTH10Hard cap on MATCH variable-length path depth
P8G_WAL_SYNCtruetrue = fsync on every write (durable), false = async (faster, less durable)

KMS / encryption

VariableRequiredDescription
KMS_PROVIDERWhen encryptinglocal / vault / aws / gcp / azure
KMS_KEY_IDWhen encryptingProvider-specific key identifier
KMS_LOCAL_KEYSTORELocal onlyPath to JSON keystore file
VAULT_ADDRVault onlyHashiCorp Vault server URL
VAULT_TOKENVault onlyVault token
VAULT_CACERTVault (mTLS)Vault CA certificate path
AWS_REGIONAWS onlyAWS region (e.g. us-east-1)
AWS_ACCESS_KEY_IDAWS (key auth)AWS access key ID
AWS_SECRET_ACCESS_KEYAWS (key auth)AWS secret access key
GOOGLE_APPLICATION_CREDENTIALSGCP (SA auth)Path to service account JSON
AZURE_TENANT_IDAzureAzure AD tenant ID
AZURE_CLIENT_IDAzureAzure app registration client ID
AZURE_CLIENT_SECRETAzureAzure app registration client secret
AZURE_USE_MSIAzure (MSI)Use Managed Identity instead of client secret

Multi-tenancy

VariableDefaultDescription
P8G_MULTI_TENANTfalseRoute requests to per-tenant engine instances
P8G_TENANT_DATA_ROOT./data/tenantsRoot directory for per-tenant data directories

Cluster / sharding

VariableDefaultDescription
P8G_CLUSTER_MODEfalseEnable distributed sharding mode
SHARD_IDThis instance's shard index (e.g. 0, 1, 2)
SHARD_PEERSComma-separated host:port list of peer shards

Journeys / AI

VariableDefaultDescription
P8G_JOURNEY_SLA_POLL_INTERVAL30How often (seconds) the SLA monitor checks for breaches
P8G_AI_ADVISOR_PROVIDERDefault LLM provider for JourneyAIAdvisor (openai / anthropic / google / mistral / cohere / ollama)

LLM providers

VariableDescription
OPENAI_API_KEYOpenAI API key
ANTHROPIC_API_KEYAnthropic API key
GOOGLE_API_KEYGoogle Gemini API key
MISTRAL_API_KEYMistral AI API key
COHERE_API_KEYCohere API key
OLLAMA_BASE_URLOllama server URL (default: http://localhost:11434)
OLLAMA_MODELOllama model name (e.g. llama3.1)
P8G_EMBEDDING_MODELDefault embedding model (e.g. all-MiniLM-L6-v2)

Sample .env for local development

bash
# Auth
JWT_SECRET=dev-secret-change-me
ADMIN_EMAIL=admin@localhost
ADMIN_PASSWORD=changeme

# Storage
DATA_DIR=./graph_data
LOG_LEVEL=debug

# Vector
P8G_VECTOR_BACKEND=hnswlib

# LLM (optional)
OPENAI_API_KEY=sk-...

Sample .env for production (AWS)

bash
# Auth — generate with: python -c "import secrets; print(secrets.token_hex(32))"
JWT_SECRET=<64-hex-chars>
ADMIN_EMAIL=ops@acme.com
ADMIN_PASSWORD=<strong-password>

# Storage
DATA_DIR=/mnt/data/graph
WORKERS=4
LOG_LEVEL=info

# Vector
P8G_VECTOR_BACKEND=diskann
P8G_VECTOR_QUANTIZATION=int8

# KMS
KMS_PROVIDER=aws
KMS_KEY_ID=arn:aws:kms:us-east-1:123456789012:key/mrk-abc123
AWS_REGION=us-east-1
# Credentials via IAM instance role — no keys needed here

# Multi-tenancy
P8G_MULTI_TENANT=true
P8G_TENANT_DATA_ROOT=/mnt/data/tenants

Purple8 Graph is proprietary software. All rights reserved.