Skip to content

Pattern: user settings — one store, three surfaces #7

Description

@denkasyanov

Proposal to adopt a user-settings architecture as a stack pattern (proven in a downstream project; reference links kept internal).

The pattern:

  • One userSettings row per user, every field optional; no row until first write.
  • One read query applying defaults from a code-side DEFAULTS object — clients never null-check, defaults change without migration.
  • One write mutation settings.set({ setting: { key, value } }) with a per-key discriminated union: granular one-setting-per-call writes, value typed to its key, future side effects are a switch case not a sibling mutation.
  • UI: up to three surfaces over the one store — a /settings page that always shows everything, promoted shortcuts (avatar menu), inline controls at the point of effect. Promote by frequency-of-change × proximity-of-effect.
  • Scope: per-user cross-device preferences only; per-device state stays client-side.

Adding a setting = optional schema field + DEFAULTS entry + union member + a row on /settings.

Scope if accepted: add an ADR + a minimal settings module (one example setting) to the template.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions