TurfAITurfAI User Guide
ReferenceOperations

TurfAI Environment Variables Inventory

Synced from the TurfAI source on 2026-06-21.

Overview

This document provides a comprehensive inventory of all environment variables used across TurfAI services for both local development and cloud deployment.

Last Updated: November 4, 2025 Project: TurfAI v0.9.1 GCP Project: turfai-476911


Table of Contents

  1. Shared Secrets
  2. DMS (Strapi)
  3. Router Service
  4. Processor Service
  5. LLM Service
  6. RAG Query Service
  7. RAG Embeddings Worker
  8. Infrastructure
  9. Local Development Setup
  10. Cloud Deployment Setup

Legend

  • 🔴 Required - Must be set for service to function
  • 🟡 Recommended - Should be set for full functionality
  • 🟢 Optional - Can be omitted (has default)
  • 🔐 Secret - Sensitive value, store securely
  • 🔗 Shared - Must be identical across multiple services

Shared Secrets

These secrets MUST be identical across all services for proper authentication and communication.

VariableTypeDescriptionLocal ValueCloud Value
STRAPI_JWT_SECRET / JWT_SECRET🔴🔐🔗JWT token secret for user authenticationGenerate with openssl rand -base64 32Same as local, stored in env
ROUTER_API_KEY🔴🔐🔗API key for router service authenticationGenerate UUIDSame as local, stored in env

Generation Commands:

# Generate JWT Secret
openssl rand -base64 32

# Generate Router API Key
uuidgen
# or
openssl rand -hex 16

Services Using JWT_SECRET:

  • DMS (as JWT_SECRET)
  • Router (as STRAPI_JWT_SECRET)
  • Processor (as STRAPI_JWT_SECRET)
  • RAG Query Service (as STRAPI_JWT_SECRET)
  • RAG Embeddings Worker (as STRAPI_JWT_SECRET)

Services Using ROUTER_API_KEY:

  • DMS (for submitting jobs)
  • Router (for validating requests)

DMS (Strapi)

Service: Document Management System (Strapi CMS) Location: /dms/ Port: 1338 (local), Cloud Run (cloud) Config File: .env

Database Configuration

VariableTypeDescriptionLocal ValueCloud Value
DATABASE_CLIENT🔴Database typepostgrespostgres
DATABASE_HOST🔴PostgreSQL hostlocalhost/cloudsql/turfai-476911:us-central1:turfai-db
DATABASE_PORT🔴PostgreSQL port54325432
DATABASE_NAME🔴Database nameturfai_dmsturfai_dms
DATABASE_USERNAME🔴Database userpostgrespostgres
DATABASE_PASSWORD🔴🔐Database password(local password)Secret Manager: turfai-db-password
DATABASE_SSL🟢Enable SSLfalsefalse (Unix socket)

Strapi Secrets

VariableTypeDescriptionLocal ValueCloud Value
APP_KEYS🔴🔐Strapi app keys (4 comma-separated)Generate 4 keysSame, stored in env
API_TOKEN_SALT🔴🔐Salt for API tokensopenssl rand -base64 32Same
ADMIN_JWT_SECRET🔴🔐Admin JWT secretopenssl rand -base64 32Same
TRANSFER_TOKEN_SALT🔴🔐Transfer token saltopenssl rand -base64 32Same
JWT_SECRET🔴🔐🔗User JWT secret (SHARED)openssl rand -base64 32Same

Storage Configuration

VariableTypeDescriptionLocal ValueCloud Value
STORAGE_PROVIDER🔴Storage backendgcsgcs
GCS_BUCKET_NAME🔴GCS bucket nameturfai-documents-devturfai-documents-turfai-476911
GCS_PROJECT_ID🔴GCP project ID(your project)turfai-476911
GCS_KEY_FILE🟡Service account key path/path/to/key.json(empty - use Workload Identity)

Redis Configuration

VariableTypeDescriptionLocal ValueCloud Value
REDIS_HOST🔴Redis hostlocalhost10.233.40.195
REDIS_PORT🔴Redis port63796379

Service URLs

VariableTypeDescriptionLocal ValueCloud Value
ROUTER_URL🔴Router service URLhttp://localhost:8000https://turfai-router-eatorcypia-uc.a.run.app
JOB_ROUTER_URL🔴Job submission endpointhttp://localhost:8000/api/v1/jobshttps://turfai-router-eatorcypia-uc.a.run.app/api/v1/jobs
RAG_QUERY_SERVICE_URL🔴RAG query service URLhttp://localhost:8003https://turfai-rag-eatorcypia-uc.a.run.app

