Skip to main content

Overview

Interview Simulator is configured through environment variables defined in a .env file. The application uses python-dotenv to load these variables at startup.

Configuration File

Configuration is managed by the Config class in app/config.py:
app/config.py
class Config:
    SECRET_KEY = os.getenv("SECRET_KEY", "dev-secret-key-change-in-production")
    UPLOAD_FOLDER = os.getenv("UPLOAD_FOLDER", "uploads")
    MAX_CONTENT_LENGTH = int(os.getenv("MAX_CONTENT_LENGTH", 16 * 1024 * 1024))

    SQLALCHEMY_DATABASE_URI = os.getenv("DATABASE_URL", "sqlite:///dev.db")
    SQLALCHEMY_TRACK_MODIFICATIONS = False

    OPENROUTER_API_KEY = os.getenv("OPENROUTER_API_KEY", "")
    GEMINI_API_KEY = os.getenv("GEMINI_API_KEY", "")
    ACTIVE_PROVIDERS = os.getenv("ACTIVE_PROVIDERS", "openrouter,gemini")

Environment Variables

Flask Core Settings

SECRET_KEY
string
default:"dev-secret-key-change-in-production"
Secret key used for Flask session signing and security features.
Never use the default value in production. Generate a strong random key:
python -c 'import secrets; print(secrets.token_hex(32))'
FLASK_ENV
string
default:"development"
Flask environment mode. Controls debug mode and error handling.Values:
  • development: Enables debug mode, auto-reload, and verbose errors
  • production: Disables debug mode and optimizes for performance
Always set to production in deployed environments.

File Upload Settings

UPLOAD_FOLDER
string
default:"uploads"
Directory path where uploaded CV/resume files are stored.The application creates this directory automatically if it doesn’t exist.
MAX_CONTENT_LENGTH
integer
default:"16777216"
Maximum allowed file upload size in bytes.Default: 16MB (16 * 1024 * 1024)Example values:
  • 5242880 = 5MB
  • 26214400 = 25MB
  • 52428800 = 50MB
Requests exceeding this size are rejected with a 413 error.

Database Settings

DATABASE_URL
string
default:"sqlite:///dev.db"
SQLAlchemy database connection string.SQLite (default):
DATABASE_URL=sqlite:///instance/app.db
PostgreSQL:
DATABASE_URL=postgresql://user:password@localhost:5432/interview_sim
MySQL:
DATABASE_URL=mysql://user:password@localhost:3306/interview_sim
The application automatically creates tables on first run using SQLAlchemy migrations.

AI Provider Settings

GEMINI_API_KEY
string
default:""
Google Gemini API key for AI-powered interview questions and feedback.Get your API key from: https://ai.google.dev/Default model: gemini-2.5-flashIf not set, the Gemini provider will not be initialized.
OPENROUTER_API_KEY
string
default:""
OpenRouter API key for accessing multiple LLM providers through a unified interface.Get your API key from: https://openrouter.ai/Default model: openai/gpt-oss-20b:freeIf not set, the OpenRouter provider will not be initialized.
ACTIVE_PROVIDERS
string
default:"openrouter,gemini"
Comma-separated list of AI providers to enable.Values:
  • openrouter: Enable OpenRouter
  • gemini: Enable Google Gemini
Examples:
# Use only Gemini
ACTIVE_PROVIDERS=gemini

# Use only OpenRouter
ACTIVE_PROVIDERS=openrouter

# Use both (default)
ACTIVE_PROVIDERS=openrouter,gemini
Note: Providers are only enabled if their corresponding API key is set.

Example Configuration

Development

.env
# Development configuration
FLASK_ENV=development
SECRET_KEY=dev-secret-key-change-in-production

# Local SQLite database
DATABASE_URL=sqlite:///instance/app.db

# AI Providers - at least one required
GEMINI_API_KEY=your-gemini-api-key
OPENROUTER_API_KEY=your-openrouter-api-key
ACTIVE_PROVIDERS=openrouter,gemini

# File uploads
UPLOAD_FOLDER=uploads
MAX_CONTENT_LENGTH=16777216

Production

.env
# Production configuration
FLASK_ENV=production
SECRET_KEY=a1b2c3d4e5f6789... # Generate with secrets.token_hex(32)

# PostgreSQL database
DATABASE_URL=postgresql://user:[email protected]:5432/interview_prod

# AI Providers
GEMINI_API_KEY=your-production-gemini-key
OPENROUTER_API_KEY=your-production-openrouter-key
ACTIVE_PROVIDERS=openrouter,gemini

# File uploads
UPLOAD_FOLDER=/var/app/uploads
MAX_CONTENT_LENGTH=26214400  # 25MB

Configuration Loading

The configuration is loaded at application startup:
from dotenv import load_dotenv

load_dotenv()  # Loads .env file
Configuration precedence (highest to lowest):
  1. Environment variables set in the shell
  2. Variables defined in .env file
  3. Default values in Config class

Validation

Required Settings

The following settings must be configured for production:
1

SECRET_KEY

Must be set to a strong random value (not the default).
2

At least one AI provider

Either GEMINI_API_KEY or OPENROUTER_API_KEY must be set. The application logs a warning if no providers are configured:
app/extensions.py
if not providers:
    app.logger.warning("No AI providers configured! Check your API keys.")
    return
3

FLASK_ENV=production

Must be set to production for deployed environments.

Runtime Checks

The application performs validation during initialization in app/extensions.py:
app/extensions.py
def init_ai_providers(app):
    openrouter_key = app.config.get("OPENROUTER_API_KEY", "")
    gemini_key = app.config.get("GEMINI_API_KEY", "")
    
    providers = []
    
    if openrouter_key:
        providers.append(OpenRouterProvider(...))
    
    if gemini_key:
        providers.append(GeminiProvider(...))
    
    if not providers:
        app.logger.warning("No AI providers configured!")

SQLAlchemy Settings

SQLALCHEMY_DATABASE_URI
string
Internal SQLAlchemy setting. Automatically set from DATABASE_URL.
SQLALCHEMY_TRACK_MODIFICATIONS
boolean
default:"false"
SQLAlchemy event system. Always set to False to avoid overhead.This setting is hardcoded in the Config class:
SQLALCHEMY_TRACK_MODIFICATIONS = False

Configuration Best Practices

  1. Never commit .env files: The .env file is gitignored and should never be committed to version control
  2. Use .env.example as a template: Copy .env.example to .env and fill in actual values
  3. Rotate secrets regularly: Change SECRET_KEY and API keys periodically
  4. Use environment-specific configs: Maintain separate .env files for dev/staging/prod
  5. Validate on startup: The application logs configuration status on initialization

Troubleshooting

”No AI providers configured” warning

Cause: Neither GEMINI_API_KEY nor OPENROUTER_API_KEY is set. Solution: Set at least one API key in your .env file.

Database connection errors

Cause: Invalid DATABASE_URL format or unreachable database server. Solution: Verify connection string format and network connectivity:
# Test PostgreSQL connection
psql postgresql://user:password@host:5432/dbname

File upload 413 errors

Cause: Uploaded file exceeds MAX_CONTENT_LENGTH. Solution: Increase the limit or reduce file size:
MAX_CONTENT_LENGTH=52428800  # 50MB

Build docs developers (and LLMs) love