Translation CMS: this folder also contains a static web app (
web/) and tooling (scripts/) for community translations.topics.dbstays the source of truth. See CONTRIBUTING.md.
Reference notes for topics.db and how QuranApp consumes it in Compose.
DB path: see db_path.txt → app/src/main/assets/db/topics.db
App entry: ActivityQuranicTopics → QuranicTopicsScreen
A packaged SQLite ontology of Quranic topics: entities (people, places, concepts, …), three hierarchy lenses, soft “related” links, and verse membership. The Android app exposes two browse modes — Ontology Explorer and Thematic Topics — plus search.
| Table | Role | Approx. size |
|---|---|---|
topics |
Node identity (slug, type, flags, optional image) |
~2.5k |
topic_localizations |
Titles/descriptions (en all, ar subset) |
~3.5k |
relationships |
Typed edges src (child) → tgt (parent) |
~1.7k |
topic_ayahs |
Topic ↔ verse (ayah_id = surah*1000 + ayah) |
~31k |
Bitmask on topics.flags (TopicFlags):
| Value | Meaning |
|---|---|
0 |
Neither curated tree (hidden / catalog-only) |
1 |
Thematic |
2 |
Ontology |
3 |
Both |
Primary roots for each UI tree are topics with the matching flag that have no parent of that tree’s relationship type.
Convention: src_topic_id = child, tgt_topic_id = parent (except related, which is bidirectional in queries).
| DB type | App use |
|---|---|
ontology_parent |
Entity “is-a” tree (Ontology Explorer) |
thematic_parent |
Curated thematic browse tree |
parent |
Broader keyword/index graph — used to attach supplemental topics not in the two curated trees |
related |
Soft associations (“Connected Concepts” on detail) |
parent and thematic_parent child sets are largely disjoint. ontology_parent is a smaller typed taxonomy (e.g. Human → Historic People → Quraysh).
Entity kinds stored as free text, e.g.:
concept · category · object · place · animal · prophet · person · body_part · event · plant · angel · religion · scripture · jinn
Most rows are concept or category.
ActivityQuranicTopics
└─ QuranicTopicsScreen (NavHost)
├─ TopicsListScreen roots + paged supplemental
├─ TopicsDetailScreen hero, verses, children, related
└─ QuranicTopicsSearchScreen
│
QuranicTopicsViewModel
│
TopicsRepository ← TopicsDao (Room) ← assets/db/topics.db
| File | Role |
|---|---|
QuranicTopicsScreen.kt |
Nested nav: ontology / thematic / topic detail / search |
TopicsListScreen.kt |
Root list; primary roots then “broader catalog”; infinite scroll for supplemental pages |
TopicsDetailScreen.kt |
Hero, verse previews, subtopics, broader children, connected concepts; breadcrumb trail in route |
QuranicTopicsSearchScreen.kt |
Debounced search; opens detail with inferred tree + breadcrumb path |
UI pieces live under compose/components/quranic_topics/ (Hero, TopicCards, TopicCommon, …).
| Piece | Role |
|---|---|
TopicsDatabase |
Room DB, createFromAsset("db/topics.db") |
TopicsDao |
Roots, children, verses, related, hierarchy edges, search candidates |
TopicsRepository |
Language (en only for now), supplemental assignment, search scoring/paths, verse previews via translation factory |
QuranicTopicsViewModel |
Roots + detail cache (capped), maps rows → TopicNode |
Many topics have flags = 0 and sit only on the parent graph. The repository:
- Walks curated visible ontology/thematic trees (flagged roots + their
*_parentdescendants). - Treats remaining topics as hidden.
- Unions them via
parentedges (disjoint-set); assigns each component to ontology or thematic by which curated tree it touches (default thematic if ambiguous). - Surfaces orphan supplemental roots under “More topics from broader catalog”, paged (40 at a time).
Detail screens show primary children for the active tree, then optional broader-catalog children from that assignment.
- SQL
LIKEover title / short / description → candidates. - Best ancestor trail over
parent+ontology_parent+thematic_parent(prefer ontology, then thematic). - Score by title match quality, path, verse count.
- Prefer hits whose path matches the current tree; otherwise fall back to all hits.
- Home verse collections → Ontology or Thematic (
HomeSectionVersesCollections) - Global exclusive search → deep-link with
topic_id+topic_trail(ExclusiveSearchResults) - Intent extras:
screen_type,topic_id,topic_trail
- Hero — title, breadcrumbs, image, counts
- Explore — shortcuts when verses / subtopics / related exist
- Verse refs — all ayah refs + a few translation previews
- Go Deeper / Subtopics — tree children
- More from broader catalog — supplemental children
- Connected Concepts —
relatededges
Empty leaf titles that look like “see X” redirects may navigate to a matching topic by normalized title (resolveChildTopicNavigationTarget).
app/src/main/assets/db/topics.db
app/.../activities/reference/ActivityQuranicTopics.kt
app/.../compose/screens/quranictopics/
app/.../compose/components/quranic_topics/
app/.../viewModels/QuranicTopicsViewModel.kt
app/.../repository/TopicsRepository.kt
app/.../db/TopicsDatabase.kt
app/.../db/dao/TopicsDao.kt
app/.../db/entities/topics/
app/.../db/DatabaseProvider.kt # getTopicsRepository / createFromAsset
- Ontology tree = typed entity taxonomy (
ontology_parent+ flag bit 2). - Thematic tree = curated browse themes (
thematic_parent+ flag bit 1). - Parent graph = glue for the rest of the catalog into those two explorers.
- Related = lateral links, not hierarchy.
- topic_ayahs = what the reader opens when exploring a topic’s verses.