Environment Variables

Complete .env reference for NFYio. Required vs optional variables grouped by service: Core, Database, Storage, Auth, AI, Networking.

This reference lists all environment variables used by NFYio. Variables are grouped by service. Required variables must be set for the service to start; optional variables have defaults.

Core Variables

VariableRequiredDefaultDescription
NODE_ENVNodevelopmentdevelopment, production, or test
LOG_LEVELNoinfodebug, info, warn, error
PUBLIC_URLYes (prod)Public base URL (e.g., https://api.yourdomain.com)
PORTNo3000HTTP port for gateway
SESSION_SECRETYes64+ character secret for session encryption. Generate with openssl rand -hex 64

Database

VariableRequiredDefaultDescription
DATABASE_URLYesPostgreSQL connection string
POSTGRES_HOSTYes*PostgreSQL host (*if not using DATABASE_URL)
POSTGRES_PORTNo5432PostgreSQL port
POSTGRES_USERYes*PostgreSQL username
POSTGRES_PASSWORDYes*PostgreSQL password
POSTGRES_DBYes*nfyioPostgreSQL database name

Connection string format:

postgres://USER:PASSWORD@HOST:PORT/DATABASE?sslmode=disable

Redis

VariableRequiredDefaultDescription
REDIS_URLYesRedis connection string
REDIS_HOSTYes*Redis host (*if not using REDIS_URL)
REDIS_PORTNo6379Redis port
REDIS_PASSWORDNoRedis password (empty for no auth)

Connection string format:

redis://[:PASSWORD@]HOST:PORT[/DB]

Storage

VariableRequiredDefaultDescription
SEAWEEDFS_MASTERYesSeaweedFS master URL (e.g., http://seaweedfs-master:9333)
STORAGE_PORTNo7007S3 proxy port
MAX_UPLOAD_SIZENo5368709120Max upload size in bytes (default 5GB)
MULTIPART_PART_SIZENo67108864Multipart part size (default 64MB)

Auth (Keycloak)

VariableRequiredDefaultDescription
KEYCLOAK_URLYesKeycloak base URL (e.g., https://keycloak.yourdomain.com)
KEYCLOAK_REALMNonfyioKeycloak realm
KEYCLOAK_CLIENT_IDNonfyio-gatewayKeycloak client ID
KEYCLOAK_CLIENT_SECRETYes*Client secret (*for confidential clients)
KEYCLOAK_ADMINNoadminKeycloak admin username
KEYCLOAK_ADMIN_PASSWORDYesKeycloak admin password

AI / Embeddings

VariableRequiredDefaultDescription
EMBEDDINGS_ENABLEDNofalseEnable embedding pipeline
OPENAI_API_KEYYes*OpenAI API key (*if using OpenAI)
OPENAI_EMBEDDING_MODELNotext-embedding-3-smallOpenAI embedding model
VOYAGE_API_KEYYes*Voyage AI key (*if using Voyage)
VOYAGE_EMBEDDING_MODELNovoyage-2Voyage embedding model
EMBEDDING_BATCH_SIZENo32Batch size for embedding requests
CHUNK_SIZENo512Default chunk size (tokens)
CHUNK_OVERLAPNo50Chunk overlap (tokens)

AI / Agent (LLM)

VariableRequiredDefaultDescription
DEFAULT_LLM_MODELNogpt-4o-miniDefault LLM for agents
OPENAI_API_KEYYes*OpenAI API key (*for GPT models)
ANTHROPIC_API_KEYYes*Anthropic key (*for Claude)
MAX_CONTEXT_TOKENSNo8192Max context window size

Networking / CORS

VariableRequiredDefaultDescription
ALLOWED_ORIGINSYes (prod)Comma-separated CORS origins (e.g., https://app.yourdomain.com)
CORS_MAX_AGENo86400Preflight cache duration (seconds)
TRUST_PROXYNofalseTrust X-Forwarded-* headers (set true behind reverse proxy)

Rate Limiting

VariableRequiredDefaultDescription
RATE_LIMIT_ENABLEDNotrueEnable rate limiting
RATE_LIMIT_PER_MINNo1000Requests per minute per IP/key
RATE_LIMIT_BURSTNo100Burst allowance

Example .env File

# ── Core ─────────────────────────────────────────────
NODE_ENV=production
LOG_LEVEL=info
PUBLIC_URL=https://api.yourdomain.com
SESSION_SECRET=your-64-char-hex-secret-from-openssl-rand-hex-64

# ── Database ──────────────────────────────────────────
DATABASE_URL=postgres://nfyio:your-password@postgres:5432/nfyio

# ── Redis ────────────────────────────────────────────
REDIS_URL=redis://:your-redis-password@redis:6379/0

# ── Storage ──────────────────────────────────────────
SEAWEEDFS_MASTER=http://seaweedfs-master:9333

# ── Auth (Keycloak) ─────────────────────────────────
KEYCLOAK_URL=https://keycloak.yourdomain.com
KEYCLOAK_REALM=nfyio
KEYCLOAK_ADMIN=admin
KEYCLOAK_ADMIN_PASSWORD=your-keycloak-admin-password

# ── AI (optional) ────────────────────────────────────
EMBEDDINGS_ENABLED=true
OPENAI_API_KEY=sk-...
OPENAI_EMBEDDING_MODEL=text-embedding-3-small

# ── Networking ──────────────────────────────────────
ALLOWED_ORIGINS=https://app.yourdomain.com,https://admin.yourdomain.com
TRUST_PROXY=true

Variable Precedence

  1. Environment — Variables set in the shell or container
  2. .env file — Loaded by Docker Compose or the application
  3. Defaults — Application defaults for optional variables

Security Notes

  • Never commit .env files to version control. Add .env to .gitignore.
  • Use secrets management (e.g., Docker secrets, Kubernetes secrets) in production.
  • Rotate SESSION_SECRET, database passwords, and API keys periodically.
  • Restrict ALLOWED_ORIGINS to your actual domains.

Next Steps