# malik-712/sanad architecture

> Architecture diagram of the GitHub repository malik-712/sanad, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-18). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/malik-712/sanad
- Repository: https://github.com/malik-712/sanad

## Overview

Sanad is a browser-based isnād parser and hadith explorer, with separate pages for curated hadiths, narrator records, and source notes. The principal workflow is pasted isnād → model or rule-based reading → narrator-name linking → corpus matching and ranking → shared-chain graph and results. The README documents the corpus, privacy behavior, and curated-data capabilities; source-level edges are limited to relationships visible in the excerpts or SOURCE INDEX.

Main entry points: [`components/explorer/ExplorerResults.tsx`](https://github.com/malik-712/sanad/blob/main/components/explorer/ExplorerResults.tsx) (Explorer results), [`components/parse/ParseApp.tsx`](https://github.com/malik-712/sanad/blob/main/components/parse/ParseApp.tsx) (Parse interface), [`lib/ml/client.ts`](https://github.com/malik-712/sanad/blob/main/lib/ml/client.ts) (Reader coordinator), [`app/hadith/[id]/page.tsx`](https://github.com/malik-712/sanad/blob/main/app/hadith/%5Bid%5D/page.tsx) (Hadith page)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_experience["User experience"]
  node_home["Explorer page<br/>[page.tsx]"]
end

subgraph group_reading["Isnād reading"]
  node_parse["Parse interface<br/>[ParseApp.tsx]"]
  node_reader["Reader coordinator<br/>[client.ts]"]
  node_worker["Model worker<br/>[worker.ts]"]
  node_rules["Rule parser<br/>[ruleParser.ts]"]
  node_linker["Narrator linker<br/>[linker.ts]"]
end

subgraph group_discovery["Corpus discovery"]
  node_results["Explorer results"]
  node_corpus["Corpus access<br/>[corpus.ts]"]
  node_tree["Interactive tree<br/>[IsnadTree.tsx]"]
end

subgraph group_curated["Curated records"]
  node_hadithpage["Hadith page<br/>[page.tsx]"]
  node_hadithview["Hadith and route view<br/>[HadithView.tsx]"]
  node_narratorpage["Narrator page<br/>[page.tsx]"]
  node_narratorpanel["Narrator details"]
  node_data["Curated data access<br/>[load.ts]"]
  node_sourcespage["Sources page<br/>[page.tsx]"]
  node_corpuspage["Corpus hadith page<br/>[page.tsx]"]
  node_corpushadith["Corpus entry view<br/>[CorpusHadith.tsx]"]
end

subgraph group_algorithms["Shared algorithms"]
  node_tokenizer["Arabic tokenizer<br/>[tokenize.ts]"]
  node_matcher["Isnād matching<br/>[match.ts]"]
  node_explorergraph["Shared-chain graph<br/>[graph.ts]"]
  node_layout["Tree layout<br/>[layout.ts]"]
  node_derivations["Record derivations<br/>[derive.ts]"]
end

node_visitor(("Visitor"))

node_visitor -->|"opens"| node_home
node_home -->|"renders"| node_parse
node_parse -->|"reads text"| node_reader
node_reader -->|"dispatches tags"| node_worker
node_reader -->|"falls back"| node_rules
node_reader -->|"tokenizes"| node_tokenizer
node_parse -->|"links names"| node_linker
node_parse -->|"shows matches"| node_results
node_results -->|"loads entries"| node_corpus
node_results -->|"filters matches"| node_matcher
node_results -->|"builds graph"| node_explorergraph
node_results -->|"renders chain"| node_tree
node_tree -->|"positions nodes"| node_layout
node_visitor -->|"opens record"| node_hadithpage
node_hadithpage -->|"loads hadith"| node_data
node_hadithpage -->|"derives status"| node_derivations
node_hadithpage -->|"renders routes"| node_hadithview
node_hadithview -->|"shows tree"| node_tree
node_visitor -->|"opens narrator"| node_narratorpage
node_narratorpage -->|"loads records"| node_data
node_narratorpage -->|"derives links"| node_derivations
node_narratorpage -->|"renders details"| node_narratorpanel
node_visitor -->|"opens sources"| node_sourcespage
node_sourcespage -->|"loads records"| node_data
node_visitor -->|"opens entry"| node_corpuspage
node_corpuspage -->|"renders entry"| node_corpushadith

click node_home "https://github.com/malik-712/sanad/blob/main/app/page.tsx"
click node_parse "https://github.com/malik-712/sanad/blob/main/components/parse/ParseApp.tsx"
click node_reader "https://github.com/malik-712/sanad/blob/main/lib/ml/client.ts"
click node_worker "https://github.com/malik-712/sanad/blob/main/lib/ml/worker.ts"
click node_rules "https://github.com/malik-712/sanad/blob/main/lib/parser/ruleParser.ts"
click node_tokenizer "https://github.com/malik-712/sanad/blob/main/lib/parser/tokenize.ts"
click node_linker "https://github.com/malik-712/sanad/blob/main/lib/linker/linker.ts"
click node_results "https://github.com/malik-712/sanad/blob/main/components/explorer/ExplorerResults.tsx"
click node_matcher "https://github.com/malik-712/sanad/blob/main/lib/explorer/match.ts"
click node_corpus "https://github.com/malik-712/sanad/blob/main/lib/explorer/corpus.ts"
click node_explorergraph "https://github.com/malik-712/sanad/blob/main/lib/explorer/graph.ts"
click node_tree "https://github.com/malik-712/sanad/blob/main/components/tree/IsnadTree.tsx"
click node_layout "https://github.com/malik-712/sanad/blob/main/lib/isnad/layout.ts"
click node_hadithpage "https://github.com/malik-712/sanad/blob/main/app/hadith/%5Bid%5D/page.tsx"
click node_hadithview "https://github.com/malik-712/sanad/blob/main/components/hadith/HadithView.tsx"
click node_narratorpage "https://github.com/malik-712/sanad/blob/main/app/narrator/%5Bid%5D/page.tsx"
click node_narratorpanel "https://github.com/malik-712/sanad/blob/main/components/panels/NarratorPanelBody.tsx"
click node_data "https://github.com/malik-712/sanad/blob/main/lib/data/load.ts"
click node_derivations "https://github.com/malik-712/sanad/blob/main/lib/data/derive.ts"
click node_sourcespage "https://github.com/malik-712/sanad/blob/main/app/sources/page.tsx"
click node_corpuspage "https://github.com/malik-712/sanad/blob/main/app/c/page.tsx"
click node_corpushadith "https://github.com/malik-712/sanad/blob/main/components/explorer/CorpusHadith.tsx"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_home toneBlue
class node_parse,node_reader,node_worker,node_rules,node_linker toneAmber
class node_results,node_corpus,node_tree toneMint
class node_hadithpage,node_hadithview,node_narratorpage,node_narratorpanel,node_data,node_sourcespage,node_corpuspage,node_corpushadith toneRose
class node_tokenizer,node_matcher,node_explorergraph,node_layout,node_derivations,node_visitor toneIndigo
```

## Components

### User experience

- [Explorer page](https://github.com/malik-712/sanad/blob/main/app/page.tsx): `app/page.tsx`

### Isnād reading

- [Parse interface](https://github.com/malik-712/sanad/blob/main/components/parse/ParseApp.tsx): `components/parse/ParseApp.tsx`
- [Reader coordinator](https://github.com/malik-712/sanad/blob/main/lib/ml/client.ts): `lib/ml/client.ts`
- [Model worker](https://github.com/malik-712/sanad/blob/main/lib/ml/worker.ts): `lib/ml/worker.ts`
- [Rule parser](https://github.com/malik-712/sanad/blob/main/lib/parser/ruleParser.ts): `lib/parser/ruleParser.ts`
- [Narrator linker](https://github.com/malik-712/sanad/blob/main/lib/linker/linker.ts): `lib/linker/linker.ts`

### Corpus discovery

- [Explorer results](https://github.com/malik-712/sanad/blob/main/components/explorer/ExplorerResults.tsx): `components/explorer/ExplorerResults.tsx`
- [Corpus access](https://github.com/malik-712/sanad/blob/main/lib/explorer/corpus.ts): `lib/explorer/corpus.ts`
- [Interactive tree](https://github.com/malik-712/sanad/blob/main/components/tree/IsnadTree.tsx): `components/tree/IsnadTree.tsx`

### Curated records

- [Hadith page](https://github.com/malik-712/sanad/blob/main/app/hadith/%5Bid%5D/page.tsx): `app/hadith/[id]/page.tsx`
- [Hadith and route view](https://github.com/malik-712/sanad/blob/main/components/hadith/HadithView.tsx): `components/hadith/HadithView.tsx`
- [Narrator page](https://github.com/malik-712/sanad/blob/main/app/narrator/%5Bid%5D/page.tsx): `app/narrator/[id]/page.tsx`
- [Narrator details](https://github.com/malik-712/sanad/blob/main/components/panels/NarratorPanelBody.tsx): `components/panels/NarratorPanelBody.tsx`
- [Curated data access](https://github.com/malik-712/sanad/blob/main/lib/data/load.ts): `lib/data/load.ts`
- [Sources page](https://github.com/malik-712/sanad/blob/main/app/sources/page.tsx): `app/sources/page.tsx`
- [Corpus hadith page](https://github.com/malik-712/sanad/blob/main/app/c/page.tsx): `app/c/page.tsx`
- [Corpus entry view](https://github.com/malik-712/sanad/blob/main/components/explorer/CorpusHadith.tsx): `components/explorer/CorpusHadith.tsx`

### Shared algorithms

- [Arabic tokenizer](https://github.com/malik-712/sanad/blob/main/lib/parser/tokenize.ts): `lib/parser/tokenize.ts`
- [Isnād matching](https://github.com/malik-712/sanad/blob/main/lib/explorer/match.ts): `lib/explorer/match.ts`
- [Shared-chain graph](https://github.com/malik-712/sanad/blob/main/lib/explorer/graph.ts): `lib/explorer/graph.ts`
- [Tree layout](https://github.com/malik-712/sanad/blob/main/lib/isnad/layout.ts): `lib/isnad/layout.ts`
- [Record derivations](https://github.com/malik-712/sanad/blob/main/lib/data/derive.ts): `lib/data/derive.ts`

### Other components

- **Visitor**

## Connections

- Visitor → Explorer page: opens (evidence: `README.md`)
- Explorer page → Parse interface: renders (evidence: `app/page.tsx`)
- Parse interface → Reader coordinator: reads text (evidence: `components/parse/ParseApp.tsx`)
- Reader coordinator → Model worker: dispatches tags (evidence: `lib/ml/client.ts`)
- Reader coordinator → Rule parser: falls back (evidence: `lib/ml/client.ts`)
- Reader coordinator → Arabic tokenizer: tokenizes (evidence: `lib/ml/client.ts`)
- Parse interface → Narrator linker: links names (evidence: `components/parse/ParseApp.tsx`)
- Parse interface → Explorer results: shows matches (evidence: `components/parse/ParseApp.tsx`)
- Explorer results → Corpus access: loads entries (evidence: `components/explorer/ExplorerResults.tsx`)
- Explorer results → Isnād matching: filters matches (evidence: `components/explorer/ExplorerResults.tsx`)
- Explorer results → Shared-chain graph: builds graph (evidence: `components/explorer/ExplorerResults.tsx`)
- Explorer results → Interactive tree: renders chain (evidence: `components/explorer/ExplorerResults.tsx`)
- Interactive tree → Tree layout: positions nodes (evidence: `components/tree/IsnadTree.tsx`)
- Visitor → Hadith page: opens record (evidence: `README.md`)
- Hadith page → Curated data access: loads hadith (evidence: `app/hadith/[id]/page.tsx`)
- Hadith page → Record derivations: derives status (evidence: `app/hadith/[id]/page.tsx`)
- Hadith page → Hadith and route view: renders routes (evidence: `app/hadith/[id]/page.tsx`)
- Hadith and route view → Interactive tree: shows tree (evidence: `components/hadith/HadithView.tsx`)
- Visitor → Narrator page: opens narrator (evidence: `README.md`)
- Narrator page → Curated data access: loads records (evidence: `app/narrator/[id]/page.tsx`)
- Narrator page → Record derivations: derives links (evidence: `app/narrator/[id]/page.tsx`)
- Narrator page → Narrator details: renders details (evidence: `app/narrator/[id]/page.tsx`)
- Visitor → Sources page: opens sources (evidence: `README.md`)
- Sources page → Curated data access: loads records (evidence: `app/sources/page.tsx`)
- Visitor → Corpus hadith page: opens entry (evidence: `README.md`)
- Corpus hadith page → Corpus entry view: renders entry (evidence: `app/c/page.tsx`)
