Web Configuration File (YAML)
Relevant source files
The following files were used as context for generating this wiki page:
The Web Configuration File (YAML) is a core component of the flext-web platform, providing a structured and human-readable format for defining application behavior and environment settings. It integrates with the broader FLEXT hierarchical configuration system, which leverages Pydantic v2 models to ensure type safety, validation, and schema enforcement across the platform's modern web interfaces.
This configuration file allows developers to manage common settings such as logging levels, debug modes, and environment-specific parameters (e.g., host and port) while maintaining a clean separation between code and infrastructure-specific data. The system supports inheritance and overrides, ensuring that settings can be tailored for development, testing, or production environments.
Sources: guides/configuration.md:12-16, development.md:31-40, pyproject.toml:104-124
Configuration Architecture and Hierarchy
FLEXT employs a strict hierarchical loading order to resolve configuration values. The YAML configuration file sits as a middle-tier priority, allowing local file-based settings to override defaults but remain overridable by environment variables or programmatic calls.
The following diagram illustrates the priority flow of configuration sources within the flext-web ecosystem:
Sources: guides/configuration.md:18-24
Namespaced Settings
Configuration in flext-web is namespaced to prevent collisions between different modules (e.g., auth, api, ldif). The FlextWebSettings class acts as the primary validator and container for these namespaced values.
Sources: development.md:31-40, development/README.md:27-31
Key Configuration Components
The YAML configuration is structured into logical blocks representing different service layers of the platform.
Core Web Settings
The Web namespace specifically handles the infrastructure parameters for the web server, including the network interface and port.
| Option | Type | Default | Description |
|---|---|---|---|
host | str | localhost | The network interface the web server binds to. |
port | int | 8080 | The port number for the web service. |
log_level | str | INFO | The verbosity of system logs. |
debug | bool | false | Enables/disables debug mode and verbose error output. |
environment | str | production | Defines the execution context (e.g., development, production). |
Sources: development.md:31-40, guides/configuration.md:34-45, guides/configuration.md:112-120
Integration Namespaces
The configuration file can also contain settings for integrated FLEXT libraries, which are validated by their respective Pydantic models.
# Example YAML Structure
log_level: INFO
debug: false
environment: production
# Web Service Namespace
Web:
host: "127.0.0.1"
port: 8080
# API Service Namespace
api:
base_url: https://api.example.com
timeout: 30
retry_attempts: 3
# Auth Service Namespace
auth:
access_token_expire_minutes: 30
Sources: guides/configuration.md:47-65, development.md:34-37
Implementation and Validation
Pydantic Validation Logic
All values loaded from the YAML file are processed through Pydantic v2 models. This ensures that a port defined as a string in the YAML will be cast to an integer or raise a ValidationError if the format is invalid.
Environment Specific Overrides
The system encourages using separate YAML files or environment variables for different stages of the development lifecycle.
- Development: Typically uses
debug: trueandlog_level: DEBUG. - Production: Mandatory
debug: falseand strict validation enabled.
Sources: guides/configuration.md:95-120
Usage in Code
The following example demonstrates how the flext-web facade utilizes these configuration settings to initialize services.
from flext_web import web, FlextWebSettings
# Configuration is typically loaded automatically,
# but can be explicitly defined or overridden.
runtime_settings = FlextWebSettings(
Web={"host": "127.0.0.1", "port": 8080}
)
# Lifecycle operations utilize these settings
web.start_service(host="127.0.0.1", port=8080)
Sources: development.md:31-50, development/README.md:27-31
Troubleshooting Configuration Issues
Common issues related to the YAML configuration file and their diagnostic steps:
| Issue | Detection | Resolution |
|---|---|---|
| ModuleNotFoundError | Missing flext_core or flext_web | Verify PYTHONPATH=src or run make setup. |
| ValidationError | "field required" or type mismatch | Check YAML indentation and ensure types match Pydantic models. |
| File Not Found | Startup fails to find settings.yaml | Verify file path and read permissions. |
Sources: guides/troubleshooting.md:42-55, guides/troubleshooting.md:104-118
Conclusion
The Web Configuration File (YAML) provides a robust, typed interface for managing the behavior of flext-web applications. By adhering to the hierarchical configuration pattern and leveraging Pydantic validation, it ensures that web services remain stable, configurable, and secure across various deployment environments.
Sources: guides/configuration.md:213-220, development.md:55-60