Overview
Studley AI requires several environment variables to function properly. This guide covers all required and optional variables for deployment.Required Variables
Database Configuration
PostgreSQL database connection string. Used for primary data storage.Format:
postgresql://user:password@host:port/databaseExample:Supabase PostgreSQL connection URL for auth and database operations.Example:
Supabase Authentication
Your Supabase project URL. Found in Supabase project settings.Example:
Supabase anonymous/public key for client-side operations.Example:
Supabase service role key for server-side admin operations.Warning: Keep this secret! Never expose in client-side code.Example:
AI Configuration
Groq API key for AI-powered features (quiz generation, flashcards, study guides).Get your API key from: https://console.groq.comExample:
Session Security
Secret key for signing JWT session tokens. Must be a strong random string.Generate with:Example:
Application URL
The public URL of your application. Used for OAuth redirects and email links.Development:Production:
Optional Variables
File Storage
Vercel Blob storage token for file uploads. Automatically set by Vercel if using Vercel Blob.Example:
Email Service
Resend API key for transactional emails (verification, notifications).Get your API key from: https://resend.comExample:
Bot Protection
Cloudflare Turnstile secret key for bot protection on forms.Example:
Clever Integration (Education)
Clever OAuth client ID for education platform integration.Example:
Clever OAuth client secret.Example:
Runtime Environment
Node environment. Automatically set by most hosting providers.Values:
development, production, testExample:Automatically set by Vercel. The deployment URL.Note: Do not set manually. Vercel provides this automatically.
Environment File Setup
Validation
Verify your environment variables are loaded correctly:Security Best Practices
Never commit secrets to Git
Never commit secrets to Git
- Always use
.env.localfor local development - Add all
.env*files to.gitignore - Use environment variable management in production
Use different keys for each environment
Use different keys for each environment
- Separate API keys for development, staging, and production
- Rotate keys regularly
- Revoke compromised keys immediately
Protect service role keys
Protect service role keys
- Never expose
SUPABASE_SERVICE_ROLE_KEYto the client - Only use in server-side code and API routes
- Store securely in production environment
Generate strong session secrets
Generate strong session secrets
Use cryptographically secure random strings:
Next Steps
Database Setup
Configure PostgreSQL and run migrations
Authentication Setup
Configure Supabase auth providers
AI Configuration
Set up Groq AI models and limits
Vercel Deployment
Deploy to production on Vercel