# alphabet-h/grooveseek architecture

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

- Interactive diagram: https://gitdiagram.com/alphabet-h/grooveseek
- Repository: https://github.com/alphabet-h/grooveseek

## Overview

#### Purpose and Entry Points
GrooveSeek is a Rust workspace providing local knowledge-base indexing and hybrid semantic/lexical retrieval for MCP clients. The primary `groove` CLI indexes content, searches it directly, runs an MCP server, validates schemas, manages services, and evaluates/tunes retrieval. Main entry points are `grooveseek/src/main.rs` and `grooveseek/src/lib.rs`. Windows service/tray companion binaries are `crates/groove-svc/src/main.rs` and `crates/groove-tray/src/main.rs`.

#### CLI, Configuration, and Operational Modes
The CLI coordinates explicit operations such as `index`, `serve`, `search`, `graph`, `validate`, `doctor`, `eval`, `tune`, and `service`. Configuration discovers KB paths, models, storage, transport, and schema settings through `grooveseek/src/config.rs`; schema compatibility and validation are handled by `grooveseek/src/schema.rs` and `grooveseek/src/schema_compat.rs`. Deployments may be one-shot CLI processes, persistent local stdio servers, or multi-client HTTP services.

#### Ingestion and Index Construction
Indexing walks the configured knowledge base, excludes disallowed paths, parses supported document formats, chunks content around Markdown headings, and writes searchable records. The orchestration boundary is `grooveseek/src/indexer.rs`; file-type dispatch and fault isolation live in `grooveseek/src/parser/registry.rs` and `grooveseek/src/parser/panic_guard.rs`. Parsers support Markdown/text plus optional PDF, OOXML document, spreadsheet, and presentation inputs via paths such as `grooveseek/src/parser/pdf.rs` and `grooveseek/src/parser/docx.rs`.

#### Persistent Retrieval Store and Embeddings
SQLite is the durable index, containing document metadata, chunks, lexical FTS data, and sqlite-vec vector data. Database schema, storage, and search access are separated under `grooveseek/src/db/schema.rs`, `grooveseek/src/db/storage.rs`, and `grooveseek/src/db/search.rs`. `grooveseek/src/embedder.rs` loads/selects ONNX embedding models; models are downloaded from HuggingFace on first use. SQLite and ONNX Runtime are statically linked into distributed binaries.

#### Hybrid Search and Ranking Pipeline
A query flows from CLI or MCP transport into retrieval, where lexical FTS and semantic vector candidates are combined, then optionally reranked/diversified and expanded to parent context. Query compilation is in `grooveseek/src/db/fts_query.rs`; ranking stages are represented by `grooveseek/src/mmr.rs` and `grooveseek/src/parent.rs`. Search results retain document identity, headings, metadata, and citation-oriented spans for downstream clients.

#### MCP, HTTP, and Resource Boundary
The server exposes MCP tools, prompts, and `kb://` resources; request-facing orchestration is in `grooveseek/src/server.rs`, with document/resource and search handlers under `grooveseek/src/server/documents.rs` and `grooveseek/src/server/search.rs`. Transport adapters separate stdio MCP from Streamable HTTP in `grooveseek/src/transport/stdio.rs` and `grooveseek/src/transport/http.rs`. HTTP additionally serves an operator UI from `grooveseek/src/transport/webui_index.html`; origin/DNS-rebinding protections form a material network boundary.

#### Live Synchronization, Graphs, and Host Integration
A filesystem watcher incrementally refreshes the persistent index after edits, pulls, or scripts, through `grooveseek/src/watcher.rs`. Link extraction and graph construction support connection-graph retrieval and CLI output via `grooveseek/src/links.rs` and `grooveseek/src/graph.rs`. Cross-platform background installation is isolated in `grooveseek/src/service/mod.rs`, while Windows-specific daemon/tray lifecycle handling resides in `crates/groove-tray/src/daemon.rs` and `crates/groove-tray/src/tray.rs`.

