Skip to main content

Configuration Reference

Generated projects use pydantic-settings and read values from .env. Start from:

cp .env.example .env

Settings are resolved through get_settings(), which is cached for normal runtime use. The generated FastAPI application calls get_settings() inside create_app(), and the local runner calls it inside run.py's main(). This avoids import-time configuration in app.py.

When tests or scripts change environment variables in-process, clear the settings cache before creating the app:

from shop_api.app import create_app
from shop_api.settings import get_settings

get_settings.cache_clear()
app = create_app()

Application

SettingDefaultPurpose
APP_NAMEproject nameFastAPI title and status service name
APP_ENVdevelopmentRuntime environment label
APP_DEBUGtrueFastAPI debug mode
API_V1_PREFIX/api/v1Prefix for the generated API router

Database

SettingDefaultPurpose
DATABASE_URLsqlite:///./poleposition.dbSQLAlchemy database URL
POSTGRES_DBappLocal Docker PostgreSQL database
POSTGRES_USERpostgresLocal Docker PostgreSQL user
POSTGRES_PASSWORDpostgresLocal Docker PostgreSQL password
POSTGRES_PORT5432Host port for local Docker PostgreSQL

Projects generated with polepos start --db none omit DATABASE_URL, PostgreSQL settings, SQLAlchemy, and Alembic wiring. Projects generated with --db postgres start with a PostgreSQL DATABASE_URL instead of the SQLite default.

Use Alembic for schema changes:

polepos db revision -m "add customers table"
polepos db upgrade

For the full workflow, see Database and Migrations.

Runtime

SettingDefaultPurpose
APP_HOST127.0.0.1Host passed to Uvicorn
APP_PORT8000Port passed to Uvicorn
APP_RELOADtrueUvicorn reload mode
UVICORN_WORKERS1Worker process count
UVICORN_ACCESS_LOGtrueUvicorn access log toggle
UVICORN_PROXY_HEADERStrueTrust proxy headers
UVICORN_FORWARDED_ALLOW_IPS127.0.0.1Allowed proxy IPs
UVICORN_SERVER_HEADERtrueEmit server header
UVICORN_DATE_HEADERtrueEmit date header
UVICORN_TIMEOUT_KEEP_ALIVE5Keep-alive timeout
UVICORN_BACKLOG2048Socket backlog

Optional integer or boolean-like values can be left commented in .env.example until needed. Required generated values should stay active. polepos check treats commented required settings and env keys as missing so disabled examples do not accidentally satisfy the project contract.

run.py is the preferred local process entrypoint. It reads these values when main() runs and starts Uvicorn with <package>.main:app. main.py exposes the ASGI app, while app.py keeps the reusable create_app() factory.

Logging

SettingDefaultPurpose
LOG_LEVELINFOPython logging level
LOG_FORMATtexttext or json

Use json for structured production logs:

LOG_FORMAT=json

CORS

SettingDefaultPurpose
CORS_ENABLEDtrueEnable FastAPI CORS middleware
CORS_ALLOW_ORIGINSlocal frontend originsAllowed origins
CORS_ALLOW_ORIGIN_REGEXemptyOptional origin regex
CORS_ALLOW_CREDENTIALStrueAllow credentials
CORS_ALLOW_METHODScommon HTTP methodsAllowed methods
CORS_ALLOW_HEADERSauth and content headersAllowed headers
CORS_EXPOSE_HEADERSX-Request-IDExposed response headers
CORS_MAX_AGE600Browser preflight cache seconds

List settings accept JSON arrays:

CORS_ALLOW_ORIGINS=["https://app.example.com"]

Authentication

SettingDefaultPurpose
AUTH_SECRET_KEYchange-me-in-productionJWT signing secret
AUTH_ALGORITHMHS256JWT algorithm
AUTH_ACCESS_TOKEN_EXPIRE_MINUTES60Access token lifetime
AUTH_ISSUERproject nameExpected JWT issuer

Change AUTH_SECRET_KEY before deployment.

Kafka

Kafka settings are added by:

polepos add integration kafka

Important values:

  • KAFKA_ENABLED
  • KAFKA_BOOTSTRAP_SERVERS
  • KAFKA_CLIENT_ID
  • KAFKA_DEFAULT_TOPIC
  • KAFKA_GROUP_ID
  • KAFKA_REQUEST_TIMEOUT_MS

KAFKA_COMPRESSION_TYPE is generated as an optional commented example. Leave it commented until compression is needed; keep required values such as KAFKA_BOOTSTRAP_SERVERS active.

RabbitMQ

RabbitMQ settings are added by:

polepos add integration rabbitmq

Important values:

  • RABBITMQ_ENABLED
  • RABBITMQ_URL
  • RABBITMQ_CLIENT_ID
  • RABBITMQ_EXCHANGE
  • RABBITMQ_DEFAULT_ROUTING_KEY
  • RABBITMQ_DEFAULT_QUEUE
  • RABBITMQ_PREFETCH_COUNT

Redis

Redis settings are added by:

polepos add integration redis

Important values:

  • REDIS_ENABLED
  • REDIS_URL
  • REDIS_CLIENT_NAME
  • REDIS_KEY_PREFIX
  • REDIS_SOCKET_TIMEOUT_SECONDS

RQ

RQ settings are added by:

polepos add integration rq

Important values:

  • RQ_ENABLED
  • RQ_REDIS_URL
  • RQ_DEFAULT_QUEUE
  • RQ_WORKER_NAME
  • RQ_JOB_TIMEOUT_SECONDS
  • RQ_RESULT_TTL_SECONDS

LLM

LLM settings are added when an AI prompt module is generated:

polepos add module assistant --template ai-prompt

Important values:

  • LLM_PROVIDER
  • LLM_MODEL
  • LLM_API_KEY
  • LLM_BASE_URL
  • LLM_TIMEOUT_SECONDS
  • LLM_TEMPERATURE
  • LLM_MAX_TOKENS

LLM_MAX_TOKENS is generated as an optional commented example. Required values such as LLM_PROVIDER, LLM_MODEL, and LLM_API_KEY should remain active in .env.example, even when the value is empty.