Application Configuration

VariableTypeDescriptionLocal ValueCloud Value
HOST🟢Bind host0.0.0.00.0.0.0
PORT🟢Service port13381338
NODE_ENV🔴Environmentdevelopmentproduction
ENABLE_ADMIN_ACCESS🟡Enable admin UItruetrue (initial), false (production)
STRAPI_LOG_LEVEL🟢Log leveldebuginfo
ADMIN_PATH🟢Admin UI path/admin/admin

Router Service

Service: Job routing and API gateway Location: /router/ Port: 8000 (local), Cloud Run (cloud) Config File: .env

Database Configuration

VariableTypeDescriptionLocal ValueCloud Value
DATABASE_HOST🔴PostgreSQL hostlocalhost/cloudsql/turfai-476911:us-central1:turfai-db
DATABASE_PORT🔴PostgreSQL port54325432
DATABASE_NAME🔴Database nameturfai_dmsturfai_dms
DATABASE_USERNAME🔴Database userpostgrespostgres
DATABASE_PASSWORD🔴🔐Database password(local password)Secret Manager: turfai-db-password

Redis Configuration

VariableTypeDescriptionLocal ValueCloud Value
REDIS_HOST🔴Redis hostlocalhost10.233.40.195
REDIS_PORT🔴Redis port63796379

Authentication

VariableTypeDescriptionLocal ValueCloud Value
STRAPI_JWT_SECRET🔴🔐🔗JWT secret (SHARED)(shared secret)(shared secret)
ROUTER_API_KEY🔴🔐🔗Router API key (SHARED)(shared secret)(shared secret)

Service URLs

VariableTypeDescriptionLocal ValueCloud Value
DMS_URL🔴DMS service URLhttp://localhost:1338https://turfai-dms-eatorcypia-uc.a.run.app
LLM_SERVICE_URL🔴LLM service URLhttp://localhost:9090https://turfai-llm-eatorcypia-uc.a.run.app

Application Configuration

VariableTypeDescriptionLocal ValueCloud Value
HOST🟢Bind host0.0.0.00.0.0.0
PORT🟢Service port80008000
LOG_LEVEL🟢Log levelDEBUGINFO

Processor Service

Service: Document processing and workflow execution Location: /processors/ Port: 8001 (local), Cloud Run (cloud) Config File: .env

Database Configuration

VariableTypeDescriptionLocal ValueCloud Value
DATABASE_HOST🔴PostgreSQL hostlocalhost/cloudsql/turfai-476911:us-central1:turfai-db
DATABASE_PORT🔴PostgreSQL port54325432
DATABASE_NAME🔴Database nameturfai_dmsturfai_dms
DATABASE_USERNAME🔴Database userpostgrespostgres
DATABASE_PASSWORD🔴🔐Database password(local password)Secret Manager: turfai-db-password

Redis Configuration

VariableTypeDescriptionLocal ValueCloud Value
REDIS_HOST🔴Redis hostlocalhost10.233.40.195
REDIS_PORT🔴Redis port63796379
REDIS_QUEUE_NAME🟢Processor queue nameprocessor_queueprocessor_queue
RESULTS_QUEUE_NAME🟢Results queue nameresults_queueresults_queue

Authentication

VariableTypeDescriptionLocal ValueCloud Value
STRAPI_JWT_SECRET🔴🔐🔗JWT secret (SHARED)(shared secret)(shared secret)

Service URLs

VariableTypeDescriptionLocal ValueCloud Value
DMS_URL🔴DMS service URLhttp://localhost:1338https://turfai-dms-eatorcypia-uc.a.run.app
LLM_SERVICE_URL🔴LLM service URLhttp://localhost:9090https://turfai-llm-eatorcypia-uc.a.run.app

GCS Configuration

VariableTypeDescriptionLocal ValueCloud Value
GCS_BUCKET_NAME🔴GCS bucket nameturfai-documents-devturfai-documents-turfai-476911
GOOGLE_CLOUD_PROJECT🔴GCP project ID(your project)turfai-476911
GOOGLE_APPLICATION_CREDENTIALS🟡Service account key/path/to/key.json(empty - use Workload Identity)

Application Configuration

VariableTypeDescriptionLocal ValueCloud Value
HOST🟢Bind host0.0.0.00.0.0.0
PORT🟢Service port80018001
LOG_LEVEL🟢Log levelDEBUGINFO
WORKER_CONCURRENCY🟢Concurrent workers44

LLM Service

Service: LLM abstraction layer Location: /llm-service/ Port: 9090 (local), Cloud Run (cloud) Config File: .env

