configuration PK: id 12 required 3 unique

Description

User-specific and organization-level configuration preferences including notification toggles, language, accessibility options, and calendar sync preferences. Stored dually — locally for performance and remotely for cross-device consistency. One record per user for personal settings.

16
Attributes
3
Indexes
8
Validation Rules
18
CRUD Operations

Data Structure

Name Type Description Constraints
id uuid Surrogate primary key for the settings record
PKrequiredunique
user_id uuid Foreign key reference to the owning user. Enforces the one-to-one relationship; each user has exactly one settings row.
requiredunique
notification_enabled boolean Master toggle for all push notification delivery. When false, no FCM messages are dispatched to the user's devices regardless of individual reminder settings.
required
language string BCP 47 language tag controlling the app UI locale. Defaults to 'nb' (Norwegian Bokmål). Supported values include 'nb', 'nn', 'en', 'se' (Sami, planned).
required
font_scale decimal Text scaling multiplier applied on top of the system font size. Range 0.8–2.0. Supports WCAG 2.2 AA requirement for text resizable up to 200% without loss of content.
required
high_contrast_enabled boolean When true, the app switches to a high-contrast color palette with elevated contrast ratios beyond the standard 4.5:1 AA minimum. Supports users with low vision.
required
reduce_motion_enabled boolean When true, all animations (Rive, Lottie, counter animations in annual summary) are replaced with static fallbacks. Mirrors the OS-level reduce-motion preference but allows in-app override.
required
calendar_sync_enabled boolean Controls whether the user's activities, events, and reminders are exported via the iCal feed and written to the device native calendar. When false, Calendar API Infrastructure returns 403 for this user's feed.
required
calendar_event_filters json Array of event type strings the user wants included in the calendar sync. Valid values: 'activities', 'events', 'reminders'. Null means all types are included. Example: ["activities", "events"].
-
calendar_ical_token string Cryptographically random bearer token (min 32 bytes, URL-safe base64) that secures the per-user iCal feed endpoint GET /api/v1/users/{id}/calendar.ics. Null until the user enables calendar sync for the first time.
unique
reminder_preferences json Map of scenario-type keys to user-level toggle states and threshold overrides. Example: {"10_day_no_contact": {"enabled": true}, "certification_expiry": {"enabled": true, "lead_days": 30}}. Stored as JSONB for flexible schema evolution.
-
biometric_auth_enabled boolean Whether the user has opted into biometric authentication (Face ID / fingerprint) for session resumption. True only if the device supports and has biometric hardware enrolled. Affects Biometric Auth Service prompt behavior on app launch.
required
default_activity_duration_minutes integer Configurable default duration (in minutes) pre-filled in the activity registration wizard. Defaults to 30 per the organization-wide default. User can override for personal workflow efficiency.
required
created_at datetime Timestamp when the settings record was first created, typically on first login or onboarding completion.
required
updated_at datetime Timestamp of the most recent settings update. Used by the sync system to detect stale local copies and trigger re-fetch on other devices.
required
synced_at datetime Timestamp of the last successful remote synchronization of this settings record to the server. Null on the local record before first upload. Used to detect divergence between local and remote copies.
-

Database Indexes

idx_setting_user_id
btree unique

Columns: user_id

idx_setting_calendar_ical_token
btree unique

Columns: calendar_ical_token

idx_setting_updated_at
btree

Columns: updated_at

Validation Rules

language_valid_bcp47 error

Validation failed

language_valid_bcp47_on_update error

Validation failed

font_scale_within_bounds error

Validation failed

font_scale_within_bounds_on_update error

Validation failed

calendar_event_filters_valid_values warning

Validation failed

ical_token_uniqueness error

Validation failed

reminder_preferences_schema warning

Validation failed

user_id_references_existing_user error

Validation failed

Business Rules

one_settings_per_user
on_create

Each user must have exactly one settings row. The unique constraint on user_id at the database level prevents duplicate records. Settings are created automatically on first login if absent.

dual_storage_sync
on_update

Every write to the remote settings row must also be reflected in the local SQLite settings copy (via Local Database Infrastructure / drift). On app launch, if remote updated_at > local synced_at, the local record is overwritten with the remote version to ensure cross-device consistency.

ical_token_generation_on_sync_enable
on_update

When calendar_sync_enabled transitions from false to true and calendar_ical_token is null, the system automatically generates a cryptographically random token and persists it. The token is never regenerated unless the user explicitly resets the calendar feed.

notification_master_toggle_cascade
always

When notification_enabled is set to false, Push Notification Service must not dispatch any FCM messages to the user regardless of individual reminder_preferences values. The master toggle acts as a hard gate at the dispatch layer.

auto_create_on_first_login
on_create

If no settings record exists for a newly authenticated user, Settings Service creates one with all default values before returning the dashboard. This ensures downstream components always find a settings row and never receive null.

biometric_flag_requires_device_support
on_update

biometric_auth_enabled may only be set to true by the client after Biometric Auth Service confirms isBiometricAvailable() and isBiometricEnrolled() both return true. The server does not validate device capability but trusts the client flag.

default_activity_duration_org_floor
on_update

default_activity_duration_minutes must be at least 1 minute. Organizations may configure a recommended default (typically 30 minutes) surfaced by Default Values Provider, but users can set any value within the valid range.

Storage Configuration

Storage Type
primary_table
Location
main_db
Partitioning
No Partitioning
Retention
Permanent Storage

Entity Relationships

user
incoming one_to_one

A user has exactly one settings record containing all their personal preferences

required cascade delete