Overview
The CS Interview Assistant uses environment variables for configuration, API keys, and sensitive credentials. All environment variables should be defined in a.env file in the backend root directory.
Quick Start
Create a.env file in the backend/ directory:
Required Variables
These variables must be set for the application to function properly.Mistral AI Configuration
Your Mistral AI API key for accessing language models.How to obtain:Used in:
- Sign up at Mistral AI Console
- Navigate to API Keys section
- Create a new API key
- Copy the key to your
.envfile
backend/app.py:612-617, RAG system, adaptive interview controllerThe application will fail to start if
MISTRAL_API_KEY is not set, as it’s required for core AI features including RAG, mock interviews, and coding exercises.Security Variables
These variables control authentication and session management. While defaults are provided, you must change them in production.Flask Session Management
Flask secret key for session encryption and security.Default: Generate secure key:Defined in:
'your-secret-key-here' (development only)Production requirement: Generate a secure random keyExample:backend/config.py:16, backend/app.py:137JWT Authentication
Secret key for signing JSON Web Tokens (JWT) used for API authentication.Default: Generate secure key:Defined in:
'your-jwt-secret-key-here' (development only)Production requirement: Generate a different key from SECRET_KEYExample:backend/config.py:25, backend/app.py:154Token expiration: 24 hours (configured in config.py:26)AI Model Configuration
Mistral Model Selection
Specifies which Mistral model to use for AI operations.Available models:Defined in:
mistral-large-latest- Most capable, recommended for productionmistral-medium-latest- Balanced performance and costmistral-small-latest- Faster, lower costopen-mistral-7b- Open source model
backend/config.py:29, backend/app.py:610Impact: Affects quality of interview questions, code analysis, and RAG responsesThe default
mistral-large-latest model provides the best results for technical interviews. Consider smaller models only if cost optimization is critical.Optional Variables
These variables enable additional features but are not required for basic operation.Speech-to-Text Services
AssemblyAI API key for real-time speech transcription during voice interviews.When to use: Enable this for production-quality real-time transcriptionFallback: If not set, the system uses a mock transcription service (no actual transcription)How to obtain:Used in:
- Sign up at AssemblyAI
- Get your API key from the dashboard
backend/assemblyai_websocket_stream.pyWithout
ASSEMBLYAI_API_KEY, voice interview features will use a mock transcription service that collects audio but doesn’t transcribe it. This is useful for development but not for production.Database Configuration
Default SQLite Configuration
By default, the application uses SQLite with no additional configuration needed:instance/interview_prep.db (created automatically)
PostgreSQL Configuration (Production)
For production deployments, use PostgreSQL by setting:PostgreSQL connection string (production environments only).Format:Example:To enable: Modify
backend/config.py:17 to use this variable:File Upload Configuration
These settings are configured inconfig.py but can be overridden via environment variables if needed.
Directory for storing uploaded files (resumes, audio recordings).Defined in:
backend/config.py:21Maximum file upload size in bytes (default: 16MB).Defined in:
backend/config.py:22RAG System Paths
These paths are configured inconfig.py and typically don’t need environment variable overrides:
Complete .env Template
Here’s a complete.env file template with all available variables:
Security Best Practices
1. Never Commit Secrets
2. Use Different Keys for Each Environment
Maintain separate.env files for development, staging, and production:
.env.development.env.staging.env.production
3. Rotate Keys Regularly
In production:- Rotate
SECRET_KEYandJWT_SECRET_KEYevery 90 days - Rotate
MISTRAL_API_KEYif compromised - Update all active sessions after key rotation
4. Use Environment Variable Management
For production deployments, consider using:- Docker Secrets for containerized deployments
- AWS Secrets Manager or Azure Key Vault for cloud deployments
- HashiCorp Vault for enterprise environments
5. Restrict File Permissions
Loading Environment Variables
The application automatically loads environment variables usingpython-dotenv:
- System environment variables
.envfile in backend directory- Default values in code
Verification
Verify your environment configuration:Troubleshooting
Environment Variables Not Loading
Problem: Application uses default values instead of.env values
Solutions:
- Ensure
.envfile is in the correct directory (backend/.env) - Check file permissions:
chmod 644 .env - Verify no syntax errors in
.env(no spaces around=) - Restart the application after modifying
.env
API Key Invalid
Problem:MISTRAL_API_KEY authentication fails
Solutions:
- Verify the key is copied correctly (no extra spaces)
- Check if the key is active in Mistral AI Console
- Ensure no quotes around the value in
.env - Test the key directly:
Database Connection Issues
Problem: PostgreSQL connection fails Solutions:- Verify
DATABASE_URLformat is correct - Check if PostgreSQL is running:
pg_isready - Verify credentials and database exists
- Ensure config.py is modified to use
DATABASE_URL
Next Steps
Requirements
Review system and dependency requirements
Production Setup
Configure production deployment