Main entry points: [`grooveseek/src/main.rs`](https://github.com/alphabet-h/grooveseek/blob/main/grooveseek/src/main.rs) (groove CLI), [`grooveseek/src/indexer.rs`](https://github.com/alphabet-h/grooveseek/blob/main/grooveseek/src/indexer.rs) (Index orchestrator), [`grooveseek/src/db/search.rs`](https://github.com/alphabet-h/grooveseek/blob/main/grooveseek/src/db/search.rs) (Hybrid retrieval), [`grooveseek/src/server.rs`](https://github.com/alphabet-h/grooveseek/blob/main/grooveseek/src/server.rs) (MCP server)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_core["Core CLI &amp; config"]
  node_cli["groove CLI<br/>Rust binary<br/>[main.rs]"]
  node_library["Core library<br/>Rust library<br/>[lib.rs]"]
  node_config["Configuration<br/>config discovery<br/>[config.rs]"]
  node_schema["Schema validation<br/>schema compatibility<br/>[schema.rs]"]
end

subgraph group_indexing["Index construction"]
  node_indexer["Index orchestrator<br/>ingestion pipeline<br/>[indexer.rs]"]
  node_parser_registry["Parser registry<br/>format dispatch<br/>[registry.rs]"]
  node_embedder["ONNX embedder<br/>embedding runtime<br/>[embedder.rs]"]
end

subgraph group_retrieval["Storage &amp; retrieval"]
  node_sqlite[("SQLite retrieval index<br/>durable hybrid store<br/>[storage.rs]")]
  node_query_compiler["FTS query compiler<br/>lexical query compiler<br/>[fts_query.rs]"]
  node_hybrid_search["Hybrid retrieval<br/>search access<br/>[search.rs]"]
  node_ranking["Ranking &amp; context<br/>post-retrieval pipeline<br/>[mmr.rs]"]
end

subgraph group_server["MCP server &amp; transports"]
  node_mcp_server["MCP server<br/>request orchestration<br/>[server.rs]"]
  node_search_handler["Search handler<br/>MCP handler<br/>[search.rs]"]
  node_document_handler["Document resources<br/>MCP resource handler<br/>[documents.rs]"]
  node_stdio["stdio MCP transport<br/>transport adapter<br/>[stdio.rs]"]
  node_http["Streamable HTTP<br/>transport adapter<br/>[http.rs]"]
end

subgraph group_operations["Operations &amp; host integration"]
  node_watcher["Filesystem watcher<br/>live synchronization<br/>[watcher.rs]"]
  node_graph["Connection graph<br/>link graph retrieval<br/>[graph.rs]"]
  node_service["Background service installer<br/>host integration<br/>[mod.rs]"]
  node_windows_companion["Windows daemon &amp; tray<br/>Windows lifecycle<br/>[daemon.rs]"]
end

node_cli -->|"invokes"| node_library
node_library -->|"loads"| node_config
node_cli -->|"validates"| node_schema
node_cli -->|"index command"| node_indexer
node_indexer -->|"parses files"| node_parser_registry
node_indexer -->|"embeds chunks"| node_embedder
node_indexer -->|"writes records"| node_sqlite
node_embedder -->|"writes vectors"| node_sqlite
node_cli -->|"search command"| node_hybrid_search
node_query_compiler -->|"compiles lexical query"| node_hybrid_search
node_hybrid_search -->|"queries FTS and vectors"| node_sqlite
node_hybrid_search -->|"candidate results"| node_ranking
node_cli -->|"serve command"| node_mcp_server
node_stdio -->|"MCP requests"| node_mcp_server
node_http -->|"HTTP requests"| node_mcp_server
node_mcp_server -->|"search tool"| node_search_handler
node_mcp_server -->|"kb resources"| node_document_handler
node_search_handler -->|"retrieves"| node_hybrid_search
node_watcher -->|"incremental reindex"| node_indexer
node_cli -->|"graph command"| node_graph
node_cli -->|"service command"| node_service
node_service -.->|"Windows lifecycle"| node_windows_companion

click node_cli "https://github.com/alphabet-h/grooveseek/blob/main/grooveseek/src/main.rs"
click node_library "https://github.com/alphabet-h/grooveseek/blob/main/grooveseek/src/lib.rs"
click node_config "https://github.com/alphabet-h/grooveseek/blob/main/grooveseek/src/config.rs"
click node_schema "https://github.com/alphabet-h/grooveseek/blob/main/grooveseek/src/schema.rs"
click node_indexer "https://github.com/alphabet-h/grooveseek/blob/main/grooveseek/src/indexer.rs"
click node_parser_registry "https://github.com/alphabet-h/grooveseek/blob/main/grooveseek/src/parser/registry.rs"
click node_embedder "https://github.com/alphabet-h/grooveseek/blob/main/grooveseek/src/embedder.rs"
click node_sqlite "https://github.com/alphabet-h/grooveseek/blob/main/grooveseek/src/db/storage.rs"
click node_query_compiler "https://github.com/alphabet-h/grooveseek/blob/main/grooveseek/src/db/fts_query.rs"
click node_hybrid_search "https://github.com/alphabet-h/grooveseek/blob/main/grooveseek/src/db/search.rs"
click node_ranking "https://github.com/alphabet-h/grooveseek/blob/main/grooveseek/src/mmr.rs"
click node_mcp_server "https://github.com/alphabet-h/grooveseek/blob/main/grooveseek/src/server.rs"
click node_search_handler "https://github.com/alphabet-h/grooveseek/blob/main/grooveseek/src/server/search.rs"
click node_document_handler "https://github.com/alphabet-h/grooveseek/blob/main/grooveseek/src/server/documents.rs"
click node_stdio "https://github.com/alphabet-h/grooveseek/blob/main/grooveseek/src/transport/stdio.rs"
click node_http "https://github.com/alphabet-h/grooveseek/blob/main/grooveseek/src/transport/http.rs"
click node_watcher "https://github.com/alphabet-h/grooveseek/blob/main/grooveseek/src/watcher.rs"
click node_graph "https://github.com/alphabet-h/grooveseek/blob/main/grooveseek/src/graph.rs"
click node_service "https://github.com/alphabet-h/grooveseek/blob/main/grooveseek/src/service/mod.rs"
click node_windows_companion "https://github.com/alphabet-h/grooveseek/blob/main/crates/groove-tray/src/daemon.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_library,node_config,node_schema toneBlue
class node_indexer,node_parser_registry,node_embedder toneAmber
class node_sqlite,node_query_compiler,node_hybrid_search,node_ranking toneMint
class node_mcp_server,node_search_handler,node_document_handler,node_stdio,node_http toneRose
class node_watcher,node_graph,node_service,node_windows_companion toneIndigo
```

## Components

### Core CLI & config

- [groove CLI](https://github.com/alphabet-h/grooveseek/blob/main/grooveseek/src/main.rs): Rust binary · Coordinates index, search, serve, validation, evaluation, and service commands. · `grooveseek/src/main.rs`
- [Core library](https://github.com/alphabet-h/grooveseek/blob/main/grooveseek/src/lib.rs): Rust library · `grooveseek/src/lib.rs`
- [Configuration](https://github.com/alphabet-h/grooveseek/blob/main/grooveseek/src/config.rs): config discovery · Resolves KB paths, models, storage, transport, and schema settings. · `grooveseek/src/config.rs`
- [Schema validation](https://github.com/alphabet-h/grooveseek/blob/main/grooveseek/src/schema.rs): schema compatibility · `grooveseek/src/schema.rs`

### Index construction

- [Index orchestrator](https://github.com/alphabet-h/grooveseek/blob/main/grooveseek/src/indexer.rs): ingestion pipeline · Walks knowledge bases, chunks content, and writes index records. · `grooveseek/src/indexer.rs`
- [Parser registry](https://github.com/alphabet-h/grooveseek/blob/main/grooveseek/src/parser/registry.rs): format dispatch · Selects format parsers and isolates parser failures. · `grooveseek/src/parser/registry.rs`
- [ONNX embedder](https://github.com/alphabet-h/grooveseek/blob/main/grooveseek/src/embedder.rs): embedding runtime · Loads selected models, downloading them on first use. · `grooveseek/src/embedder.rs`

### Storage & retrieval

- [SQLite retrieval index](https://github.com/alphabet-h/grooveseek/blob/main/grooveseek/src/db/storage.rs): durable hybrid store · Stores documents, chunks, FTS data, and sqlite-vec vectors. · `grooveseek/src/db/storage.rs`
- [FTS query compiler](https://github.com/alphabet-h/grooveseek/blob/main/grooveseek/src/db/fts_query.rs): lexical query compiler · `grooveseek/src/db/fts_query.rs`
- [Hybrid retrieval](https://github.com/alphabet-h/grooveseek/blob/main/grooveseek/src/db/search.rs): search access · Combines lexical FTS and semantic vector candidates. · `grooveseek/src/db/search.rs`
- [Ranking & context](https://github.com/alphabet-h/grooveseek/blob/main/grooveseek/src/mmr.rs): post-retrieval pipeline · Diversifies results and expands parent context. · `grooveseek/src/mmr.rs`

### MCP server & transports

- [MCP server](https://github.com/alphabet-h/grooveseek/blob/main/grooveseek/src/server.rs): request orchestration · Exposes tools, prompts, and kb:// resources. · `grooveseek/src/server.rs`
- [Search handler](https://github.com/alphabet-h/grooveseek/blob/main/grooveseek/src/server/search.rs): MCP handler · `grooveseek/src/server/search.rs`
- [Document resources](https://github.com/alphabet-h/grooveseek/blob/main/grooveseek/src/server/documents.rs): MCP resource handler · `grooveseek/src/server/documents.rs`
- [stdio MCP transport](https://github.com/alphabet-h/grooveseek/blob/main/grooveseek/src/transport/stdio.rs): transport adapter · `grooveseek/src/transport/stdio.rs`
- [Streamable HTTP](https://github.com/alphabet-h/grooveseek/blob/main/grooveseek/src/transport/http.rs): transport adapter · Serves multi-client MCP and the protected operator UI. · `grooveseek/src/transport/http.rs`

### Operations & host integration

- [Filesystem watcher](https://github.com/alphabet-h/grooveseek/blob/main/grooveseek/src/watcher.rs): live synchronization · Incrementally refreshes the index after content changes. · `grooveseek/src/watcher.rs`
- [Connection graph](https://github.com/alphabet-h/grooveseek/blob/main/grooveseek/src/graph.rs): link graph retrieval · `grooveseek/src/graph.rs`
- [Background service installer](https://github.com/alphabet-h/grooveseek/blob/main/grooveseek/src/service/mod.rs): host integration · `grooveseek/src/service/mod.rs`
- [Windows daemon & tray](https://github.com/alphabet-h/grooveseek/blob/main/crates/groove-tray/src/daemon.rs): Windows lifecycle · Companion binaries manage Windows daemon and tray lifecycle. · `crates/groove-tray/src/daemon.rs`

## Connections

- groove CLI → Core library: invokes
- Core library → Configuration: loads
- groove CLI → Schema validation: validates
- groove CLI → Index orchestrator: index command
- Index orchestrator → Parser registry: parses files
- Index orchestrator → ONNX embedder: embeds chunks
- Index orchestrator → SQLite retrieval index: writes records
- ONNX embedder → SQLite retrieval index: writes vectors
- groove CLI → Hybrid retrieval: search command
- FTS query compiler → Hybrid retrieval: compiles lexical query
- Hybrid retrieval → SQLite retrieval index: queries FTS and vectors
- Hybrid retrieval → Ranking & context: candidate results
- groove CLI → MCP server: serve command
- stdio MCP transport → MCP server: MCP requests
- Streamable HTTP → MCP server: HTTP requests
- MCP server → Search handler: search tool
- MCP server → Document resources: kb resources
- Search handler → Hybrid retrieval: retrieves
- Filesystem watcher → Index orchestrator: incremental reindex
- groove CLI → Connection graph: graph command
- groove CLI → Background service installer: service command
- Background service installer → Windows daemon & tray: Windows lifecycle
