2424
2525from dataclasses import dataclass , field
2626from pathlib import Path
27- from typing import Optional
2827
2928from varlord import Config , sources
3029from varlord .global_config import get_global_config , set_global_config
3130
32-
3331# ============================================================================
3432# Configuration Models (config/models.py)
3533# ============================================================================
3634
35+
3736@dataclass (frozen = True )
3837class DatabaseConfig :
3938 """Database configuration."""
@@ -68,6 +67,7 @@ class AppConfig:
6867# Configuration Setup (config/setup.py)
6968# ============================================================================
7069
70+
7171def setup_config () -> Config :
7272 """Initialize and register application configuration.
7373
@@ -113,6 +113,7 @@ def get_config():
113113# Business Code (src/services/database.py)
114114# ============================================================================
115115
116+
116117def get_db_connection ():
117118 """Get database connection using global configuration."""
118119 config = get_global_config (name = "app" )
@@ -134,13 +135,14 @@ def get_db_connection():
134135# Application Entry Point (src/main.py)
135136# ============================================================================
136137
138+
137139def main ():
138140 """Main application entry point."""
139141 import sys
140142
141143 # Step 1: Initialize configuration (once at startup)
142144 try :
143- cfg = setup_config ()
145+ setup_config ()
144146 app_config = get_config ()
145147 except Exception as e :
146148 print (f"❌ Failed to load configuration: { e } " )
@@ -168,4 +170,3 @@ def main():
168170
169171if __name__ == "__main__" :
170172 main ()
171-
0 commit comments