LLM Provider API Keys

VariableTypeDescriptionLocal ValueCloud Value
OPENAI_API_KEY🟡🔐OpenAI API keysk-...Secret Manager: openai-api-key
ANTHROPIC_API_KEY🟡🔐Anthropic API keysk-ant-...Secret Manager: anthropic-api-key
GEMINI_API_KEY🟡🔐Gemini API key(if using)Secret Manager: gemini-api-key

Vertex AI Configuration

VariableTypeDescriptionLocal ValueCloud Value
GOOGLE_CLOUD_PROJECT🔴GCP project ID(your project)turfai-476911
VERTEX_LOCATION🔴Vertex AI regionus-central1us-central1
GOOGLE_APPLICATION_CREDENTIALS🟡Service account key/path/to/key.json(empty - use Workload Identity)

Ollama Configuration (Local Models)

VariableTypeDescriptionLocal ValueCloud Value
OLLAMA_BASE_URL🟢Ollama service URLhttp://localhost:11434(not used in cloud)

Application Configuration

VariableTypeDescriptionLocal ValueCloud Value
HOST🟢Bind host0.0.0.00.0.0.0
PORT🟢Service port90909090
LOG_LEVEL🟢Log levelDEBUGINFO

RAG Query Service

Service: Real-time RAG query processing Location: /rag_query_service/ Port: 8003 (local), Cloud Run (cloud) Config File: .env

Database Configuration

VariableTypeDescriptionLocal ValueCloud Value
DATABASE_HOST🔴PostgreSQL hostlocalhost/cloudsql/turfai-476911:us-central1:turfai-db
DATABASE_PORT🔴PostgreSQL port54325432
DATABASE_NAME🔴Database nameturfai_dmsturfai_dms
DATABASE_USERNAME🔴Database userpostgrespostgres
DATABASE_PASSWORD🔴🔐Database password(local password)Secret Manager: turfai-db-password

Authentication

VariableTypeDescriptionLocal ValueCloud Value
STRAPI_JWT_SECRET🔴🔐🔗JWT secret (SHARED)(shared secret)(shared secret)

Service URLs

VariableTypeDescriptionLocal ValueCloud Value
DMS_URL🔴DMS service URLhttp://localhost:1338https://turfai-dms-eatorcypia-uc.a.run.app
LLM_SERVICE_URL🔴LLM service URLhttp://localhost:9090https://turfai-llm-eatorcypia-uc.a.run.app

GCS Configuration

VariableTypeDescriptionLocal ValueCloud Value
GCS_BUCKET_NAME🔴GCS bucket nameturfai-documents-devturfai-documents-turfai-476911
GOOGLE_CLOUD_PROJECT🔴GCP project ID(your project)turfai-476911
GOOGLE_APPLICATION_CREDENTIALS🟡Service account key/path/to/key.json(empty - use Workload Identity)

Application Configuration

VariableTypeDescriptionLocal ValueCloud Value
HOST🟢Bind host0.0.0.00.0.0.0
PORT🟢Service port80038003
LOG_LEVEL🟢Log levelDEBUGINFO

RAG Embeddings Worker

Service: Background RAG embedding generation Location: /processors/rag_embeddings/ Port: N/A (background worker), Cloud Run (cloud) Config File: .env

Database Configuration

VariableTypeDescriptionLocal ValueCloud Value
DATABASE_HOST🔴PostgreSQL hostlocalhost/cloudsql/turfai-476911:us-central1:turfai-db
DATABASE_PORT🔴PostgreSQL port54325432
DATABASE_NAME🔴Database nameturfai_dmsturfai_dms
DATABASE_USERNAME🔴Database userpostgrespostgres
DATABASE_PASSWORD🔴🔐Database password(local password)Secret Manager: turfai-db-password

Redis Configuration

VariableTypeDescriptionLocal ValueCloud Value
REDIS_HOST🔴Redis hostlocalhost10.233.40.195
REDIS_PORT🔴Redis port63796379
RAG_EMBEDDINGS_QUEUE🟢RAG queue namerag_embeddings_queuerag_embeddings_queue

Authentication

VariableTypeDescriptionLocal ValueCloud Value
STRAPI_JWT_SECRET🔴🔐🔗JWT secret (SHARED)(shared secret)(shared secret)

Service URLs

VariableTypeDescriptionLocal ValueCloud Value
DMS_URL🔴DMS service URLhttp://localhost:1338https://turfai-dms-eatorcypia-uc.a.run.app
LLM_SERVICE_URL🔴LLM service URLhttp://localhost:9090https://turfai-llm-eatorcypia-uc.a.run.app

