Environment Variables
Catafract requires several environment variables to be configured. Create a.env.local file in the project root with the following variables.
Required Variables
Authentication
Google OAuth Client ID from Google Cloud ConsoleHow to get:
- Go to Google Cloud Console
- Navigate to APIs & Services > Credentials
- Create OAuth 2.0 Client ID
- Copy the Client ID
Google OAuth Client Secret from Google Cloud ConsoleHow to get:
Available in the same location as Client ID
The base URL of your applicationDevelopment:Production:
Secret key for encrypting session tokensGenerate with:Example:
abc123xyz789...Azure Storage
Connection string for Azure Blob StorageFormat:How to get:
- Go to Azure Portal
- Navigate to your Storage Account
- Go to Access Keys
- Copy Connection String
Connection string for Azure Cosmos DBFormat:How to get:
- Go to Azure Portal
- Navigate to your Cosmos DB account
- Go to Keys
- Copy Primary Connection String
AI Model
API key for Google Gemini AIHow to get:
- Go to Google AI Studio
- Create API Key
- Copy the key
Optional Variables
Payment Processing (Polar)
Environment mode for Polar integrationValues:
local- Use sandbox modeproduction- Use production mode
productionPolar production access tokenHow to get:
- Sign up at Polar.sh
- Go to Settings > API Keys
- Create Production Access Token
Polar sandbox access token for testingHow to get:
Same as production token, but select Sandbox mode
Secret for verifying Polar webhooks (production)How to get:
- Go to Polar Settings > Webhooks
- Create webhook endpoint
- Copy the signing secret
Secret for verifying Polar webhooks (sandbox)
URL to redirect after successful paymentExample:
URL to return from customer portalExample:
Video Processing (Mux)
Mux API Token IDHow to get:
- Sign up at Mux
- Go to Settings > Access Tokens
- Create new token
- Copy Token ID
Mux API Token SecretHow to get:
Available when creating the token (copy immediately, not shown again)
Analytics (Mixpanel)
Mixpanel project tokenHow to get:
- Sign up at Mixpanel
- Create a project
- Go to Project Settings
- Copy Project Token
NEXT_PUBLIC_ to be available client-sideCustom proxy URL for Mixpanel API (optional)Use case: Bypass ad blockers or implement custom trackingDefault: Mixpanel’s default API endpoint
Complete Example
Azure Configuration
Required Azure Resources
-
Storage Account
- Container name:
catafract - Public access level: Blob (anonymous read access)
- Container name:
-
Cosmos DB Account
- API: Core (SQL)
- Database name:
catafract - Containers:
users(partition key:/email)projects(partition key:/userId)canvas(partition key:/projectId)generations(partition key:/userId)
Creating Azure Resources
Validation
To validate your configuration, run:Security Best Practices
- Never commit
.env.localto version control - Add
.env.localto.gitignore - Use different credentials for development and production
- Rotate secrets regularly
- Use Azure Key Vault for production secrets
- Enable Azure Storage firewall rules
- Implement IP restrictions on Cosmos DB
- Monitor API usage and set up alerts