Skip to content

Cross-ruleset compendium browser: dedupe SRD entries with source selector #27

Description

@barrulus

Background

The SRD database holds the same entity (e.g. "fireball", "fighter", "longsword") once per loaded ruleset, by design. Currently three sources are loaded:

Source Spells
`srd-2014` 319
`srd-2024` 338
`a5e-ag` (Level Up Advanced 5e) 371

Same pattern applies to species, classes, backgrounds, feats, items, weapons, and armor — see `database/srd-schema-multi-source.sql`, which deliberately replaced `UNIQUE(key)` with `UNIQUE(key, document_source)`.

Current state (after #26 fix)

The list endpoints in `server/routes/srd.routes.js` (`/spells`, `/species`, `/classes`, `/backgrounds`, `/feats`, `/items`) now default to `?source=srd-2024` when no source is given, and support `?source=all` to opt into a cross-ruleset view.

This fixes the immediate duplication symptom in the compendium UI but is not the right long-term answer:

  • A player whose character is built against `srd-2014` or `a5e-ag` sees the wrong spell list.
  • There is no way in the UI to compare versions of the same spell side-by-side (useful for DMs reconciling rulesets).
  • Cross-ruleset browsing requires manually appending `?source=all`, which then re-introduces the duplication.

Proposal

Build a proper cross-ruleset compendium browser:

  1. Backend: add a `/api/srd/spells/grouped` (and equivalents) that returns one row per `key`, with an array of available sources and per-source field deltas. Order sources by preference (`srd-2024 → srd-2014 → a5e-ag → other`), and surface a default "primary" version.

  2. Frontend: render one card per spell with:

    • A source selector chip (`2024` / `2014` / `A5e`) showing which rulesets define this spell
    • The currently-selected version's text
    • A "compare versions" affordance if multiple sources differ
  3. Character context: when the user is viewing the compendium from a character sheet, default the source selector to that character's `srd_document_source`.

  4. Search/filter: ensure filters (level, school, class, ritual, etc.) operate on the union across sources, not on a single source.

Out of scope (for this issue)

  • Loading additional rulesets beyond what's already imported.
  • Letting players "pin" a preferred ruleset per campaign — that's a separate config concern.

Related

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions