Environment File Setup
Create a.env file in the root of your project based on .env.example:
Required Variables
Server-Side Variables
These variables are only accessible on the server and never exposed to the client bundle.GROQ_API_KEY
Required - API key for Groq AI service (Llama 3)
- Purpose: Enables AI coaching features powered by Groq’s LLM
- Where to get it: Create a free account at console.groq.com
- Free tier limits: Groq offers fast access with rate limits on RPM (Requests Per Minute) and daily tokens
PORT
- Purpose: Port for serverless/express local environments
- Default: 3001 if not specified
- Optional: Yes
Client-Side Variables (VITE_)
These variables are embedded into the client bundle at build time and are publicly accessible.VITE_SUPABASE_URL
Required - Your Supabase project URL
- Purpose: Database connection URL
- Where to get it: Supabase Dashboard → Project Settings → API → Project URL
VITE_SUPABASE_ANON_KEY
Required - Supabase anonymous public key
- Purpose: Public API key for client-side database access
- Where to get it: Supabase Dashboard → Project Settings → API → Project API keys → anon/public
- Security: Protected by Row Level Security (RLS) policies
VITE_APP_URL
Required - Application URL for authentication redirects
- Purpose: OAuth redirect URL for authentication flows
- Development: Use
http://localhost:5173 - Production: Use your actual domain
NODE_ENV
- Purpose: Application environment
- Values:
developmentorproduction - Optional: Yes (defaults to development)
Complete Example
Security Best Practices
Protecting Secrets
- Server-only secrets: Variables without the
VITE_prefix are only available server-side - Client secrets: Any variable with
VITE_prefix will be embedded in the client bundle - Row Level Security: Supabase RLS policies protect your data even with public keys
Getting API Keys
Supabase API Keys
Access Supabase Dashboard
Go to supabase.com and sign in to your project
Groq API Key
Create Groq account
Visit console.groq.com and sign up for free
Verifying Configuration
Verify all required variables are set
Ensure
GROQ_API_KEY, VITE_SUPABASE_URL, VITE_SUPABASE_ANON_KEY, and VITE_APP_URL are presentTroubleshooting
”AI Coach connection error”
- Verify
GROQ_API_KEYis set correctly - Check if you’ve exceeded Groq’s free tier rate limits
- Ensure the key hasn’t been revoked
”Supabase connection failed”
- Verify
VITE_SUPABASE_URLmatches your project URL exactly - Ensure
VITE_SUPABASE_ANON_KEYis the anon/public key (not the service_role key) - Check that your Supabase project is active
”OAuth redirect mismatch”
- Verify
VITE_APP_URLmatches the URL you’re accessing - Update Supabase Authentication settings with the correct redirect URL
- For production, ensure the domain is correct