# icampana/dsearch architecture

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

- Interactive diagram: https://gitdiagram.com/icampana/dsearch
- Repository: https://github.com/icampana/dsearch

## Overview

dsearch is an offline terminal documentation search tool. Users install DevDocs sets, then search all installed sets or scope by document; results can be listed or rendered as text/Markdown, with JSON output for scripting. The graph also covers catalog browsing and installed-set management. Edges follow the sampled CLI orchestration and storage/client implementations; unsampled behavior is not inferred.

Main entry points: [`internal/cli/root.go`](https://github.com/icampana/dsearch/blob/main/internal/cli/root.go) (Command routing), [`internal/devdocs/store.go`](https://github.com/icampana/dsearch/blob/main/internal/devdocs/store.go) (Local doc store), [`internal/cli/install.go`](https://github.com/icampana/dsearch/blob/main/internal/cli/install.go) (Install docs), [`internal/cli/available.go`](https://github.com/icampana/dsearch/blob/main/internal/cli/available.go) (Browse catalog)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["CLI entry"]
  node_main["Executable entry<br/>[main.go]"]
  node_commands["Command routing<br/>[root.go]"]
  node_paths["XDG paths<br/>[paths.go]"]
  node_migration["Data migration<br/>[migrate.go]"]
end

subgraph group_catalog["Catalog management"]
  node_install["Install docs<br/>[install.go]"]
  node_available["Browse catalog<br/>[available.go]"]
  node_list["List installed<br/>[list.go]"]
  node_uninstall["Remove docs<br/>[uninstall.go]"]
end

subgraph group_search["Search and display"]
  node_engine["Fuzzy search<br/>[engine.go]"]
  node_renderer["Content renderer<br/>[render.go]"]
end

subgraph group_data["Documentation data"]
  node_client["DevDocs client<br/>[client.go]"]
  node_store[("Local doc store<br/>[store.go]")]
end

node_user(("Terminal user"))
node_remote["DevDocs service"]
node_output["Terminal or pipe"]

node_user -->|"runs command"| node_main
node_main -->|"executes"| node_commands
node_commands -->|"initializes paths"| node_paths
node_commands -->|"migrates data"| node_migration
node_commands -->|"routes install"| node_install
node_commands -->|"routes browse"| node_available
node_commands -->|"routes list"| node_list
node_commands -->|"routes removal"| node_uninstall
node_install -->|"fetches manifest and docs"| node_client
node_client -->|"requests manifest and content"| node_remote
node_install -->|"caches and installs"| node_store
node_available -->|"loads or caches manifest"| node_store
node_available -->|"fetches manifest"| node_client
node_list -->|"reads installed docs"| node_store
node_uninstall -->|"removes doc set"| node_store
node_commands -->|"loads indices and content"| node_store
node_commands -->|"searches query"| node_engine
node_engine -->|"uses index entries"| node_store
node_commands -->|"renders content"| node_renderer
node_commands -->|"prints results"| node_output
node_renderer -->|"returns formatted text"| node_output
node_user -->|"reads or pipes"| node_output

click node_main "https://github.com/icampana/dsearch/blob/main/cmd/dsearch/main.go"
click node_commands "https://github.com/icampana/dsearch/blob/main/internal/cli/root.go"
click node_install "https://github.com/icampana/dsearch/blob/main/internal/cli/install.go"
click node_available "https://github.com/icampana/dsearch/blob/main/internal/cli/available.go"
click node_list "https://github.com/icampana/dsearch/blob/main/internal/cli/list.go"
click node_uninstall "https://github.com/icampana/dsearch/blob/main/internal/cli/uninstall.go"
click node_client "https://github.com/icampana/dsearch/blob/main/internal/devdocs/client.go"
click node_store "https://github.com/icampana/dsearch/blob/main/internal/devdocs/store.go"
click node_paths "https://github.com/icampana/dsearch/blob/main/internal/config/paths.go"
click node_migration "https://github.com/icampana/dsearch/blob/main/internal/config/migrate.go"
click node_engine "https://github.com/icampana/dsearch/blob/main/internal/search/engine.go"
click node_renderer "https://github.com/icampana/dsearch/blob/main/internal/render/render.go"

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_main,node_commands,node_paths,node_migration,node_user toneBlue
class node_install,node_available,node_list,node_uninstall toneAmber
class node_engine,node_renderer toneMint
class node_client,node_store toneRose
class node_remote,node_output toneIndigo
```

## Components

### CLI entry

- [Executable entry](https://github.com/icampana/dsearch/blob/main/cmd/dsearch/main.go): `cmd/dsearch/main.go`
- [Command routing](https://github.com/icampana/dsearch/blob/main/internal/cli/root.go): `internal/cli/root.go`
- [XDG paths](https://github.com/icampana/dsearch/blob/main/internal/config/paths.go): `internal/config/paths.go`
- [Data migration](https://github.com/icampana/dsearch/blob/main/internal/config/migrate.go): `internal/config/migrate.go`

### Catalog management

- [Install docs](https://github.com/icampana/dsearch/blob/main/internal/cli/install.go): `internal/cli/install.go`
- [Browse catalog](https://github.com/icampana/dsearch/blob/main/internal/cli/available.go): `internal/cli/available.go`
- [List installed](https://github.com/icampana/dsearch/blob/main/internal/cli/list.go): `internal/cli/list.go`
- [Remove docs](https://github.com/icampana/dsearch/blob/main/internal/cli/uninstall.go): `internal/cli/uninstall.go`

### Search and display

- [Fuzzy search](https://github.com/icampana/dsearch/blob/main/internal/search/engine.go): `internal/search/engine.go`
- [Content renderer](https://github.com/icampana/dsearch/blob/main/internal/render/render.go): `internal/render/render.go`

### Documentation data

- [DevDocs client](https://github.com/icampana/dsearch/blob/main/internal/devdocs/client.go): `internal/devdocs/client.go`
- [Local doc store](https://github.com/icampana/dsearch/blob/main/internal/devdocs/store.go): `internal/devdocs/store.go`

### Other components

- **Terminal user**
- **DevDocs service**
- **Terminal or pipe**

## Connections

- Terminal user → Executable entry: runs command (evidence: `cmd/dsearch/main.go`)
- Executable entry → Command routing: executes (evidence: `cmd/dsearch/main.go`)
- Command routing → XDG paths: initializes paths (evidence: `internal/cli/root.go`)
- Command routing → Data migration: migrates data (evidence: `internal/cli/root.go`)
- Command routing → Install docs: routes install (evidence: `internal/cli/root.go`)
- Command routing → Browse catalog: routes browse (evidence: `internal/cli/root.go`)
- Command routing → List installed: routes list (evidence: `internal/cli/root.go`)
- Command routing → Remove docs: routes removal (evidence: `internal/cli/root.go`)
- Install docs → DevDocs client: fetches manifest and docs (evidence: `internal/cli/install.go`)
- DevDocs client → DevDocs service: requests manifest and content (evidence: `internal/devdocs/client.go`)
- Install docs → Local doc store: caches and installs (evidence: `internal/cli/install.go`)
- Browse catalog → Local doc store: loads or caches manifest (evidence: `internal/cli/available.go`)
- Browse catalog → DevDocs client: fetches manifest (evidence: `internal/cli/available.go`)
- List installed → Local doc store: reads installed docs (evidence: `internal/cli/list.go`)
- Remove docs → Local doc store: removes doc set (evidence: `internal/cli/uninstall.go`)
- Command routing → Local doc store: loads indices and content (evidence: `internal/cli/root.go`)
- Command routing → Fuzzy search: searches query (evidence: `internal/cli/root.go`)
- Fuzzy search → Local doc store: uses index entries (evidence: `internal/search/engine.go`)
- Command routing → Content renderer: renders content (evidence: `internal/cli/root.go`)
- Command routing → Terminal or pipe: prints results (evidence: `internal/cli/root.go`)
- Content renderer → Terminal or pipe: returns formatted text
- Terminal user → Terminal or pipe: reads or pipes (evidence: `README.md`)
