Configuration
Overview
Section titled “Overview”Lexigram loads configuration from multiple sources with an overlay (later-wins) model. The ConfigProvider (priority CRITICAL) handles loading during the register() phase.
Config sources (in priority order, later wins):
- In-code field defaults
application.yamlin the working directory- Custom file sources (via
ConfigLoader) - Environment variables (
LEX_<KEY>) .envfile- CLI arguments (via
CliConfigSource)
Config Section Key
Section titled “Config Section Key”Lexigram’s config lives at the root of the config hierarchy (there is no outer section key). Extension packages use sub-keys under the root (e.g. cache:, web:, db:), which are accessed via config.get_section("cache", CacheConfig).
Options
Section titled “Options”LexigramConfig — Root Configuration
Section titled “LexigramConfig — Root Configuration”| Key | Type | Default | Description | Env Var |
|---|---|---|---|---|
app_name | str | "lexigram-app" | Application name used in logging and telemetry | LEX_APP_NAME |
debug | bool | False | Enable debug mode (blocked in production) | LEX_DEBUG |
env | Environment | "development" | Deployment environment | LEX_ENV |
logging.level | str | "INFO" | Default log level | LEX_LOGGING__LEVEL |
logging.format | str | "json" | Log output format | LEX_LOGGING__FORMAT |
modules | list[str] | [] | Enabled module names | LEX_MODULES |
discovery.auto_discover | bool | False | Auto-discover modules | LEX_DISCOVERY__AUTO_DISCOVER |
discovery.entry_point_group | str | "lexigram.modules" | Entry point group for module discovery | LEX_DISCOVERY__ENTRY_POINT_GROUP |
health.liveness_path | str | "/health/live" | Liveness check path (web) | LEX_HEALTH__LIVENESS_PATH |
health.readiness_path | str | "/health/ready" | Readiness check path (web) | LEX_HEALTH__READINESS_PATH |
Environment Values
Section titled “Environment Values”| Environment | String Value |
|---|---|
DEVELOPMENT | "development" |
STAGING | "staging" |
PRODUCTION | "production" |
TEST | "test" |
Examples
Section titled “Examples”Minimal YAML (application.yaml)
Section titled “Minimal YAML (application.yaml)”app_name: my-apidebug: falseenv: developmentlogging: level: INFO format: jsonProduction YAML
Section titled “Production YAML”app_name: my-apidebug: falseenv: productionlogging: level: WARN format: jsonEnvironment Variables
Section titled “Environment Variables”export LEX_APP_NAME="my-api"export LEX_DEBUG="false"export LEX_ENV="production"export LEX_LOGGING__LEVEL="WARN"Programmatic Usage
Section titled “Programmatic Usage”from lexigram import LexigramConfigfrom lexigram.config.di.provider import ConfigProvider
# Load from YAML + envconfig = LexigramConfig.from_yaml("application.yaml")print(config.app_name) # "my-api"print(config.is_production) # True/False
# Provider section accesscache_cfg = config.get_section("cache", CacheConfig)
# Validationissues = config.validate_for_environment()for issue in issues: print(f"{issue.field}: {issue.message}")
# ConfigProvider for DIprovider = ConfigProvider()Best Practices
Section titled “Best Practices”- Never hardcode secrets in YAML — use environment variables or a secret store
- Use
LEX_prefix for all env var overrides - Section naming uses double-underscore:
LEX_SECTION__KEY - Validate with
config.validate_for_environment()in production to catchdebug=True - Register secrets via
app.register_secrets()for boot-time validation - Pin config model types by registering them in
ConfigRegistryfor extension packages