refactor(backend): modularize oversized config module into app/config#400
Open
SaitejaKommi wants to merge 1 commit intoopenfoodfacts:mainfrom
Open
refactor(backend): modularize oversized config module into app/config#400SaitejaKommi wants to merge 1 commit intoopenfoodfacts:mainfrom
SaitejaKommi wants to merge 1 commit intoopenfoodfacts:mainfrom
Conversation
… package Decoupled the monolithic app/config.py to reduce cognitive load: - app/config/settings.py: Contains application settings and environment variables - app/config/models.py: Contains all Pydantic configuration models - app/config/loader.py: Handles reading YAML configuration and managing global state - app/config/__init__.py: Exposes everything to preserve backwards compatibility Verified with passing unit tests.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR reduces the high cognitive load of the monolithic
app/config.pymodule by refactoring it into a structuredapp/configpackage with clearly separated responsibilities.The new layout improves readability, maintainability, and contributor onboarding while preserving backward compatibility for existing imports.
Related Issue
Fixes #399
What Changed
Extracted Environment Settings
Created
settings.py, responsible for:SettingsLoggingLevelSettingsGenerateJsonSchemaExtracted Configuration Models
Created
models.py, containing a focused catalog of schema models such as:TaxonomyConfigFieldConfigIndexConfigConfigThis makes configuration schemas easier to browse and extend.
Extracted Loading / State Logic
Created
loader.py, responsible for:_CONFIGstateget_config()Preserved Public API Surface
Added
__init__.pyto re-export components and maintain compatibility for existing imports used by indexing, API, and dependent modules.Affected Files
app/config.py→ replaced by package structureapp/config/__init__.pyapp/config/settings.pyapp/config/models.pyapp/config/loader.pyTesting
Verification gateway executed successfully:
Notes
This is a backend structural refactor focused on maintainability and cleaner modular boundaries with no intended runtime or API behavior changes.