This PR builds on the changes from PR #17430. The diff currently shows cumulative changes from both PRs. Once PR #17430 is merged, I will rebase this branch and the diff will show only the changes specific to this PR.
Part 2/4 of the config refactoring series.
Pull Request Checklist
Note to first-time contributors: Please open a discussion post in Discussions and describe your changes before submitting a pull request.
Before submitting, make sure you've checked the following:
Target branch: Please verify that the pull request targets the dev branch.
Description: Provide a concise description of the changes made in this pull request.
Changelog: Ensure a changelog entry following the format of Keep a Changelog is added at the bottom of the PR description.
Documentation: Have you updated relevant documentation Open WebUI Docs, or other documentation sources?
Dependencies: Are there any new dependencies? Have you updated the dependency versions in the documentation?
Testing: Have you written and run sufficient tests to validate the changes?
Code review: Have you performed a self-review of your code, addressing any coding standard issues and ensuring adherence to the project's coding standards?
Prefix: To clearly categorize this pull request, prefix the pull request title using one of the following:
BREAKING CHANGE: Significant changes that may affect compatibility
build: Changes that affect the build system or external dependencies
ci: Changes to our continuous integration processes or workflows
chore: Refactor, cleanup, or other non-functional code changes
docs: Documentation update or addition
feat: Introduces a new feature or enhancement to the codebase
fix: Bug fix or error correction
i18n: Internationalization or localization changes
perf: Performance improvement
refactor: Code restructuring for better maintainability, readability, or scalability
style: Changes that do not affect the meaning of the code (white space, formatting, missing semi-colons, etc.)
test: Adding missing tests or correcting existing tests
WIP: Work in progress, a temporary label for incomplete or ongoing work
Changelog Entry
Description
Extract database configuration, Redis management, and logging setup from config/legacy.py into dedicated modules. This is part 2 of 4 in the config.py refactoring series, continuing the modularization by separating core infrastructure concerns into logical modules.
Added
backend/open_webui/config/database.py:
Database configuration and connection management
run_migrations() function for Alembic migration handling
Config SQLAlchemy model for persistent configuration storage
Database initialization and setup logic
backend/open_webui/config/redis.py:
Redis connection management and configuration
Sentinel support for Redis high availability
Connection pooling and error handling
Redis client initialization functions
backend/open_webui/config/logging.py:
EndpointFilter class for filtering health check logs
Logging configuration and setup
Log level management and formatting
uvicorn access log filtering
backend/open_webui/config/base.py:
PersistentConfig class for environment-backed configuration
AppConfig class for application state management
Core configuration utilities and helpers
Configuration validation and type handling
Changed
Extracted database-related code from config/legacy.py to dedicated modules
Moved Redis connection logic to separate module for better organization
Separated logging configuration into its own module
Updated config/__init__.py imports to reference new modular structure
Converted import-time side effects to explicit initialization functions
Deprecated
None
Removed
Database configuration code from config/legacy.py (moved to database.py)
Redis connection logic from config/legacy.py (moved to redis.py)
Logging setup and filters from config/legacy.py (moved to logging.py)
Core configuration classes from config/legacy.py (moved to base.py)
Fixed
None
Security
None
Breaking Changes
No breaking changes - All existing functionality and import patterns continue to work unchanged
Additional Information
This is part 2 of 4 in a comprehensive config.py refactoring series
100% backward compatibility maintained - no existing code needs updates
See discussion: #17429 for the complete refactoring plan
This PR focuses on extracting core infrastructure (database, Redis, logging) into logical modules
Future PRs will extract feature-specific configurations and implement centralized bootstrap
Screenshots or Videos
[Attach any relevant screenshots or videos demonstrating the changes]
Contributor License Agreement
By submitting this pull request, I confirm that I have read and fully agree to the Contributor License Agreement (CLA), and I am providing my contributions under its terms.
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.
## 📋 Pull Request Information
**Original PR:** https://github.com/open-webui/open-webui/pull/17431
**Author:** [@luxass](https://github.com/luxass)
**Created:** 9/14/2025
**Status:** ❌ Closed
**Base:** `dev` ← **Head:** `refactor/extract-core-config`
---
### 📝 Commits (10+)
- [`5ee3521`](https://github.com/open-webui/open-webui/commit/5ee3521647152a91e29b4bd4c81bed221af29dea) refactor: move config.py into config/ package structure
- [`61ce6c4`](https://github.com/open-webui/open-webui/commit/61ce6c47045105ff9cb63e6e7b8368667c2eed2b) refactor(logging): move logging setup to a dedicated module
- [`c9639dd`](https://github.com/open-webui/open-webui/commit/c9639dd8bdd54de4c11345bb84d9f0618b1dda67) refactor(config): reorganize configuration modules and enhance structure
- [`d300bdf`](https://github.com/open-webui/open-webui/commit/d300bdf4bf1a2ac9b4d1bd2954e6d9d1e4d374e5) chore: format
- [`5efefcb`](https://github.com/open-webui/open-webui/commit/5efefcbad6452fa2d7e4cf44d61cd2ac25cbc3fc) Merge branch 'dev' into refactor/move-to-config-module
- [`8b67a4a`](https://github.com/open-webui/open-webui/commit/8b67a4aad31736e028ce4344c183c777c4d5a736) Merge branch 'dev' into refactor/move-to-config-module
- [`5d1ae32`](https://github.com/open-webui/open-webui/commit/5d1ae32ed9ac7bef76ca3d70c128f74ae3add1c1) chore: format
- [`56bfb79`](https://github.com/open-webui/open-webui/commit/56bfb794fac197ffccbedbd9078ba02eae9344d7) Merge branch 'refactor/move-to-config-module' into refactor/extract-core-config
- [`44a40c9`](https://github.com/open-webui/open-webui/commit/44a40c9fee5017dc6c85c47dfb2281f0a0d53b62) Merge branch 'dev' into refactor/move-to-config-module
- [`3ed1b5b`](https://github.com/open-webui/open-webui/commit/3ed1b5bf94596a2d36f9edafbe4088d3e7aab3f3) Merge branch 'refactor/move-to-config-module' into refactor/extract-core-config
### 📊 Changes
**6 files changed** (+323 additions, -282 deletions)
<details>
<summary>View changed files</summary>
➕ `backend/open_webui/config/__init__.py` (+23 -0)
➕ `backend/open_webui/config/base.py` (+171 -0)
➕ `backend/open_webui/config/database.py` (+79 -0)
📝 `backend/open_webui/config/legacy.py` (+30 -281)
➕ `backend/open_webui/config/logging.py` (+15 -0)
📝 `backend/open_webui/utils/oauth.py` (+5 -1)
</details>
### 📄 Description
**⚠️ DEPENDS ON PR #17430**
This PR builds on the changes from PR #17430. The diff currently shows cumulative changes from both PRs. Once PR #17430 is merged, I will rebase this branch and the diff will show only the changes specific to this PR.
**Part 2/4** of the config refactoring series.
# Pull Request Checklist
### Note to first-time contributors: Please open a discussion post in [Discussions](https://github.com/open-webui/open-webui/discussions) and describe your changes before submitting a pull request.
**Before submitting, make sure you've checked the following:**
- [x] **Target branch:** Please verify that the pull request targets the `dev` branch.
- [x] **Description:** Provide a concise description of the changes made in this pull request.
- [x] **Changelog:** Ensure a changelog entry following the format of [Keep a Changelog](https://keepachangelog.com/) is added at the bottom of the PR description.
- [x] **Documentation:** Have you updated relevant documentation [Open WebUI Docs](https://github.com/open-webui/docs), or other documentation sources?
- [x] **Dependencies:** Are there any new dependencies? Have you updated the dependency versions in the documentation?
- [x] **Testing:** Have you written and run sufficient tests to validate the changes?
- [x] **Code review:** Have you performed a self-review of your code, addressing any coding standard issues and ensuring adherence to the project's coding standards?
- [x] **Prefix:** To clearly categorize this pull request, prefix the pull request title using one of the following:
- **BREAKING CHANGE**: Significant changes that may affect compatibility
- **build**: Changes that affect the build system or external dependencies
- **ci**: Changes to our continuous integration processes or workflows
- **chore**: Refactor, cleanup, or other non-functional code changes
- **docs**: Documentation update or addition
- **feat**: Introduces a new feature or enhancement to the codebase
- **fix**: Bug fix or error correction
- **i18n**: Internationalization or localization changes
- **perf**: Performance improvement
- **refactor**: Code restructuring for better maintainability, readability, or scalability
- **style**: Changes that do not affect the meaning of the code (white space, formatting, missing semi-colons, etc.)
- **test**: Adding missing tests or correcting existing tests
- **WIP**: Work in progress, a temporary label for incomplete or ongoing work
# Changelog Entry
### Description
Extract database configuration, Redis management, and logging setup from `config/legacy.py` into dedicated modules. This is part 2 of 4 in the config.py refactoring series, continuing the modularization by separating core infrastructure concerns into logical modules.
### Added
- **`backend/open_webui/config/database.py`**:
- Database configuration and connection management
- `run_migrations()` function for Alembic migration handling
- `Config` SQLAlchemy model for persistent configuration storage
- Database initialization and setup logic
- **`backend/open_webui/config/redis.py`**:
- Redis connection management and configuration
- Sentinel support for Redis high availability
- Connection pooling and error handling
- Redis client initialization functions
- **`backend/open_webui/config/logging.py`**:
- `EndpointFilter` class for filtering health check logs
- Logging configuration and setup
- Log level management and formatting
- uvicorn access log filtering
- **`backend/open_webui/config/base.py`**:
- `PersistentConfig` class for environment-backed configuration
- `AppConfig` class for application state management
- Core configuration utilities and helpers
- Configuration validation and type handling
### Changed
- Extracted database-related code from `config/legacy.py` to dedicated modules
- Moved Redis connection logic to separate module for better organization
- Separated logging configuration into its own module
- Updated `config/__init__.py` imports to reference new modular structure
- Converted import-time side effects to explicit initialization functions
### Deprecated
- None
### Removed
- Database configuration code from `config/legacy.py` (moved to `database.py`)
- Redis connection logic from `config/legacy.py` (moved to `redis.py`)
- Logging setup and filters from `config/legacy.py` (moved to `logging.py`)
- Core configuration classes from `config/legacy.py` (moved to `base.py`)
### Fixed
- None
### Security
- None
### Breaking Changes
- **No breaking changes** - All existing functionality and import patterns continue to work unchanged
---
### Additional Information
- This is **part 2 of 4** in a comprehensive config.py refactoring series
- **100% backward compatibility maintained** - no existing code needs updates
- See discussion: #17429 for the complete refactoring plan
- This PR focuses on extracting core infrastructure (database, Redis, logging) into logical modules
- Future PRs will extract feature-specific configurations and implement centralized bootstrap
### Screenshots or Videos
- [Attach any relevant screenshots or videos demonstrating the changes]
### Contributor License Agreement
By submitting this pull request, I confirm that I have read and fully agree to the [Contributor License Agreement (CLA)](https://github.com/open-webui/open-webui/blob/main/CONTRIBUTOR_LICENSE_AGREEMENT), and I am providing my contributions under its terms.
---
<sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
📋 Pull Request Information
Original PR: https://github.com/open-webui/open-webui/pull/17431
Author: @luxass
Created: 9/14/2025
Status: ❌ Closed
Base:
dev← Head:refactor/extract-core-config📝 Commits (10+)
5ee3521refactor: move config.py into config/ package structure61ce6c4refactor(logging): move logging setup to a dedicated modulec9639ddrefactor(config): reorganize configuration modules and enhance structured300bdfchore: format5efefcbMerge branch 'dev' into refactor/move-to-config-module8b67a4aMerge branch 'dev' into refactor/move-to-config-module5d1ae32chore: format56bfb79Merge branch 'refactor/move-to-config-module' into refactor/extract-core-config44a40c9Merge branch 'dev' into refactor/move-to-config-module3ed1b5bMerge branch 'refactor/move-to-config-module' into refactor/extract-core-config📊 Changes
6 files changed (+323 additions, -282 deletions)
View changed files
➕
backend/open_webui/config/__init__.py(+23 -0)➕
backend/open_webui/config/base.py(+171 -0)➕
backend/open_webui/config/database.py(+79 -0)📝
backend/open_webui/config/legacy.py(+30 -281)➕
backend/open_webui/config/logging.py(+15 -0)📝
backend/open_webui/utils/oauth.py(+5 -1)📄 Description
⚠️ DEPENDS ON PR #17430
This PR builds on the changes from PR #17430. The diff currently shows cumulative changes from both PRs. Once PR #17430 is merged, I will rebase this branch and the diff will show only the changes specific to this PR.
Part 2/4 of the config refactoring series.
Pull Request Checklist
Note to first-time contributors: Please open a discussion post in Discussions and describe your changes before submitting a pull request.
Before submitting, make sure you've checked the following:
devbranch.Changelog Entry
Description
Extract database configuration, Redis management, and logging setup from
config/legacy.pyinto dedicated modules. This is part 2 of 4 in the config.py refactoring series, continuing the modularization by separating core infrastructure concerns into logical modules.Added
backend/open_webui/config/database.py:run_migrations()function for Alembic migration handlingConfigSQLAlchemy model for persistent configuration storagebackend/open_webui/config/redis.py:backend/open_webui/config/logging.py:EndpointFilterclass for filtering health check logsbackend/open_webui/config/base.py:PersistentConfigclass for environment-backed configurationAppConfigclass for application state managementChanged
config/legacy.pyto dedicated modulesconfig/__init__.pyimports to reference new modular structureDeprecated
Removed
config/legacy.py(moved todatabase.py)config/legacy.py(moved toredis.py)config/legacy.py(moved tologging.py)config/legacy.py(moved tobase.py)Fixed
Security
Breaking Changes
Additional Information
Screenshots or Videos
Contributor License Agreement
By submitting this pull request, I confirm that I have read and fully agree to the Contributor License Agreement (CLA), and I am providing my contributions under its terms.
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.