Environment Variables
Relevant source files
The following files were used as context for generating this wiki page:
Environment variables are the primary method for configuring the Resume Matcher application, controlling everything from AI provider settings to server ports and inter-service communication. This system allows for flexible deployment across different environments (local development, Docker) without modifying the source code.
The backend (FastAPI) uses a .env file which is loaded by Pydantic settings, while the frontend (Next.js) can use an optional .env.local file to override default API endpoints. For Docker deployments, configuration is managed through the application's UI, which persists settings in a volume.
Backend Configuration (.env)
The backend configuration is managed via a .env file located in the apps/backend/ directory. This file is created by copying the template apps/backend/.env.example.
Sources: SETUP.md, AGENTS.md, INSTALL.md
Creation
To create the configuration file, run the following command in the apps/backend directory:
cp .env.example .env
Sources: SETUP.md, install.txt
Backend Variables
The following table details the environment variables used by the FastAPI backend.
| Variable | Description | Example |
|---|---|---|
LLM_PROVIDER | Specifies the AI provider to use. | openai |
LLM_MODEL | The specific model from the chosen provider. | gpt-4o-mini |
LLM_API_KEY | The API key for the selected cloud provider. Not needed for local Ollama. | sk-your-api-key-here |
LLM_API_BASE | The base URL for the LLM API. Primarily used for Ollama. | http://localhost:11434 |
HOST | The IP address the backend server binds to. | 0.0.0.0 |
PORT | The port the backend server listens on. | 8000 |
FRONTEND_BASE_URL | The full URL of the running frontend application. Crucial for PDF generation. | http://localhost:3000 |
CORS_ORIGINS | A list of allowed origins for Cross-Origin Resource Sharing. Must include the frontend URL. | ["http://localhost:3000", "http://127.0.0.1:3000"] |
Sources: SETUP.md, INSTALL.md
AI Provider Configuration
The application supports multiple AI providers, configured using LLM_PROVIDER and the corresponding LLM_MODEL.
| Provider | LLM_PROVIDER Value | Example Model |
|---|---|---|
| OpenAI | openai | gpt-4o-mini |
| Anthropic | anthropic | claude-3-5-sonnet-20241022 |
| Google Gemini | gemini | gemini-1.5-flash |
| OpenRouter | openrouter | anthropic/claude-3.5-sonnet |
| DeepSeek | deepseek | deepseek-chat |
| Ollama (Local) | ollama | llama3.2 |
Sources: SETUP.md, README.md, INSTALL.md
Example: Ollama Configuration
To use a local AI model with Ollama, the .env file should be configured as follows. Note that LLM_API_KEY is not required.
LLM_PROVIDER=ollama
LLM_MODEL=llama3.2
LLM_API_BASE=http://localhost:11434
Sources: SETUP.md
Configuration Loading Flow
The backend uses Pydantic settings to load, validate, and manage these environment variables from the .env file.
The diagram below illustrates how environment variables are loaded into the backend application.
Frontend Configuration (.env.local)
The Next.js frontend is largely zero-config but supports an optional .env.local file in the apps/frontend/ directory for overriding the default backend API URL. This is typically only necessary if the backend is not running on the default http://localhost:8000.
Sources: SETUP.md, INSTALL.md
Frontend Variables
| Variable | Description | Default (implied) |
|---|---|---|
NEXT_PUBLIC_API_URL | The URL of the backend API. | http://localhost:8000 |
Sources: INSTALL.md
Docker Deployment Configuration
When deploying with Docker Compose, the configuration approach changes significantly. Environment variables from .env files are not used for LLM configuration. Instead, API keys and provider settings are configured through the UI on the Settings page (/settings).
- UI-Based Configuration: Users must navigate to
http://localhost:3000/settingsto select their AI provider and enter the API key. - Data Persistence: This configuration is persisted in a Docker volume, ensuring it survives container restarts.
This flow is visualized in the sequence diagram below, showing how a user action in the frontend updates the configuration used by the backend.
This diagram shows the process of updating the LLM configuration via the frontend settings page.
Sources: apps/frontend/app/(default)/settings/page.tsx, AGENTS.md
Troubleshooting
Incorrect environment variable configuration is a common source of issues.
- PDF Generation Fails: This is often caused by an incorrect
FRONTEND_BASE_URLin the backend's.envfile. The backend must be able to reach the frontend via this URL to render the PDF. ECONNREFUSEDin Frontend: This error indicates the frontend cannot connect to the backend. Ensure the backend is running and thatNEXT_PUBLIC_API_URL(if used) is correct.- Ollama Connection Fails: Ensure the Ollama service is running and that
LLM_API_BASEis set to the correct URL (e.g.,http://localhost:11434for local,http://host.docker.internal:11434when running the app in Docker).
Sources: SETUP.md, INSTALL.md, README.md