Environment Variables
TractStack uses environment variables and configuration files to manage system behavior. Understanding these settings helps you customize and troubleshoot your installation.
Configuration File Locations
Section titled “Configuration File Locations”Development
Section titled “Development”- Backend:
~/t8k/src/tractstack-go/.env
- Frontend:
~/t8k/src/my-tractstack/.env
- Site config:
~/t8k/t8k-go-server/config/default/env.json
Production
Section titled “Production”- Backend:
/home/t8k/src/tractstack-go/.env
- Frontend:
/home/t8k/src/my-tractstack/.env
- Site config:
/home/t8k/t8k-go-server/config/default/env.json
Backend Environment Variables
Section titled “Backend Environment Variables”Core Settings
Section titled “Core Settings”File: .env
in tractstack-go directory
# Application ModeGIN_MODE=debug # debug, releasePORT=10000 # HTTP server port
# Database ConfigurationDB_PATH=../../t8k-go-server/db/default/tractstack.dbENABLE_TURSO=false # Enable Turso cloud databaseTURSO_DATABASE_URL= # Turso database URLTURSO_AUTH_TOKEN= # Turso authentication token
# File PathsCONFIG_PATH=../../t8k-go-server/configMEDIA_PATH=../../t8k-go-server/config/default/mediaLOG_PATH=../../t8k-go-server/log
# Multi-tenant ConfigurationENABLE_MULTI_TENANT=false # Enable multi-tenant featuresMAX_TENANTS=100 # Maximum number of tenants
# SecurityCORS_ORIGINS=http://localhost:4321,https://yourdomain.comRATE_LIMIT_ENABLED=true # Enable API rate limitingRATE_LIMIT_REQUESTS=100 # Requests per minute per IP
Advanced Settings
Section titled “Advanced Settings”# CachingENABLE_REDIS=false # Enable Redis cachingREDIS_URL=redis://localhost:6379
# External ServicesAAI_API_KEY= # Assembly AI API keyRESEND_API_KEY= # Resend email API keyGOOGLE_ANALYTICS_KEY= # Google Analytics measurement ID
# PerformanceMAX_UPLOAD_SIZE=10485760 # 10MB max file uploadWORKER_POOL_SIZE=10 # Background worker pool sizeCACHE_TTL=3600 # Cache time-to-live in seconds
# LoggingLOG_LEVEL=info # debug, info, warn, errorLOG_FORMAT=json # json, textENABLE_ACCESS_LOG=true # HTTP access logging
Frontend Environment Variables
Section titled “Frontend Environment Variables”Core Settings
Section titled “Core Settings”File: .env
in my-tractstack directory
# Backend ConnectionPUBLIC_GO_BACKEND=http://localhost:10000PUBLIC_TENANTID=default
# Multi-tenantPUBLIC_ENABLE_MULTI_TENANT=false
# DevelopmentNODE_ENV=development # development, productionASTRO_TELEMETRY_DISABLED=1 # Disable Astro telemetry
Production Settings
Section titled “Production Settings”# Backend ConnectionPUBLIC_GO_BACKEND=https://yourdomain.comPUBLIC_TENANTID=default
# Multi-tenantPUBLIC_ENABLE_MULTI_TENANT=true
# ProductionNODE_ENV=productionBUILD_PATH=./dist
Site Configuration (env.json)
Section titled “Site Configuration (env.json)”Core Settings
Section titled “Core Settings”File: config/default/env.json
{ "SITE_URL": "https://yourdomain.com", "SITE_INIT": true, "HOME_SLUG": "hello", "SITE_NAME": "Your Site Name", "SITE_DESCRIPTION": "Your site description",
"ADMIN_PASSWORD_HASH": "...", "EDITOR_PASSWORD_HASH": "...", "JWT_SECRET": "secure-random-string-here", "AES_KEY": "32-character-encryption-key-here",
"TIME_ZONE": "America/New_York", "LANGUAGE": "en", "CONTACT_EMAIL": "admin@yourdomain.com"}
Advanced Settings
Section titled “Advanced Settings”{ "SEO_SETTINGS": { "DEFAULT_META_DESCRIPTION": "Default page description", "DEFAULT_KEYWORDS": "keyword1, keyword2, keyword3", "SOCIAL_IMAGE": "/og-image.jpg", "ROBOTS_TXT": "User-agent: *\nDisallow:" },
"ANALYTICS": { "GOOGLE_ANALYTICS_ID": "G-XXXXXXXXXX", "ENABLE_INTERNAL_ANALYTICS": true, "TRACK_SCROLL_DEPTH": true, "TRACK_CLICK_EVENTS": true },
"PERFORMANCE": { "ENABLE_IMAGE_OPTIMIZATION": true, "ENABLE_CSS_MINIFICATION": true, "ENABLE_JS_MINIFICATION": true, "CACHE_STATIC_ASSETS": true },
"FEATURES": { "ENABLE_COMMENTS": false, "ENABLE_SEARCH": true, "ENABLE_RSS": true, "ENABLE_SITEMAP": true }}
Multi-Tenant Configuration
Section titled “Multi-Tenant Configuration”Tenant-Specific Settings
Section titled “Tenant-Specific Settings”Each tenant has its own configuration at:
config/{tenant-id}/env.json
{ "TENANT_ID": "tenant-name", "SITE_URL": "https://tenant-name.yourdomain.com", "SITE_NAME": "Tenant Site Name", "HOME_SLUG": "home",
"ADMIN_PASSWORD_HASH": "...", "EDITOR_PASSWORD_HASH": "...",
"STORAGE_QUOTA": "1GB", "MAX_PAGES": 100, "MAX_USERS": 5,
"CUSTOM_DOMAIN": null, "SSL_ENABLED": true}
Global Multi-Tenant Settings
Section titled “Global Multi-Tenant Settings”File: config/t8k/tenants.json
{ "max_tenants": 100, "default_quota": "1GB", "enable_custom_domains": true, "require_email_verification": true, "auto_ssl": true,
"tenants": [ { "id": "tenant1", "domain": "tenant1.yourdomain.com", "created": "2024-01-01T00:00:00Z", "active": true } ]}
Database Configuration
Section titled “Database Configuration”SQLite (Default)
Section titled “SQLite (Default)”# Backend .envDB_TYPE=sqliteDB_PATH=../../t8k-go-server/db/default/tractstack.dbENABLE_WAL_MODE=true # Write-Ahead LoggingSQLITE_CACHE_SIZE=2000 # Cache size in KB
Turso Cloud Database
Section titled “Turso Cloud Database”# Backend .envENABLE_TURSO=trueTURSO_DATABASE_URL=libsql://your-database.turso.ioTURSO_AUTH_TOKEN=your-auth-tokenTURSO_SYNC_INTERVAL=5m # Sync interval
Security Configuration
Section titled “Security Configuration”Authentication Settings
Section titled “Authentication Settings”{ "JWT_EXPIRY": "24h", "SESSION_TIMEOUT": "8h", "MAX_LOGIN_ATTEMPTS": 5, "LOCKOUT_DURATION": "15m",
"PASSWORD_POLICY": { "min_length": 8, "require_uppercase": true, "require_lowercase": true, "require_numbers": true, "require_symbols": false }}
CORS Configuration
Section titled “CORS Configuration”# Backend .envCORS_ORIGINS=https://yourdomain.com,https://www.yourdomain.comCORS_METHODS=GET,POST,PUT,DELETE,OPTIONSCORS_HEADERS=Content-Type,Authorization,X-Tenant-IDCORS_CREDENTIALS=true
Performance Tuning
Section titled “Performance Tuning”Caching Settings
Section titled “Caching Settings”# Backend .envENABLE_CACHE=trueCACHE_TYPE=memory # memory, redisCACHE_TTL=3600 # 1 hourCACHE_MAX_SIZE=100MBCACHE_CLEANUP_INTERVAL=300 # 5 minutes
Rate Limiting
Section titled “Rate Limiting”# Backend .envRATE_LIMIT_ENABLED=trueRATE_LIMIT_REQUESTS=100 # Per minuteRATE_LIMIT_BURST=10 # Burst capacityRATE_LIMIT_WINDOW=60 # Time window in seconds
Development vs Production
Section titled “Development vs Production”Development Configuration
Section titled “Development Configuration”# Development settingsGIN_MODE=debugLOG_LEVEL=debugENABLE_CORS=trueCORS_ORIGINS=http://localhost:4321ENABLE_HOT_RELOAD=trueCACHE_DISABLED=true
Production Configuration
Section titled “Production Configuration”# Production settingsGIN_MODE=releaseLOG_LEVEL=infoENABLE_CORS=trueCORS_ORIGINS=https://yourdomain.comENABLE_HOT_RELOAD=falseCACHE_ENABLED=trueENABLE_COMPRESSION=true
Environment Variable Priority
Section titled “Environment Variable Priority”Settings are loaded in this order (later values override earlier ones):
- Default values (hardcoded in application)
- Configuration files (env.json)
- Environment variables (.env files)
- System environment variables
- Command line flags
Validation and Troubleshooting
Section titled “Validation and Troubleshooting”Check Current Configuration
Section titled “Check Current Configuration”# Backend configurationcd ~/t8k/src/tractstack-go./tractstack-go --config-check
# View environment variablesenv | grep -E "(DB_|SITE_|PUBLIC_)"
# Validate JSON configurationcat ~/t8k/t8k-go-server/config/default/env.json | jq .
Common Configuration Issues
Section titled “Common Configuration Issues”Database connection errors:
# Check database pathls -la ~/t8k/t8k-go-server/db/default/
# Verify permissionschmod 644 ~/t8k/t8k-go-server/db/default/tractstack.db
CORS errors:
# Check CORS origins include your frontend URLgrep CORS_ORIGINS ~/t8k/src/tractstack-go/.env
File upload issues:
# Check media directory permissionsls -la ~/t8k/t8k-go-server/config/default/media/chmod -R 755 ~/t8k/t8k-go-server/config/default/media/
Proper environment configuration ensures TractStack runs optimally in your specific environment. Always backup configuration files before making changes.