βοΈ Settings System
LibreFolio uses a two-tiered settings system to manage configuration: Global Settings and User Settings.
π Global Settings
Global settings are system-wide configurations that apply to all users. They are managed by administrators and are read-only for regular users.
π― Purpose
- βοΈ To control core application behavior.
- π§ To configure default values for the entire system.
π§ Implementation
- ποΈ Global settings are stored in the
global_settingstable in the database. - π οΈ They are managed via the
user_cli.pyscript. - π The
settings_service.pyprovides functions to read these settings.
π Example Global Settings
- π° Default currency for the application.
- π Enabled/disabled status of external data providers.
π» Managing Global Settings
Global settings are initialized with default values using the CLI:
Future versions will allow administrators to modify these settings through an admin UI.
π€ User Settings
User settings are preferences specific to each individual user. Each user can modify their own settings.
π― Purpose
- π¨ To allow users to customize their experience.
- π To store user-specific preferences that override global defaults.
π§ Implementation
- ποΈ User settings are stored in the
user_settingstable, linked to auser_id. - π They are managed via the API (
/api/v1/settings). - π The
settings_service.pyprovides functions to get and set user-specific settings, with a fallback to the global setting if a user-specific one is not defined.
π Example User Settings
- π° The user's preferred display currency for their portfolio.
- π¨ Theme preference (light/dark mode).
- π Dashboard layout preferences.
π The Settings Service (settings_service.py)
This service acts as the central point for all settings-related operations. It abstracts the two-tiered system, providing a simple interface for the rest of the application.
When a setting is requested for a user, the service first checks if a UserSetting exists for that user. If not, it falls back to the corresponding GlobalSetting. This provides
a clean and flexible way to handle default values and user overrides.