GCS Configuration

VariableTypeDescriptionLocal ValueCloud Value
GCS_BUCKET_NAME🔴GCS bucket nameturfai-documents-devturfai-documents-turfai-476911
GOOGLE_CLOUD_PROJECT🔴GCP project ID(your project)turfai-476911
GOOGLE_APPLICATION_CREDENTIALS🟡Service account key/path/to/key.json(empty - use Workload Identity)

OCR Configuration

VariableTypeDescriptionLocal ValueCloud Value
OCR_ENABLED🟢Enable OCRtruetrue
OCR_DEFAULT_PROVIDER🟢Primary OCR providergooglegoogle
OCR_FALLBACK_PROVIDER🟢Fallback OCR providertesseracttesseract
OCR_PER_DOCUMENT_MAX_USD🟢Max cost per document0.500.50
OCR_TENANT_DAILY_MAX_USD🟢Max daily cost per tenant10.0010.00
OCR_TENANT_MONTHLY_MAX_USD🟢Max monthly cost per tenant100.00100.00

Application Configuration

VariableTypeDescriptionLocal ValueCloud Value
LOG_LEVEL🟢Log levelDEBUGINFO
WORKER_POLL_INTERVAL🟢Poll interval (seconds)55

Infrastructure

These are not environment variables but configuration values used during infrastructure setup.

Cloud SQL

ParameterValue
Instance Nameturfai-db
Regionus-central1
Tierdb-f1-micro
Databaseturfai_dms
Extensionsvector (pgvector v0.8.0)

Redis Memorystore

ParameterValue
Instance Nameturfai-redis
Regionus-central1
Size1 GB
Versionredis_7_0

Cloud Storage

ParameterValue
Bucket Nameturfai-documents-turfai-476911
Regionus-central1
Storage ClassStandard

Service Account

ParameterValue
Nameturfai-services
Emailturfai-services@turfai-476911.iam.gserviceaccount.com
Rolescloudsql.client, storage.objectAdmin, aiplatform.user, iam.serviceAccountTokenCreator

Local Development Setup

Quick Start

  1. Copy example environment file:

    cp .env.example .env
  2. Generate shared secrets:

    # JWT Secret
    export JWT_SECRET=$(openssl rand -base64 32)
    echo "JWT_SECRET=$JWT_SECRET" >> .env
    
    # Router API Key
    export ROUTER_API_KEY=$(uuidgen)
    echo "ROUTER_API_KEY=$ROUTER_API_KEY" >> .env
  3. Configure local infrastructure:

    # PostgreSQL (via Docker or local install)
    export DATABASE_HOST=localhost
    export DATABASE_PORT=5432
    export DATABASE_NAME=turfai_dms
    export DATABASE_USERNAME=postgres
    export DATABASE_PASSWORD=your_local_password
    
    # Redis (via Docker or local install)
    export REDIS_HOST=localhost
    export REDIS_PORT=6379
    
    # GCS (use local bucket or dev bucket)
    export GCS_BUCKET_NAME=turfai-documents-dev
    export GOOGLE_CLOUD_PROJECT=your-gcp-project
    export GOOGLE_APPLICATION_CREDENTIALS=/path/to/service-account-key.json
  4. Configure service URLs (all local):

    export DMS_URL=http://localhost:1338
    export ROUTER_URL=http://localhost:8000
    export LLM_SERVICE_URL=http://localhost:9090
    export RAG_QUERY_SERVICE_URL=http://localhost:8003
  5. Propagate to all services:

    # Copy .env to each service directory
    cp .env dms/.env
    cp .env router/.env
    cp .env processors/.env
    cp .env llm-service/.env
    cp .env rag_query_service/.env

Running Locally

# Terminal 1: Start PostgreSQL and Redis (via Docker Compose)
cd dev/bootstrap
docker-compose up -d postgres redis

# Terminal 2: Start DMS
cd dms
npm run develop

# Terminal 3: Start LLM Service
cd llm-service
python -m uvicorn api.main:app --host 0.0.0.0 --port 9090 --reload

# Terminal 4: Start RAG Query Service
cd rag_query_service
python -m uvicorn main:app --host 0.0.0.0 --port 8003 --reload

# Terminal 5: Start Router
cd router
python -m uvicorn main:app --host 0.0.0.0 --port 8000 --reload

# Terminal 6: Start Processor
cd processors
python -m uvicorn main:app --host 0.0.0.0 --port 8001 --reload

# Terminal 7: Start RAG Embeddings Worker
cd processors/rag_embeddings
python worker.py

