UI: Application Settings
Relevant source files
The following files were used as context for generating this wiki page:
The Application Settings page provides a centralized user interface for configuring глобальные параметры of the PriceBuddy application. Built using the Filament admin panel, this page allows administrators to manage settings for web scraping, localization, logging, notifications, and third-party integrations without directly editing environment files. Most common application settings are exposed through this interface.
The settings are persisted using the filament/spatie-laravel-settings-plugin, which stores configuration values in a structured way. This allows for easy access and modification of system-wide behavior.
Sources: README.md, app/Filament/Pages/AppSettingsPage.php, composer.json
Architecture
The settings UI is primarily managed by two classes: AppSettingsPage and AppSettings.
AppSettingsPage: A FilamentSettingsPagethat defines the form structure, layout, and actions for the settings UI. It is responsible for rendering the form fields and handling the save operation.AppSettings: A class that extendsSpatie\LaravelSettings\Settings. It defines the properties (the settings themselves) and their data types.AppSettingsPageis linked to this class to automatically handle loading and saving of the settings.
The diagram below illustrates the relationship between the UI page and the settings data class.
Settings Form Structure
The settings form is built within the form() method of AppSettingsPage.php. It is organized into several logical sections, each handling a specific aspect of the application's configuration.
The following diagram shows the high-level structure of the settings form.
Scrape Settings
This section configures the behavior of the web scraping service.
| Field | Label | Description |
|---|---|---|
scrape_schedule_time | Fetch schedule time | The time of day to get product prices. |
scrape_cache_ttl | Scrape cache ttl | How many minutes the page HTML will be cached for after a scrape. |
sleep_seconds_between_scrape | Seconds to wait before fetching next page | Recommended to prevent being blocked by websites. |
max_attempts_to_scrape | Max scrape attempts | How many times to attempt to scrape a page before giving up. |
Sources: app/Filament/Pages/AppSettingsPage.php:43-73
Locale Settings
This section defines the default region and locale settings for the application, which are primarily used for extracting and displaying prices.
| Field | Label | Description |
|---|---|---|
default_locale_settings.locale | Locale | Primarily used when extracting and displaying prices. |
default_locale_settings.currency | Currency | Default currency for extracting and displaying prices. |
These fields are generated by the getLocaleFormFields() static method.
Sources: app/Filament/Pages/AppSettingsPage.php:75-80, 273-289
Logging Settings
This section controls the retention period for application logs.
| Field | Label | Description | Options |
|---|---|---|---|
log_retention_days | Log retention days | How many days to keep logs for. | 7, 14, 30, 90, 180, 365 days |
Sources: app/Filament/Pages/AppSettingsPage.php:82-98
Notification Services
This section configures various services for sending price change notifications. The settings for each service are grouped under the notification_services key in the AppSettings class. The FormHelperTrait is used to construct these sections.
A similar structure is used for user-specific notification settings in UserResource.
Sources: app/Filament/Pages/AppSettingsPage.php:102, 120-211, app/Filament/Resources/UserResource.php:61-66, app/Filament/Traits/FormHelperTrait.php
The diagram below shows the nested structure of notification settings.
Email (SMTP) Settings
| Field | Label | Description |
|---|---|---|
smtp_host | SMTP host | Host domain or IP address of the SMTP server. |
smtp_port | SMTP Port | The port of the SMTP server (default: '25'). |
smtp_user | SMTP Username | The optional username for the SMTP server. |
smtp_password | SMTP Password | The optional password for the SMTP server. |
from_address | From address | The email address to send emails from. |
encryption | Encryption | The encryption method to use (TLS or SSL). |
Sources: app/Filament/Pages/AppSettingsPage.php:137-172
Pushover Settings
| Field | Label | Description |
|---|---|---|
token | Pushover token | The application token. A link is provided to create one. |
Sources: app/Filament/Pages/AppSettingsPage.php:178-187
Gotify Settings
| Field | Label | Description |
|---|---|---|
url | Gotify server URL | The URL of the Gotify server. |
token | Application token | The application token, with a button to test the connection. |
Sources: app/Filament/Pages/AppSettingsPage.php:193-208
Apprise Settings
| Field | Label | Description |
|---|---|---|
url | Apprise API server URL | The URL of the Apprise API server. |
token | Configuration token | The configuration token, with a button to test the connection. |
Sources: app/Filament/Pages/AppSettingsPage.php:214-229
Integrations
This section is for configuring integrations with third-party services.
SearXng Settings
This configures the integration with a self-hosted SearXng instance to automatically find product URLs.
| Field | Label | Description |
|---|---|---|
url | SearXng url | URL of the SearXng instance, including the /search path. |
search_prefix | Search prefix | Text to prepend to the product name when searching. |
prune_days | Cache duration | How long to keep parsed search results in the cache. |
max_pages | How many pages of results to fetch | The number of result pages to fetch from SearXng. |
*Sources: app/Filament/Pages/AppSettingsPage.php:235-270_
Saving Settings
When the "Save" button is clicked, the save() method in AppSettingsPage is executed. This method first calls the parent save() method, which persists the form state to the AppSettings class. It then flushes both the application cache and the Once cache to ensure the new settings are applied immediately.
The following diagram illustrates the save process.
Conclusion
The Application Settings UI is a critical component for customizing a PriceBuddy instance. It leverages Filament's form-building capabilities and the spatie/laravel-settings package to provide a robust and user-friendly interface for managing a wide range of application parameters, from core scraping functionality to detailed notification and integration configurations. This centralized management simplifies administration and allows for dynamic adjustment of the application's behavior without code changes or server access.