# tbadru/lenscope architecture

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

- Interactive diagram: https://gitdiagram.com/tbadru/lenscope
- Repository: https://github.com/tbadru/lenscope

## Overview

Lenscope is a VS Code fuzzy finder. Users launch a search command, enter a query in a webview, and select a result to open it in the editor. The sampled extension code shows ripgrep discovery and process-backed file/grep search, plus current-buffer line collection; webview assets handle the search interface. The README also documents current-buffer fuzzy search. The `git files` capability is marked unfinished. Some implementation details are unsampled, so the graph omits unsupported interactions.

Main entry points: [`src/extension.ts`](https://github.com/tbadru/lenscope/blob/main/src/extension.ts) (Command Handlers), [`src/webview.ts`](https://github.com/tbadru/lenscope/blob/main/src/webview.ts) (Webview Templates), [`media/webview.js`](https://github.com/tbadru/lenscope/blob/main/media/webview.js) (Search UI)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_vscode["VS Code Extension"]
  node_extension["Command Handlers<br/>[extension.ts]"]
end

subgraph group_search["Search Features"]
  node_file_search["Find Files<br/>[extension.ts]"]
  node_grep_search["Live Grep<br/>[extension.ts]"]
  node_buffer_search["Buffer Fuzzy Search<br/>[extension.ts]"]
  node_rg_discovery["ripgrep Discovery<br/>[extension.ts]"]
  node_preview["Grep Preview<br/>[extension.ts]"]
  node_git_files["Git Files &#40;planned&#41;"]
end

subgraph group_interface["Search Interface"]
  node_webview_templates["Webview Templates<br/>[webview.ts]"]
  node_webview_ui["Search UI<br/>[webview.js]"]
end

node_user(("VS Code User"))
node_rg["ripgrep"]
node_editor["VS Code Editor"]

node_user -->|"runs command"| node_extension
node_extension -->|"resolves binary"| node_rg_discovery
node_rg_discovery -->|"locates"| node_rg
node_extension -->|"handles command"| node_file_search
node_extension -->|"handles command"| node_grep_search
node_extension -->|"handles command"| node_buffer_search
node_file_search -->|"lists files"| node_rg
node_grep_search -->|"searches workspace"| node_rg
node_extension -->|"gets content"| node_webview_templates
node_webview_templates -->|"loads script"| node_webview_ui
node_webview_ui -.->|"posts messages"| node_extension
node_extension -->|"reads preview"| node_preview
node_extension -->|"opens result"| node_editor

click node_extension "https://github.com/tbadru/lenscope/blob/main/src/extension.ts"
click node_file_search "https://github.com/tbadru/lenscope/blob/main/src/extension.ts"
click node_grep_search "https://github.com/tbadru/lenscope/blob/main/src/extension.ts"
click node_buffer_search "https://github.com/tbadru/lenscope/blob/main/src/extension.ts"
click node_rg_discovery "https://github.com/tbadru/lenscope/blob/main/src/extension.ts"
click node_preview "https://github.com/tbadru/lenscope/blob/main/src/extension.ts"
click node_webview_templates "https://github.com/tbadru/lenscope/blob/main/src/webview.ts"
click node_webview_ui "https://github.com/tbadru/lenscope/blob/main/media/webview.js"

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_extension,node_user toneBlue
class node_file_search,node_grep_search,node_buffer_search,node_rg_discovery,node_preview,node_git_files toneAmber
class node_webview_templates,node_webview_ui toneMint
class node_rg,node_editor toneIndigo
```

## Components

### VS Code Extension

- [Command Handlers](https://github.com/tbadru/lenscope/blob/main/src/extension.ts): `src/extension.ts`

### Search Features

- [Find Files](https://github.com/tbadru/lenscope/blob/main/src/extension.ts): `src/extension.ts`
- [Live Grep](https://github.com/tbadru/lenscope/blob/main/src/extension.ts): `src/extension.ts`
- [Buffer Fuzzy Search](https://github.com/tbadru/lenscope/blob/main/src/extension.ts): `src/extension.ts`
- [ripgrep Discovery](https://github.com/tbadru/lenscope/blob/main/src/extension.ts): `src/extension.ts`
- [Grep Preview](https://github.com/tbadru/lenscope/blob/main/src/extension.ts): `src/extension.ts`
- **Git Files (planned)**

### Search Interface

- [Webview Templates](https://github.com/tbadru/lenscope/blob/main/src/webview.ts): `src/webview.ts`
- [Search UI](https://github.com/tbadru/lenscope/blob/main/media/webview.js): `media/webview.js`

### Other components

- **VS Code User**
- **ripgrep**
- **VS Code Editor**

## Connections

- VS Code User → Command Handlers: runs command
- Command Handlers → ripgrep Discovery: resolves binary (evidence: `src/extension.ts`)
- ripgrep Discovery → ripgrep: locates (evidence: `src/extension.ts`)
- Command Handlers → Find Files: handles command (evidence: `src/extension.ts`)
- Command Handlers → Live Grep: handles command (evidence: `src/extension.ts`)
- Command Handlers → Buffer Fuzzy Search: handles command (evidence: `src/extension.ts`)
- Find Files → ripgrep: lists files (evidence: `src/extension.ts`)
- Live Grep → ripgrep: searches workspace (evidence: `src/extension.ts`)
- Command Handlers → Webview Templates: gets content (evidence: `src/extension.ts`)
- Webview Templates → Search UI: loads script (evidence: `src/webview.ts`)
- Search UI → Command Handlers: posts messages
- Command Handlers → Grep Preview: reads preview (evidence: `src/extension.ts`)
- Command Handlers → VS Code Editor: opens result (evidence: `src/extension.ts`)
