Overview
TikTok Miner requires several environment variables for database connections, API integrations, and application configuration. This guide documents all available variables, their purposes, and whether they are required or optional.Quick Setup
Copy the example environment file:Database Configuration
PostgreSQL Connection
Connection string for the PostgreSQL database. Used for connection pooling.Format:
postgresql://USER:PASSWORD@HOST:PORT/DATABASE?pgbouncer=true&connection_limit=1&pool_timeout=0Example:For Supabase users, this should use the pooler URL with port 6543.
Direct connection to PostgreSQL, used for running migrations.Format:
postgresql://USER:PASSWORD@HOST:PORT/DATABASEExample:Database password used in connection strings.Example:
Redis Configuration
Redis connection URL for job queues and caching.Format:
redis://[username][:password]@host:port[/database]Example:The REDIS_URL is automatically configured in docker-compose.yml but needs to be set for local development.
Supabase Configuration
Your Supabase project URL.Example:
Supabase anonymous/public API key.Example:
This key is safe to use in client-side code as it has limited permissions.
AI & LLM Configuration
OpenAI
OpenAI API key for AI-powered features like creator analysis and content categorization.Example:
OpenAI model to use for text generation.Options:
gpt-4o, gpt-4-turbo, gpt-4, gpt-3.5-turboExample:Controls randomness in AI responses. Range: 0.0 to 2.0
- Lower values (0.0-0.3): More focused and deterministic
- Medium values (0.4-0.7): Balanced creativity
- Higher values (0.8-2.0): More creative and varied
Minimum confidence threshold for AI predictions. Range: 0.0 to 1.0Example:
Perplexity AI
Perplexity API key for enhanced research and discovery features.Example:
GitHub Integration
GitHub personal access token for API access and rate limit management.Permissions needed:
public_repo, read:userExample:Generate tokens at: https://github.com/settings/tokens
Multiple GitHub tokens for load balancing (comma-separated).Example:
Using multiple tokens helps avoid rate limits on high-traffic deployments.
Load balancing strategy for multiple GitHub tokens.Options:
ROUND_ROBINExample:Social Media API Keys
TikTok
TikTok API client key for accessing TikTok data.Example:
Register your app at: https://developers.tiktok.com/
TikTok API client secret.Example:
Instagram/Facebook Graph API client secret.Example:
Twitter/X
Twitter API v2 bearer token for read-only access.Example:
Get your bearer token from: https://developer.twitter.com/
YouTube
Email Configuration
Azure Email Service
Azure Communication Services connection string for sending emails.Format:
endpoint=https://...;accesskey=...Example:SMTP Configuration
SMTP server hostname.Example:
SMTP server port.Common values:
465: SSL/TLS587: STARTTLS25: Unencrypted (not recommended)
SMTP authentication username (usually your email address).Example:
SMTP authentication password or app-specific password.Example:
Use SSL/TLS for SMTP connection.
true: Port 465 (SSL)false: Port 587 (STARTTLS)
SMTP authentication method.Options:
login, plain, cram-md5Example:Application Configuration
Node.js environment mode.Options:
development, production, testExample:Port number for the application server.Example:
Public URL where the application is hosted. Used for OAuth redirects and email links.Example:
Logging verbosity level.Options:
debug, info, warn, errorExample:Use
debug for development and info or warn for production.pgAdmin Configuration (Development)
Email for pgAdmin login (development only).Example:
Password for pgAdmin login (development only).Example:
Environment-Specific Examples
Development Environment
Production Environment
Security Best Practices
- Use strong passwords: Generate secure random passwords for databases and Redis
- Rotate API keys: Regularly rotate sensitive API keys and tokens
- Limit permissions: Use API keys with minimum required permissions
- Environment isolation: Use different keys for development and production
- Secret management: Consider using secret management services like:
- AWS Secrets Manager
- HashiCorp Vault
- Azure Key Vault
- Google Secret Manager
Validation
Validate your environment configuration:- Database connectivity
- Redis connection
- API key validity
- Required vs optional variables
Troubleshooting
Database Connection Errors
Error: Connection refused
Error: Connection refused
- Verify PostgreSQL is running:
docker-compose ps postgres - Check DATABASE_URL format and credentials
- Ensure database port (5432) is accessible
Error: SSL required
Error: SSL required
Add
?sslmode=require to your DATABASE_URL:Migration errors
Migration errors
Use DIRECT_URL for migrations, not the pooler URL:
- Supabase: Port 5432 (not 6543)
- No pgbouncer parameters
API Key Issues
OpenAI rate limits
OpenAI rate limits
- Check your usage at: https://platform.openai.com/usage
- Reduce OPENAI_TEMPERATURE or switch to cheaper model
- Implement request caching
GitHub rate limits
GitHub rate limits
- Use multiple tokens with GITHUB_TOKENS
- Enable GITHUB_TOKEN_LB_STRATEGY=ROUND_ROBIN
- Check rate limit status in application logs
Next Steps
Docker Deployment
Deploy with Docker Compose
Database Setup
Configure Prisma and run migrations