Skip to content

refactor(backend): modularize oversized config module into app/config#400

Open
SaitejaKommi wants to merge 1 commit intoopenfoodfacts:mainfrom
SaitejaKommi:refactor/config-module
Open

refactor(backend): modularize oversized config module into app/config#400
SaitejaKommi wants to merge 1 commit intoopenfoodfacts:mainfrom
SaitejaKommi:refactor/config-module

Conversation

@SaitejaKommi
Copy link
Copy Markdown

Summary

This PR reduces the high cognitive load of the monolithic app/config.py module by refactoring it into a structured app/config package 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:

  • Core Settings
  • LoggingLevel
  • SettingsGenerateJsonSchema
  • Standard environment variable overrides

Extracted Configuration Models

Created models.py, containing a focused catalog of schema models such as:

  • TaxonomyConfig
  • FieldConfig
  • IndexConfig
  • Root Config

This makes configuration schemas easier to browse and extend.

Extracted Loading / State Logic

Created loader.py, responsible for:

  • Global _CONFIG state
  • get_config()
  • YAML parsing and config loading utilities

Preserved Public API Surface

Added __init__.py to re-export components and maintain compatibility for existing imports used by indexing, API, and dependent modules.


Affected Files

  • app/config.py → replaced by package structure
  • app/config/__init__.py
  • app/config/settings.py
  • app/config/models.py
  • app/config/loader.py

Testing

Verification gateway executed successfully:

  • Backend unit tests ✅
  • Backend integration tests ✅
  • Frontend build/tests (dev) ✅
  • Frontend build/tests (prod) ✅

Notes

This is a backend structural refactor focused on maintainability and cleaner modular boundaries with no intended runtime or API behavior changes.

… 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.
@github-project-automation github-project-automation Bot moved this to Backlog (ready for dev) in 🔎 Search-a-licious Apr 23, 2026
@SaitejaKommi SaitejaKommi changed the title refactor(backend): modularize oversized config module into app/config… refactor(backend): modularize oversized config module into app/config Apr 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Backlog (ready for dev)

Development

Successfully merging this pull request may close these issues.

Refactor: Oversized configuration module has high cognitive load

1 participant