Skip to content
GitHub

Configuration


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):

  1. In-code field defaults
  2. application.yaml in the working directory
  3. Custom file sources (via ConfigLoader)
  4. Environment variables (LEX_<KEY>)
  5. .env file
  6. CLI arguments (via CliConfigSource)

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).


KeyTypeDefaultDescriptionEnv Var
app_namestr"lexigram-app"Application name used in logging and telemetryLEX_APP_NAME
debugboolFalseEnable debug mode (blocked in production)LEX_DEBUG
envEnvironment"development"Deployment environmentLEX_ENV
logging.levelstr"INFO"Default log levelLEX_LOGGING__LEVEL
logging.formatstr"json"Log output formatLEX_LOGGING__FORMAT
moduleslist[str][]Enabled module namesLEX_MODULES
discovery.auto_discoverboolFalseAuto-discover modulesLEX_DISCOVERY__AUTO_DISCOVER
discovery.entry_point_groupstr"lexigram.modules"Entry point group for module discoveryLEX_DISCOVERY__ENTRY_POINT_GROUP
health.liveness_pathstr"/health/live"Liveness check path (web)LEX_HEALTH__LIVENESS_PATH
health.readiness_pathstr"/health/ready"Readiness check path (web)LEX_HEALTH__READINESS_PATH
EnvironmentString Value
DEVELOPMENT"development"
STAGING"staging"
PRODUCTION"production"
TEST"test"

app_name: my-api
debug: false
env: development
logging:
level: INFO
format: json
app_name: my-api
debug: false
env: production
logging:
level: WARN
format: json
Terminal window
export LEX_APP_NAME="my-api"
export LEX_DEBUG="false"
export LEX_ENV="production"
export LEX_LOGGING__LEVEL="WARN"

from lexigram import LexigramConfig
from lexigram.config.di.provider import ConfigProvider
# Load from YAML + env
config = LexigramConfig.from_yaml("application.yaml")
print(config.app_name) # "my-api"
print(config.is_production) # True/False
# Provider section access
cache_cfg = config.get_section("cache", CacheConfig)
# Validation
issues = config.validate_for_environment()
for issue in issues:
print(f"{issue.field}: {issue.message}")
# ConfigProvider for DI
provider = ConfigProvider()

  • 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 catch debug=True
  • Register secrets via app.register_secrets() for boot-time validation
  • Pin config model types by registering them in ConfigRegistry for extension packages