- Docs
- Core
- Fundamentals
- YAML configuration
YAML Configuration
QuadKit merges user-defined YAML files, environment variables, and code defaults into a single typed configuration object. This page covers the mechanics; for a task-oriented walkthrough see Configuration.
1. The Configuration File
Section titled “1. The Configuration File”The primary file is application.yaml in the project root. Core settings are top-level; each extension reads its own named section:
app_name: "order-service"debug: falseenv: "production"
logging: level: INFO json_format: true
web: # quadkit-web (config_section: "web") server: host: "${HOST:0.0.0.0}" port: "${PORT:8000}"
cli: # quadkit-cli (config_section: "cli") enabled: true color: trueLoading config
Section titled “Loading config”from quadkit import QuadKitConfig
config = QuadKitConfig.from_yaml() # ./application.yaml (CWD)config = QuadKitConfig.from_yaml("config/application.yaml")config = QuadKitConfig.from_env_profile() # recommended: same file, plus QK_PROFILERelative paths resolve from the process CWD. A missing file is not an error — QuadKit logs config.defaults_only and uses code defaults. Both loaders overlay application.{profile}.yaml when QK_PROFILE is set (or profile= is passed), then apply QK_* env vars. Application() with no config calls from_env_profile().
2. Environment Interpolation
Section titled “2. Environment Interpolation”QuadKit resolves ${VAR} placeholders inside YAML values at load time:
${PORT}— resolves to thePORTenv var; fails fast if unset.${PORT:8080}— resolves toPORT, or8080if unset.
web: server: host: "${HOST:0.0.0.0}" port: "${PORT:8000}"3. Environment-Variable Overrides
Section titled “3. Environment-Variable Overrides”Beyond interpolation, any key can be overridden by an environment variable using the QK_ prefix and double underscores (__) for nesting. This is the highest-priority source:
sql.backend.url → QK_SQL__BACKEND__URLweb.server.port → QK_WEB__SERVER__PORTauth.secret_key → QK_AUTH__SECRET_KEYThe prefix is stripped and the rest is lowercased; __ becomes nesting. List indexes are not special — QK_FOO__0__BAR becomes a dict key "0", not foo[0].
QK_WEB__SERVER__PORT=9000 quadkit run4. Configuration Profiles
Section titled “4. Configuration Profiles”Override base settings per environment with profile files. Activate a profile with QK_PROFILE:
QK_PROFILE=production quadkit run- Base:
application.yaml - Overlay:
application.{profile}.yaml(e.g.application.production.yaml)
5. Precedence Rules
Section titled “5. Precedence Rules”When resolving a key, QuadKit applies sources in this order (highest priority wins):
QK_environment variables —QK_WEB__SERVER__PORT=9000overrides everything- Profile YAML — values from
application.{profile}.yaml - Base YAML — values from
application.yaml - Code defaults — defined in each config model
6. Typed Sections and get_section()
Section titled “6. Typed Sections and get_section()”QuadKitConfig exposes typed top-level fields and resolves extension sections on demand:
config = QuadKitConfig.from_yaml()
# Typed top-levelconfig.app_name # "order-service"config.debug # Falseconfig.environment # Environment.PRODUCTION
# Extension sections — pass the config model to get a typed object backweb_config = config.get_section("web", WebConfig)
# Dotted pathscors = config.get("web.security.cors.allowed_origins")
# Existence checkconfig.has_section("web") # TrueProviders rarely call get_section() themselves — declaring config_key and config_model makes the framework inject the typed section automatically. See Configuration → auto-injection.
7. Profile Examples
Section titled “7. Profile Examples”debug: truelogging: level: DEBUG json_format: falseweb: server: port: 9000debug: falselogging: level: WARNING json_format: trueweb: server: port: "${PORT:8000}" security: cors: enabled: true allowed_origins: ["https://myapp.com"]Inspect the resolved tree (secrets masked):
quadkit config showquadkit config validatequadkit config doctor --env productionNext Steps
Section titled “Next Steps”- Configuration — the practical guide
- The quadkit CLI —
config show,config doctor,config env - Application Lifecycle — when config is loaded during boot
- Environment variables — generated
QK_*registry