Configuration file
All configuration is defined inapp/core/config.py using Pydantic’s BaseSettings class, which automatically loads values from environment variables and .env files.
Environment variables
Application settings
The name of the application. This value is used in the FastAPI documentation and API metadata.Status: Optional (has default value)
The version of the application. Displayed in API documentation.Status: Optional (has default value)
Database configuration
PostgreSQL connection string with pgvector extension support.Status: Required
Format:
Example:
Format:
postgresql://username:password@host:port/databaseExample:
postgresql://user:pass@localhost:5435/skudbThe database must have the
pgvector extension installed for vector similarity search to work.AI provider configuration
Google Gemini API key for embeddings and text generation.Status: Required
Used for:
Used for:
- Generating embeddings via
gemini-embedding-001 - Primary LLM for answer generation (Gemini 2.5 Flash, Gemini Flash Latest, Gemini 2.5 Pro)
Anthropic API key for fallback LLM generation.Status: Required
Used for:
Used for:
- Fallback LLM when Gemini fails (Claude 3 Haiku, Claude 3.5 Sonnet)
Security configuration
Secret key for signing JWT tokens used in authentication.Status: Required
Security: Must be a strong, random string. Never commit this value to version control.Generate a secure secret:
Security: Must be a strong, random string. Never commit this value to version control.Generate a secure secret:
Algorithm used for JWT token encoding and decoding.Status: Optional (has default value)
Default:
Supported values:
Default:
HS256Supported values:
HS256, HS384, HS512Expiration time for JWT access tokens in minutes.Status: Optional (has default value)
Default:
Default:
30 minutesShorter expiration times are more secure but require users to log in more frequently. Adjust based on your security requirements.
Setting up your environment
Create a .env file
Create a.env file in the root directory of your project:
Configuration loading order
Pydantic Settings loads configuration in the following order (later sources override earlier ones):- Default values defined in
Settingsclass - Values from
.envfile - Environment variables from the system
- Use
.envfor local development - Override with system environment variables in production
- Keep sensible defaults for optional settings
Accessing configuration
Configuration is available throughout the application via thesettings singleton:
Production considerations
Use environment variables instead of .env files
Use environment variables instead of .env files
In production environments (Docker, Kubernetes, cloud platforms), set environment variables directly rather than using
.env files. This is more secure and follows twelve-factor app principles.Docker example:Rotate secrets regularly
Rotate secrets regularly
Regularly rotate your
JWT_SECRET and API keys. When rotating JWT secrets:- Generate a new secret
- Update the configuration
- Restart the application
- Users will need to log in again (existing tokens become invalid)
Use secret management services
Use secret management services
For production deployments, consider using dedicated secret management:
- AWS Secrets Manager
- Google Cloud Secret Manager
- Azure Key Vault
- HashiCorp Vault