# can1357/jegrep architecture

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

- Interactive diagram: https://gitdiagram.com/can1357/jegrep
- Repository: https://github.com/can1357/jegrep

## Overview

jegrep is a live-tree semantic search CLI: a user asks a natural-language question, a selected exploration strategy discovers and ranks candidate paths, then the search judges file content and reports relevant line ranges. The main internal layers are the shared search context/tree, composable prompt builders, and the Jev HTTP client. Documented capabilities include multiple exploration strategies, lexical candidate rescue, secret withholding, calibrated scores, live progress, and JSON/compact/tree output. The excerpts establish the main dispatch and reporting flow; strategy-to-helper links are included only where documented or directly supported.

Main entry points: [`src/ctx.rs`](https://github.com/can1357/jegrep/blob/main/src/ctx.rs) (Search context), [`src/strategies/mod.rs`](https://github.com/can1357/jegrep/blob/main/src/strategies/mod.rs) (Strategy selection), [`src/main.rs`](https://github.com/can1357/jegrep/blob/main/src/main.rs) (CLI entry), [`src/jev.rs`](https://github.com/can1357/jegrep/blob/main/src/jev.rs) (Jev client)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["CLI and output"]
  node_cli["CLI entry<br/>[main.rs]"]
  node_report["Result reporting<br/>[report.rs]"]
  node_ui["Progress UI<br/>[ui.rs]"]
end

subgraph group_search["Search orchestration"]
  node_context["Search context<br/>[ctx.rs]"]
  node_tree["Live search tree<br/>[tree.rs]"]
  node_grep["Lexical scan<br/>[grep.rs]"]
end

subgraph group_exploration["Exploration strategies"]
  node_strategy_dispatch["Strategy selection<br/>[mod.rs]"]
  node_cascade["Cascade search<br/>[cascade.rs]"]
  node_beam["Beam search<br/>[beam.rs]"]
  node_deep["Deep search<br/>[deep.rs]"]
  node_window["Window search<br/>[window.rs]"]
  node_other_strategies["Other strategies"]
end

subgraph group_judgment["Judgment and safety"]
  node_questions["Prompt builders<br/>[questions.rs]"]
  node_secrets["Secret screening<br/>[secrets.rs]"]
  node_jev["Jev client<br/>[jev.rs]"]
end

subgraph group_runtime["Runtime support"]
  node_walker["Filesystem walker<br/>[mod.rs]"]
  node_scan_cache[("Scan cache<br/>[cache.rs]")]
  node_pool["Request pool<br/>[pool.rs]"]
  node_env["Provider configuration<br/>[env.rs]"]
end

node_user(("Search user"))
node_provider["Jev providers"]

node_user -->|"asks query"| node_cli
node_cli -->|"creates context"| node_context
node_cli -->|"selects strategy"| node_strategy_dispatch
node_strategy_dispatch -->|"constructs"| node_cascade
node_strategy_dispatch -->|"constructs"| node_beam
node_strategy_dispatch -->|"constructs"| node_deep
node_strategy_dispatch -->|"constructs"| node_window
node_strategy_dispatch -->|"registers"| node_other_strategies
node_cli -->|"prints results"| node_report
node_cli -->|"configures progress"| node_ui
node_context -->|"holds state"| node_tree
node_context -->|"holds pool"| node_pool
node_cascade -->|"drives search"| node_context
node_beam -->|"drives search"| node_context
node_deep -->|"drives search"| node_context
node_window -->|"drives search"| node_context
node_other_strategies -.->|"drives search"| node_context
node_strategy_dispatch -->|"uses builders"| node_questions
node_questions -->|"screens content"| node_secrets
node_pool -.->|"submits requests"| node_jev
node_jev -->|"sends judgments"| node_provider
node_env -->|"configures providers"| node_jev
node_grep -->|"discovers candidates"| node_walker
node_walker -->|"checks scan cache"| node_scan_cache
node_report -->|"reads results"| node_context
node_ui -->|"renders exploration"| node_tree

click node_cli "https://github.com/can1357/jegrep/blob/main/src/main.rs"
click node_report "https://github.com/can1357/jegrep/blob/main/src/report.rs"
click node_ui "https://github.com/can1357/jegrep/blob/main/src/ui.rs"
click node_context "https://github.com/can1357/jegrep/blob/main/src/ctx.rs"
click node_tree "https://github.com/can1357/jegrep/blob/main/src/tree.rs"
click node_walker "https://github.com/can1357/jegrep/blob/main/src/walker/mod.rs"
click node_scan_cache "https://github.com/can1357/jegrep/blob/main/src/walker/cache.rs"
click node_strategy_dispatch "https://github.com/can1357/jegrep/blob/main/src/strategies/mod.rs"
click node_cascade "https://github.com/can1357/jegrep/blob/main/src/strategies/cascade.rs"
click node_beam "https://github.com/can1357/jegrep/blob/main/src/strategies/beam.rs"
click node_deep "https://github.com/can1357/jegrep/blob/main/src/strategies/deep.rs"
click node_window "https://github.com/can1357/jegrep/blob/main/src/strategies/window.rs"
click node_other_strategies "https://github.com/can1357/jegrep/tree/main/src/strategies"
click node_grep "https://github.com/can1357/jegrep/blob/main/src/grep.rs"
click node_questions "https://github.com/can1357/jegrep/blob/main/src/questions.rs"
click node_secrets "https://github.com/can1357/jegrep/blob/main/src/secrets.rs"
click node_jev "https://github.com/can1357/jegrep/blob/main/src/jev.rs"
click node_pool "https://github.com/can1357/jegrep/blob/main/src/pool.rs"
click node_env "https://github.com/can1357/jegrep/blob/main/src/env.rs"

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_cli,node_report,node_ui,node_user toneBlue
class node_context,node_tree,node_grep toneAmber
class node_strategy_dispatch,node_cascade,node_beam,node_deep,node_window,node_other_strategies toneMint
class node_questions,node_secrets,node_jev toneRose
class node_walker,node_scan_cache,node_pool,node_env,node_provider toneIndigo
```

## Components

### CLI and output

- [CLI entry](https://github.com/can1357/jegrep/blob/main/src/main.rs): `src/main.rs`
- [Result reporting](https://github.com/can1357/jegrep/blob/main/src/report.rs): `src/report.rs`
- [Progress UI](https://github.com/can1357/jegrep/blob/main/src/ui.rs): `src/ui.rs`

### Search orchestration

- [Search context](https://github.com/can1357/jegrep/blob/main/src/ctx.rs): `src/ctx.rs`
- [Live search tree](https://github.com/can1357/jegrep/blob/main/src/tree.rs): `src/tree.rs`
- [Lexical scan](https://github.com/can1357/jegrep/blob/main/src/grep.rs): `src/grep.rs`

### Exploration strategies

- [Strategy selection](https://github.com/can1357/jegrep/blob/main/src/strategies/mod.rs): `src/strategies/mod.rs`
- [Cascade search](https://github.com/can1357/jegrep/blob/main/src/strategies/cascade.rs): `src/strategies/cascade.rs`
- [Beam search](https://github.com/can1357/jegrep/blob/main/src/strategies/beam.rs): `src/strategies/beam.rs`
- [Deep search](https://github.com/can1357/jegrep/blob/main/src/strategies/deep.rs): `src/strategies/deep.rs`
- [Window search](https://github.com/can1357/jegrep/blob/main/src/strategies/window.rs): `src/strategies/window.rs`
- [Other strategies](https://github.com/can1357/jegrep/tree/main/src/strategies): `src/strategies`

### Judgment and safety

- [Prompt builders](https://github.com/can1357/jegrep/blob/main/src/questions.rs): `src/questions.rs`
- [Secret screening](https://github.com/can1357/jegrep/blob/main/src/secrets.rs): `src/secrets.rs`
- [Jev client](https://github.com/can1357/jegrep/blob/main/src/jev.rs): `src/jev.rs`

### Runtime support

- [Filesystem walker](https://github.com/can1357/jegrep/blob/main/src/walker/mod.rs): `src/walker/mod.rs`
- [Scan cache](https://github.com/can1357/jegrep/blob/main/src/walker/cache.rs): `src/walker/cache.rs`
- [Request pool](https://github.com/can1357/jegrep/blob/main/src/pool.rs): `src/pool.rs`
- [Provider configuration](https://github.com/can1357/jegrep/blob/main/src/env.rs): `src/env.rs`

### Other components

- **Search user**
- **Jev providers**

## Connections

- Search user → CLI entry: asks query (evidence: `README.md`)
- CLI entry → Search context: creates context (evidence: `src/main.rs`)
- CLI entry → Strategy selection: selects strategy (evidence: `src/strategies/mod.rs`)
- Strategy selection → Cascade search: constructs (evidence: `src/strategies/mod.rs`)
- Strategy selection → Beam search: constructs (evidence: `src/strategies/mod.rs`)
- Strategy selection → Deep search: constructs (evidence: `src/strategies/mod.rs`)
- Strategy selection → Window search: constructs (evidence: `src/strategies/mod.rs`)
- Strategy selection → Other strategies: registers (evidence: `src/strategies/mod.rs`)
- CLI entry → Result reporting: prints results (evidence: `src/main.rs`)
- CLI entry → Progress UI: configures progress (evidence: `src/main.rs`)
- Search context → Live search tree: holds state (evidence: `src/ctx.rs`)
- Search context → Request pool: holds pool (evidence: `src/ctx.rs`)
- Cascade search → Search context: drives search (evidence: `src/strategies/cascade.rs`)
- Beam search → Search context: drives search (evidence: `src/strategies/beam.rs`)
- Deep search → Search context: drives search (evidence: `src/strategies/deep.rs`)
- Window search → Search context: drives search (evidence: `src/strategies/window.rs`)
- Other strategies → Search context: drives search (evidence: `src/strategies/mod.rs`)
- Strategy selection → Prompt builders: uses builders (evidence: `src/strategies/mod.rs`)
- Prompt builders → Secret screening: screens content (evidence: `src/questions.rs`)
- Request pool → Jev client: submits requests
- Jev client → Jev providers: sends judgments (evidence: `README.md`)
- Provider configuration → Jev client: configures providers (evidence: `src/jev.rs`)
- Lexical scan → Filesystem walker: discovers candidates (evidence: `src/grep.rs`)
- Filesystem walker → Scan cache: checks scan cache (evidence: `src/walker/mod.rs`)
- Result reporting → Search context: reads results (evidence: `src/report.rs`)
- Progress UI → Live search tree: renders exploration (evidence: `src/ui.rs`)
