Configuration File
Create a.env.local file in the project root by copying the example:
Required Variables
These variables are essential for Repolyze to work:OpenRouter API Key
Used for AI-powered repository analysis.Sign up for OpenRouter
Go to OpenRouter and create an account.
OpenRouter provides access to multiple AI models. Repolyze uses it to generate code analysis, insights, and recommendations.
GitHub Token
Required to fetch repository data from the GitHub API.Go to GitHub Settings
Navigate to GitHub Settings → Developer settings → Personal access tokens → Tokens (classic)
Select scopes
Choose the following scopes:
repo- Full control of private repositoriesread:user- Read user profile data
The GitHub token is used server-side only and never exposed to the browser. It allows Repolyze to fetch repository structure, files, and metadata.
Database URL
PostgreSQL connection string for user data and rate limiting.postgresql://[user]:[password]@[host]:[port]/[database]
See the Database Setup page for detailed configuration.
NextAuth Secret
Secret key for encrypting session tokens and cookies.OAuth Providers (Optional)
Repolyze supports GitHub and Google OAuth for user authentication.GitHub OAuth
Register OAuth App
Go to GitHub Developer Settings → OAuth Apps → New OAuth App
Configure settings
- Application name: Repolyze (Development)
- Homepage URL:
http://localhost:3000 - Authorization callback URL:
http://localhost:3000/api/auth/callback/github
Google OAuth
Create Google Cloud Project
Go to Google Cloud Console and create a new project.
Create OAuth client
- Application type: Web application
- Authorized redirect URIs:
http://localhost:3000/api/auth/callback/google
Polar.sh Integration (Optional)
For subscription and payment management.Polar.sh is used for managing pro subscriptions. If you’re not implementing paid features, you can skip this.
Public Variables
These variables are prefixed withNEXT_PUBLIC_ and are exposed to the browser.
Site URL
- SEO metadata
- Social sharing URLs
- OAuth callback URLs
In production, set this to your deployed URL (e.g.,
https://repolyze.ossium.live)Umami Analytics (Optional)
Promo Banner (Optional)
Complete Example
Here’s a complete.env.local file with all variables:
Environment-Specific Configuration
Development
For local development, use.env.local:
Production
For production deployment (e.g., Vercel), set environment variables in your hosting platform:Security Best Practices
Keep secrets secure
Keep secrets secure
- Never commit
.env.localor.env.productionto version control - Add
.env*.localto your.gitignorefile - Use different API keys for development and production
Rotate keys regularly
Rotate keys regularly
- Regenerate API keys periodically
- Update keys immediately if they’re exposed
- Use key rotation features provided by services
Limit key permissions
Limit key permissions
- Use minimum required scopes for GitHub tokens
- Restrict API key access to specific IP addresses when possible
- Monitor API usage for suspicious activity
Use environment-specific keys
Use environment-specific keys
- Development keys for local testing
- Staging keys for pre-production
- Production keys for live deployment
Troubleshooting
API key not working
API key not working
- Verify the key is correct (no extra spaces or line breaks)
- Check if the key has been revoked or expired
- Ensure the key has the required permissions/scopes
- Restart the development server after changing environment variables
Environment variables not loading
Environment variables not loading
- Make sure the file is named
.env.local(not.env) - Restart the Next.js dev server (
pnpm dev) - Check for syntax errors in the
.env.localfile - Verify the file is in the project root directory
OAuth redirect errors
OAuth redirect errors
- Verify the callback URL matches exactly in OAuth settings
- Check that
NEXT_PUBLIC_SITE_URLis set correctly - Ensure OAuth app is approved (not in development mode)
- Clear browser cookies and try again
Next Steps
Database Setup
Configure PostgreSQL and run Prisma migrations
Installation
Complete the installation process