- Add comprehensive Settings Management Guide - Add implementation summary document - Verify all functionality with integration tests - Document API usage, security, and troubleshooting - Clean up test artifacts Co-authored-by: christianlouis <361235+christianlouis@users.noreply.github.com>
6.8 KiB
Settings Management Guide
Overview
DocuElevate now supports managing application settings through a web-based GUI. Settings can be configured, saved to the database, and will persist across application restarts with the following precedence:
Database > Environment Variables > Defaults
Accessing the Settings Page
- Navigate to
/settingsin your web browser - Admin access required - Only users with admin privileges can access this page
- For local authentication: Use the admin username/password configured in environment variables
- For OAuth/SSO: Users must be in the "admin" or "administrators" group
Features
Settings Organization
Settings are organized into logical categories for easy navigation:
- Core: Database, Redis, working directory, external hostname, debug mode
- Authentication: Login settings, session secrets, OAuth configuration
- AI Services: OpenAI and Azure AI configuration
- Storage Providers: Dropbox, Google Drive, OneDrive, S3, FTP, SFTP, WebDAV, Nextcloud, Paperless
- Email: SMTP configuration for sending emails
- IMAP: Email ingestion configuration (supports multiple accounts)
- Monitoring: Uptime Kuma integration
- Notifications: Apprise notification URLs and settings
- Processing: Batch processing and HTTP timeout settings
- Feature Flags: Enable/disable specific features
Setting Types
- String: Text values (API keys, URLs, paths)
- Boolean: True/false toggles (enable/disable features)
- Integer: Numeric values (ports, timeouts, thresholds)
- List: Comma-separated values (notification URLs)
Sensitive Data
Settings marked as sensitive (passwords, API keys, tokens) are:
- Masked in the UI by default (show ****key)
- Can be revealed temporarily using the eye icon
- Encrypted in session storage
- Never logged in plain text
Restart Requirements
Settings are marked with 🔄 or a red asterisk (*) if they require an application restart to take effect. This includes:
- Database and Redis URLs
- Working directory
- Authentication settings
- Debug mode
Most runtime settings (API keys, storage credentials) can be changed without restarting.
Using the Settings Page
Viewing Settings
- Navigate to
/settings - Browse categories using the expandable sections
- Each setting shows:
- Name: The setting key
- Description: What the setting does
- Current Value: The active value (masked if sensitive)
- Type: String, boolean, integer, or list
- Required: Whether the setting must be configured
- Restart Required: Whether changing this setting requires a restart
Updating Settings
- Modify the desired settings in the form
- Click "Save Settings" at the bottom of the page
- Settings are validated before saving
- Success/error messages are displayed
- If any changed setting requires a restart, you'll be notified
Bulk Updates
The settings page supports updating multiple settings at once:
- Change as many settings as needed
- Click "Save Settings" once
- All valid changes are applied atomically
- Any validation errors are reported individually
Resetting Changes
Click "Reset" to discard unsaved changes and return to the current values.
API Endpoints
Settings can also be managed programmatically (admin auth required):
Get All Settings
GET /api/settings/
Returns all settings with their metadata and current values.
Get Specific Setting
GET /api/settings/{key}
Returns a single setting's value and metadata.
Update Setting
POST /api/settings/{key}
{
"key": "debug",
"value": "true"
}
Updates a single setting. Returns whether a restart is required.
Delete Setting
DELETE /api/settings/{key}
Removes a setting from the database (reverts to environment variable or default).
Bulk Update
POST /api/settings/bulk-update
[
{"key": "debug", "value": "true"},
{"key": "openai_model", "value": "gpt-4"}
]
Updates multiple settings in one request.
Settings Precedence
DocuElevate loads settings in this order (later sources override earlier ones):
- Defaults: Hard-coded defaults in
app/config.py - Environment Variables: From
.envfile or system environment - Database: Settings saved through the UI or API
Example
If you have:
- Default:
debug = false - Environment:
DEBUG=truein.env - Database:
debug = false(saved via UI)
The application will use debug = false (database wins).
Database Storage
Settings are stored in the application_settings table with:
key: Unique setting identifiervalue: Setting value (stored as string, converted on load)created_at: When the setting was first savedupdated_at: When the setting was last modified
Security Considerations
- Admin Access Only: Settings page requires admin privileges
- Sensitive Data Masking: Passwords and keys are masked in the UI
- Input Validation: All setting values are validated before saving
- Audit Trail: Database tracks when settings were created/updated
- Session Security: Admin sessions require strong session secrets (min 32 chars)
Troubleshooting
Can't Access Settings Page
- Check authentication: Make sure you're logged in
- Check admin status:
- Local auth: Verify
ADMIN_USERNAMEandADMIN_PASSWORDare correct - OAuth: Verify your user is in the admin group
- Local auth: Verify
- Check logs: Look for "Non-admin user attempted to access settings page" messages
Settings Not Taking Effect
- Check restart requirement: Some settings require app restart
- Check precedence: Database settings override environment variables
- Check validation: Invalid values may not be saved (check error messages)
- Check logs: Application startup logs show which settings were loaded from database
Settings Not Persisting
- Check database: Verify
DATABASE_URLis configured correctly - Check permissions: Ensure application can write to database
- Check errors: Look for SQLAlchemy errors in logs
Development
Adding New Settings
- Add the setting to
app/config.pyin theSettingsclass - Add metadata to
SETTING_METADATAinapp/utils/settings_service.py - Include:
category: Logical groupingdescription: Clear explanationtype: string, boolean, integer, or listsensitive: True for secrets/passwordsrequired: True if the setting must be configuredrestart_required: True if app restart needed
Testing
Run the settings tests:
pytest tests/test_settings.py -v
Or run integration tests:
python3 test_integration.py
Related Documentation
- Configuration Guide - Environment variable reference
- Deployment Guide - Production deployment
- API Documentation - Full API reference