# canlin-zhang/rtfm architecture

> Architecture diagram of the GitHub repository canlin-zhang/rtfm, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-24). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/canlin-zhang/rtfm
- Repository: https://github.com/canlin-zhang/rtfm

## Overview

rtfm is a local MCP server that indexes documentation files and Git-backed documentation repositories, then returns searchable results and grounded page/line citations. The user workflow runs through an MCP client and registered tools into query operations; when needed, sources are refreshed through staged scanning, selection, reading, extraction, and indexing. The README also documents Claude Code and OpenCode fronts plus the read-the-manual skill. Edges reflect the shown imports, calls, or README statements; unsampled front bootstrap internals are not expanded.

Main entry points: [`rtfm/index.py`](https://github.com/canlin-zhang/rtfm/blob/main/rtfm/index.py) (Content index), [`rtfm/manifest.py`](https://github.com/canlin-zhang/rtfm/blob/main/rtfm/manifest.py) (Source manifest), [`rtfm_server.py`](https://github.com/canlin-zhang/rtfm/blob/main/rtfm_server.py) (MCP server), [`rtfm/staging.py`](https://github.com/canlin-zhang/rtfm/blob/main/rtfm/staging.py) (Stage and scan)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_fronts["Client fronts"]
  node_claude["Claude Code front<br/>[bootstrap.py]"]
  node_opencode["OpenCode plugin<br/>[index.ts]"]
  node_skill["Manual skill<br/>[SKILL.md]"]
  node_bootstrap["Front bootstrap<br/>[bootstrap.py]"]
end

subgraph group_service["MCP service"]
  node_server["MCP server<br/>[rtfm_server.py]"]
  node_app["MCP app<br/>[app.py]"]
  node_toolreg["Tool registration<br/>[tools.py]"]
end

subgraph group_sources["Source management"]
  node_config["Runtime config<br/>[config.py]"]
  node_manifest["Source manifest<br/>[manifest.py]"]
  node_git["Git operations<br/>[git_ops.py]"]
end

subgraph group_indexing["Indexing pipeline"]
  node_staging["Stage and scan<br/>[staging.py]"]
  node_extract["Text extraction<br/>[extract.py]"]
  node_index[("Content index<br/>[index.py]")]
end

subgraph group_retrieval["Search and results"]
  node_query["Query operations<br/>[query.py]"]
end

node_client(("MCP client"))

node_client -->|"invokes tools"| node_server
node_claude -.->|"launches"| node_bootstrap
node_opencode -->|"launches"| node_bootstrap
node_opencode -->|"registers"| node_skill
node_server -->|"imports registration"| node_toolreg
node_server -->|"runs"| node_app
node_server -->|"exports tools"| node_query
node_toolreg -->|"registers on"| node_app
node_toolreg -->|"registers functions"| node_query
node_query -->|"loads sources"| node_manifest
node_query -->|"queries and refreshes"| node_index
node_manifest -->|"resolves paths"| node_config
node_manifest -->|"validates repositories"| node_git
node_index -->|"uses settings"| node_config
node_index -->|"uses source definitions"| node_manifest
node_index -->|"refreshes repositories"| node_git
node_index -->|"scans and stages"| node_staging
node_staging -->|"uses source type"| node_manifest
node_staging -->|"uses filters"| node_config
node_staging -->|"extracts selected files"| node_extract

click node_claude "https://github.com/canlin-zhang/rtfm/blob/main/plugins/claude/bootstrap.py"
click node_opencode "https://github.com/canlin-zhang/rtfm/blob/main/plugins/opencode/index.ts"
click node_skill "https://github.com/canlin-zhang/rtfm/blob/main/skills/read-the-manual/SKILL.md"
click node_bootstrap "https://github.com/canlin-zhang/rtfm/blob/main/plugins/opencode/bootstrap.py"
click node_server "https://github.com/canlin-zhang/rtfm/blob/main/rtfm_server.py"
click node_app "https://github.com/canlin-zhang/rtfm/blob/main/rtfm/app.py"
click node_toolreg "https://github.com/canlin-zhang/rtfm/blob/main/rtfm/tools.py"
click node_config "https://github.com/canlin-zhang/rtfm/blob/main/rtfm/config.py"
click node_manifest "https://github.com/canlin-zhang/rtfm/blob/main/rtfm/manifest.py"
click node_git "https://github.com/canlin-zhang/rtfm/blob/main/rtfm/git_ops.py"
click node_staging "https://github.com/canlin-zhang/rtfm/blob/main/rtfm/staging.py"
click node_extract "https://github.com/canlin-zhang/rtfm/blob/main/rtfm/extract.py"
click node_index "https://github.com/canlin-zhang/rtfm/blob/main/rtfm/index.py"
click node_query "https://github.com/canlin-zhang/rtfm/blob/main/rtfm/query.py"

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_claude,node_opencode,node_skill,node_bootstrap,node_client toneBlue
class node_server,node_app,node_toolreg toneAmber
class node_config,node_manifest,node_git toneMint
class node_staging,node_extract,node_index toneRose
class node_query toneIndigo
```

## Components

### Client fronts

- [Claude Code front](https://github.com/canlin-zhang/rtfm/blob/main/plugins/claude/bootstrap.py): `plugins/claude/bootstrap.py`
- [OpenCode plugin](https://github.com/canlin-zhang/rtfm/blob/main/plugins/opencode/index.ts): `plugins/opencode/index.ts`
- [Manual skill](https://github.com/canlin-zhang/rtfm/blob/main/skills/read-the-manual/SKILL.md): `skills/read-the-manual/SKILL.md`
- [Front bootstrap](https://github.com/canlin-zhang/rtfm/blob/main/plugins/opencode/bootstrap.py): `plugins/opencode/bootstrap.py`

### MCP service

- [MCP server](https://github.com/canlin-zhang/rtfm/blob/main/rtfm_server.py): `rtfm_server.py`
- [MCP app](https://github.com/canlin-zhang/rtfm/blob/main/rtfm/app.py): `rtfm/app.py`
- [Tool registration](https://github.com/canlin-zhang/rtfm/blob/main/rtfm/tools.py): `rtfm/tools.py`

### Source management

- [Runtime config](https://github.com/canlin-zhang/rtfm/blob/main/rtfm/config.py): `rtfm/config.py`
- [Source manifest](https://github.com/canlin-zhang/rtfm/blob/main/rtfm/manifest.py): `rtfm/manifest.py`
- [Git operations](https://github.com/canlin-zhang/rtfm/blob/main/rtfm/git_ops.py): `rtfm/git_ops.py`

### Indexing pipeline

- [Stage and scan](https://github.com/canlin-zhang/rtfm/blob/main/rtfm/staging.py): `rtfm/staging.py`
- [Text extraction](https://github.com/canlin-zhang/rtfm/blob/main/rtfm/extract.py): `rtfm/extract.py`
- [Content index](https://github.com/canlin-zhang/rtfm/blob/main/rtfm/index.py): `rtfm/index.py`

### Search and results

- [Query operations](https://github.com/canlin-zhang/rtfm/blob/main/rtfm/query.py): `rtfm/query.py`

### Other components

- **MCP client**

## Connections

- MCP client → MCP server: invokes tools (evidence: `README.md`)
- Claude Code front → Front bootstrap: launches
- OpenCode plugin → Front bootstrap: launches (evidence: `plugins/opencode/index.ts`)
- OpenCode plugin → Manual skill: registers (evidence: `plugins/opencode/index.ts`)
- MCP server → Tool registration: imports registration (evidence: `rtfm_server.py`)
- MCP server → MCP app: runs (evidence: `rtfm_server.py`)
- MCP server → Query operations: exports tools (evidence: `rtfm_server.py`)
- Tool registration → MCP app: registers on (evidence: `rtfm/tools.py`)
- Tool registration → Query operations: registers functions (evidence: `rtfm/tools.py`)
- Query operations → Source manifest: loads sources (evidence: `rtfm/query.py`)
- Query operations → Content index: queries and refreshes (evidence: `rtfm/query.py`)
- Source manifest → Runtime config: resolves paths (evidence: `rtfm/manifest.py`)
- Source manifest → Git operations: validates repositories (evidence: `rtfm/manifest.py`)
- Content index → Runtime config: uses settings (evidence: `rtfm/index.py`)
- Content index → Source manifest: uses source definitions (evidence: `rtfm/index.py`)
- Content index → Git operations: refreshes repositories (evidence: `rtfm/index.py`)
- Content index → Stage and scan: scans and stages (evidence: `rtfm/index.py`)
- Stage and scan → Source manifest: uses source type (evidence: `rtfm/staging.py`)
- Stage and scan → Runtime config: uses filters (evidence: `rtfm/staging.py`)
- Stage and scan → Text extraction: extracts selected files (evidence: `rtfm/staging.py`)
