Skip to content

Architecture

Pipeline for both modes (filter and TUI):

scan → parse → query → search → output/tui
PackageResponsibilityKey API
internal/scan*.md discovery, sortedWalkMarkdown(Options) ([]string, error) — see Scan
internal/parsefrontmatter split + YAML + normalizers → DocumentParseFile, ParseContent, SplitFrontmatter
internal/modelUnified Document contract + SearchBlobDocument, BuildSearchBlob, FlattenScalars — see Frontmatter Model
internal/queryTokenizer + Query AST + date-range parserParse(input) (*Query, error) — see Query Syntax
internal/searchHard-filter (MatchesDoc) + fuzzy Rank + FilterArchivedRank, MatchesDoc — see Search & Ranking
internal/tuiBubbleTea picker, FilterFunc hookRun, NewModel, SetFilter — see TUI
internal/outputpaths/json/vimgrep formatters + SnippetFormatPaths/JSON/Vimgrep — see CLI
cmd/mdfuFlags, runFilter / runTUI wiringmain.go, filter.go

internal/tui never imports internal/search/internal/query; integration injects tui.SetFilter(buildFilterFunc()) in cmd/mdfu.

  • Single static Go binary, no daemon, no cgo by default.
  • No persistent index (see Backend Evaluation for the evaluated exception path).
  • Deps: gopkg.in/yaml.v3, charmbracelet/bubbletea+bubbles+lipgloss, sahilm/fuzzy, stdlib rest.
  • 5–10k files: cold scan+parse <500ms, per-keystroke query+rank <50ms.
  • Current risk: search.scoreDoc runs fuzzy.Find per doc per bare word against the whole SearchBlob — O(docs × words). See Search & Ranking and the Roadmap tasks.