Dhātu explorer and data
The /root route family presents a browseable index of verbal roots and a detail view for each root. It uses prebuilt root artifacts so a page can load one compact JSON document rather than join dictionaries, lexical links, and occurrences in the browser.
Source inputs and canonical bundles
scripts/build-bundles.js reads the synaptic helper data under $FRACTALDHARMA_RAW_DIR/00helpers/synaptic and writes canonical bundles under static/data.
| Source input | Canonical output | Role |
|---|---|---|
dhatus.json | dhatus.json | Base root identifier, IAST, Devanāgarī, gaṇa, and meaning |
dhatus-complete.json | enriched fields in dhatus.json | Pada, English/Hindi meanings, notes, tags, and upasargas where available |
word-index.json | lemmas.json, dhatu-lemma.json | Lemma records and broad root–lemma associations |
dhatu-word-links.json | dhatu-word-enriched.json | Curated/enriched root–word links, previews, dictionaries, and link basis |
dictionary-entries.json | dictionary.json | Dictionary definitions for lemma and root-detail previews |
db-ashtadhyayi.json | sutras.json and root metadata | Sūtra data used by graph and future root projections |
The bundle builder normalizes the root schema deliberately. ganaName is the gaṇa label; pada is only a pada value such as P, A, or U. Do not use a gaṇa name as a fallback for pada. The generic Aṣṭādhyāyī definition 1.3.1 is excluded from root-specific related-sūtra data because it does not distinguish one root from another.
Runtime artifacts
scripts/build-query-artifacts.mjs calls buildRootDetails and writes:
static-runtime/data/generated/v1/
├── roots/index.json
└── roots/{root-slug}.json roots/index.json is the catalogue projection: slug, IAST and Devanāgarī forms, gaṇa, pada, meaning, and word count. /root/+page.ts fetches this once, while /root/[slug]/+page.ts fetches only roots/{slug}.json.
Each root-detail artifact contains:
- the normalized
DhatuRecord; - immediate previous and next roots in source order;
- grouped linked words with dictionary definitions and text counts;
- any retained root-specific sūtra records;
- an overall linked-word count.
Keep new root-page requirements within this bounded projection. If a detail needs another field, add it during artifact construction and document its type in src/lib/data/types.ts rather than making the page scan an unbounded corpus file.
Root–word links and conflict resolution
Two link sources have different purposes:
dhatu-word-enriched.jsonis preferred for displaying a root’s word family because it contains curated link metadata.dhatu-lemma.jsonprovides broader fallback coverage from a lemma’sdhatuSlugslist.
The same lemma can have several candidate root links. The lemma-detail build ranks an enriched association whose basis says the headword begins with a root above a relation inferred only from a dictionary citation; only then does it fall back to the broad bridge. This prevents a dictionary text mentioning another root from replacing the intended root in the lemma sidebar.
Do not interpret every association as an exhaustive historical etymology. Preserve the link basis in data when available, avoid hiding ambiguity by arbitrary client-side choices, and add a better source rule when a systematic error is discovered.
Family grouping
classifyRootWord in scripts/lib/build-query-artifacts.mjs groups display words as Root, Guṇa, Vṛddhi, or Other. It normalizes IAST, tests the initial root stem, then tests initial guṇa and vṛddhi grade forms. The grouping intentionally stays heuristic and presentational:
- it is deterministic and cheap to compute during the build;
- it never claims a derivation merely because a word was placed in a group;
- words without a clear initial pattern remain visible in
Other.
When improving the classifier, add focused tests in tests/*.test.mjs for the changed sound pattern and retain the safe fallback.
Route interaction and sidebar state
/root/[slug]/+page.svelte sends a selected word to nav.setActiveWord together with rootContext: dhatu. context-lens.svelte can therefore show the full lemma entry in the shared right sidebar while retaining the root page’s authoritative context. The root page owns the selection styling; the layout clears the active word when navigation leaves the root or text scope.
Avoid restoring the former inline word-definition expansion on root pages. The sidebar is the single detailed-word surface, which keeps the root family visible while the user investigates a lemma.
Rebuild and verification
After changing raw root data or root-link logic, run:
node scripts/build-bundles.js
pnpm data:build
pnpm test:data Inspect a root with a known gaṇa/pada, a root with upasargas, a root with all four word groups, and an ambiguous lemma association. Confirm that the browser route fetches roots/index.json or a single root detail artifact—not canonical data from static/data.