Cloud Deployment Setup

Environment Variables Checklist

Before deploying, ensure you have:

  1. Generated shared secrets:

    • ✅ JWT_SECRET (used across all services)
    • ✅ ROUTER_API_KEY (used by DMS and Router)
    • ✅ Strapi secrets (APP_KEYS, API_TOKEN_SALT, etc.)
  2. Infrastructure configured:

    • ✅ Cloud SQL instance created
    • ✅ Redis Memorystore created
    • ✅ GCS bucket created
    • ✅ Service account created with all permissions
  3. Secrets stored:

    • ✅ Database password in Secret Manager
    • ✅ LLM API keys in Secret Manager (if using)
    • ✅ Service account key in Secret Manager
  4. Service URLs discovered:

    • ✅ DMS URL (from first deployment)
    • ✅ Router URL (from deployment)
    • ✅ LLM Service URL (from deployment)
    • ✅ RAG Query Service URL (from deployment)

Deployment Order

  1. Infrastructure (Cloud SQL, Redis, GCS, Service Account)
  2. DMS - Base URL needed by all other services
  3. LLM Service - Required by RAG and Processor
  4. RAG Query Service - Required by DMS RAG proxy
  5. RAG Embeddings Worker - Background processing
  6. Router - Job routing
  7. Processor - Job execution

Configuration Management

All deployment scripts auto-detect URLs from previous deployments:

# Configuration stored in deploy/.config/
deploy/.config/
├── cloudsql.env                 # Cloud SQL connection info
├── redis.env                    # Redis connection info
├── storage.env                  # GCS bucket info
├── service-account.env          # Service account details
├── shared-secrets.env           # JWT secrets, API keys
├── dms-deployment.env           # DMS URL
├── router-deployment.env        # Router URL
├── llm-deployment.env           # LLM URL
├── rag-deployment.env           # RAG Query URL
└── rag-embeddings-deployment.env # RAG Embeddings URL

Validation

Check All Required Variables

# Run this script to validate environment variables
bash deploy/scripts/validate-env-vars.sh

Test Connectivity

# Test database connection
psql -h $DATABASE_HOST -U $DATABASE_USERNAME -d $DATABASE_NAME -c "SELECT version();"

# Test Redis connection
redis-cli -h $REDIS_HOST -p $REDIS_PORT ping

# Test GCS access
gsutil ls gs://$GCS_BUCKET_NAME/

# Test service URLs
curl $DMS_URL/_health
curl $LLM_SERVICE_URL/health
curl $RAG_QUERY_SERVICE_URL/health

Troubleshooting

Common Issues

Issue: Services can't authenticate with DMS

  • Check that JWT_SECRET / STRAPI_JWT_SECRET matches across all services
  • Verify JWT secret is exactly the same (no extra whitespace)

Issue: Router API calls fail

  • Check that ROUTER_API_KEY matches between DMS and Router
  • Ensure API key is in UUID format

Issue: Database connection fails

  • For local: Check PostgreSQL is running
  • For cloud: Verify Cloud SQL connection string format
  • Check DATABASE_PASSWORD is correct

Issue: Redis connection fails

  • For local: Check Redis is running on port 6379
  • For cloud: Verify VPC connector is configured
  • Check internal IP address is correct

Issue: GCS operations fail

  • Check GCS_BUCKET_NAME is correct
  • Verify service account has storage.objectAdmin role
  • For local: Check GOOGLE_APPLICATION_CREDENTIALS path
  • For cloud: Verify Workload Identity is configured

Issue: RAG embeddings not generating

  • Check Cloud Vision API is enabled
  • Verify service account has aiplatform.user role
  • Check LLM_SERVICE_URL is accessible

Security Best Practices

  1. Never commit secrets to git

    • Use .env.example for templates
    • Keep actual .env files in .gitignore
  2. Use Secret Manager in cloud

    • Store all passwords in Secret Manager
    • Reference via secrets, not environment variables
  3. Rotate secrets regularly

    • JWT secrets should be rotated quarterly
    • API keys should be rotated on compromise
  4. Limit service account permissions

    • Use least-privilege principle
    • Only grant necessary roles
  5. Enable audit logging

    • Log all authentication attempts
    • Monitor for suspicious activity

  • Deployment Lessons Learned: /docs/deployment-lessons-learned-2025-11-04.md
  • Deployment Checklist: /docs/deployment-checklist.md
  • Database Schema: /docs/database-schema-complete.md
  • Architecture: /CLAUDE.md

Last Updated: November 4, 2025 Maintainers: TurfAI Development Team

On this page