# kh3rld/rfgrep architecture

> Architecture diagram of the GitHub repository kh3rld/rfgrep, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-09-26). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/kh3rld/rfgrep
- Repository: https://github.com/kh3rld/rfgrep

## Overview

##### Project type and purpose
- Project type: Open-source command-line utility (Rust CLI tool).
- Purpose: Recursively search and list files with advanced filtering, output formatting, interactive TUI, plugin support, and high performance.

##### File structure
- Top-level Rust project: Cargo.toml, src/, benches/, tests/, scripts/, man/.
- src/ folder contains:
- CLI entrypoint (main.rs, cli.rs, app.rs)
- Core logic: processor.rs, walker.rs, search/, list/, interactive/, streaming_search.rs
- Supporting infrastructure: config.rs, error.rs, metrics.rs, progress.rs
- Performance modules: performance/ (cache_manager, memory_pool, parallel_processor, optimized_mmap, zero_copy, io_optimizer)
- Output modules: output/ (formatter, formats, output_formats)
- Plugin support: plugin_system.rs, plugin_cli.rs, search/plugins.rs
- Test utilities: test_utils/
- Build & deployment: Dockerfile, scripts/*, snap/, man/, .github workflows, packaging docs.

##### Insights from README
- Features broken into “Advanced Search,” “File Listing,” “Utilities,” “Interactive Mode,” “Output Formats,” “Search Algorithms.”
- Performance and simulation commands.
- Shell completions, man pages, metrics and logs.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% CLI & UI Layer
    subgraph "CLI & UI" 
        direction TB
        Main["main.rs"]:::cli
        CLIParser["cli.rs"]:::cli
        PluginCLI["plugin_cli.rs"]:::cli
        InteractiveUI["interactive/mod.rs"]:::ui
        TUI["tui.rs"]:::ui
    end

    %% Application Core
    subgraph "Application Core"
        direction TB
        AppOrchestrator["app.rs"]:::core
        AppSimple["app_simple.rs"]:::core
        Config["config.rs"]:::core
        ErrorHandler["error.rs"]:::core
    end

    %% File System Walker
    subgraph "File System"
        direction TB
        Walker["walker.rs"]:::core
        MockFS["mock_file_system.rs"]:::test
    end

    %% Search Engine
    subgraph "Search Engine"
        direction TB
        SearchEngine["engine.rs"]:::core
        Algorithms["algorithms.rs"]:::core
        CacheLayer["cache.rs"]:::core
        StreamingSearch["streaming_search.rs"]:::core
        SearchPlugins["plugins.rs"]:::plugin
    end

    %% Listing Engine
    subgraph "Listing Engine"
        direction TB
        Listing["mod.rs"]:::core
    end

    %% Output Formatter
    subgraph "Output Formatter"
        direction TB
        Formatter["formatter.rs"]:::core
        Formats["formats.rs"]:::core
        OutputMod["mod.rs"]:::core
        OutputFormats["output_formats.rs"]:::core
    end

    %% Performance Subsystem
    subgraph "Performance Subsystem"
        direction TB
        PerfMod["mod.rs"]:::perf
        CacheManager["cache_manager.rs"]:::perf
        MemoryPool["memory_pool.rs"]:::perf
        ParallelProc["parallel_processor.rs"]:::perf
        OptMmap["optimized_mmap.rs"]:::perf
        IOOpt["io_optimizer.rs"]:::perf
        ZeroCopy["zero_copy.rs"]:::perf
    end

    %% Plugin System
    subgraph "Plugin System"
        direction TB
        PluginSystem["plugin_system.rs"]:::plugin
    end

    %% Metrics & Logging
    subgraph "Metrics & Logging"
        direction TB
        Metrics["metrics.rs"]:::external
        Progress["progress.rs"]:::external
    end

    %% Packaging & Deployment
    subgraph "Packaging & Deployment"
        direction TB
        Dockerfile["Dockerfile"]:::external
        Scripts["scripts/"]:::external
        ManPages["man/"]:::external
        Snapcraft["snap/snapcraft.yaml"]:::external
        CI[".github/workflows/"]:::external
    end

    %% External Systems
    FileSystem["File System"]:::external
    User["User"]:::external
    Clipboard["Clipboard"]:::external
    Logger["Logging Subsystem"]:::external

    %% Connections
    User -->|invokes| Main
    Main --> CLIParser
    Main --> PluginCLI
    CLIParser -->|parse commands| AppOrchestrator
    PluginCLI --> AppOrchestrator
    AppOrchestrator --> Config
    AppOrchestrator --> ErrorHandler
    AppOrchestrator --> PerfMod
    PerfMod --> CacheManager
    PerfMod --> MemoryPool
    PerfMod --> ParallelProc
    PerfMod --> OptMmap
    PerfMod --> IOOpt
    PerfMod --> ZeroCopy

    AppOrchestrator --> Walker
    Walker --> FileSystem
    Walker --> MockFS

    Walker --> SearchEngine
    Walker --> Listing

    SearchEngine --> Algorithms
    SearchEngine --> CacheLayer
    SearchEngine --> ParallelProc
    SearchEngine --> StreamingSearch
    SearchEngine --> SearchPlugins

    Listing --> Listing

    SearchEngine --> Formatter
    Listing --> Formatter

    Formatter --> Formats
    Formatter --> OutputMod
    Formatter --> OutputFormats
    Formatter --> User

    InteractiveUI --> SearchEngine
    InteractiveUI --> TUI
    TUI --> User

    PluginSystem --> CLIParser
    PluginSystem --> SearchEngine

    AppOrchestrator --> Metrics
    AppOrchestrator --> Progress
    Metrics --> Logger
    Progress --> Logger

    User --> Clipboard

    %% Click Events
    click Main "https://github.com/kh3rld/rfgrep/blob/main/src/main.rs"
    click CLIParser "https://github.com/kh3rld/rfgrep/blob/main/src/cli.rs"
    click PluginCLI "https://github.com/kh3rld/rfgrep/blob/main/src/plugin_cli.rs"
    click AppOrchestrator "https://github.com/kh3rld/rfgrep/blob/main/src/app.rs"
    click AppSimple "https://github.com/kh3rld/rfgrep/blob/main/src/app_simple.rs"
    click Config "https://github.com/kh3rld/rfgrep/blob/main/src/config.rs"
    click ErrorHandler "https://github.com/kh3rld/rfgrep/blob/main/src/error.rs"
    click Walker "https://github.com/kh3rld/rfgrep/blob/main/src/walker.rs"
    click MockFS "https://github.com/kh3rld/rfgrep/blob/main/src/test_utils/mock_file_system.rs"
    click SearchEngine "https://github.com/kh3rld/rfgrep/blob/main/src/search/engine.rs"
    click Algorithms "https://github.com/kh3rld/rfgrep/blob/main/src/search/algorithms.rs"
    click CacheLayer "https://github.com/kh3rld/rfgrep/blob/main/src/search/cache.rs"
    click SearchPlugins "https://github.com/kh3rld/rfgrep/blob/main/src/search/plugins.rs"
    click StreamingSearch "https://github.com/kh3rld/rfgrep/blob/main/src/streaming_search.rs"
    click Listing "https://github.com/kh3rld/rfgrep/blob/main/src/list/mod.rs"
    click InteractiveUI "https://github.com/kh3rld/rfgrep/blob/main/src/interactive/mod.rs"
    click TUI "https://github.com/kh3rld/rfgrep/blob/main/src/tui.rs"
    click Formatter "https://github.com/kh3rld/rfgrep/blob/main/src/output/formatter.rs"
    click Formats "https://github.com/kh3rld/rfgrep/blob/main/src/output/formats.rs"
    click OutputMod "https://github.com/kh3rld/rfgrep/blob/main/src/output/mod.rs"
    click OutputFormats "https://github.com/kh3rld/rfgrep/blob/main/src/output_formats.rs"
    click CacheManager "https://github.com/kh3rld/rfgrep/blob/main/src/performance/cache_manager.rs"
    click MemoryPool "https://github.com/kh3rld/rfgrep/blob/main/src/performance/memory_pool.rs"
    click ParallelProc "https://github.com/kh3rld/rfgrep/blob/main/src/performance/parallel_processor.rs"
    click OptMmap "https://github.com/kh3rld/rfgrep/blob/main/src/performance/optimized_mmap.rs"
    click IOOpt "https://github.com/kh3rld/rfgrep/blob/main/src/performance/io_optimizer.rs"
    click ZeroCopy "https://github.com/kh3rld/rfgrep/blob/main/src/performance/zero_copy.rs"
    click PerfMod "https://github.com/kh3rld/rfgrep/blob/main/src/performance/mod.rs"
    click PluginSystem "https://github.com/kh3rld/rfgrep/blob/main/src/plugin_system.rs"
    click Metrics "https://github.com/kh3rld/rfgrep/blob/main/src/metrics.rs"
    click Progress "https://github.com/kh3rld/rfgrep/blob/main/src/progress.rs"
    click Dockerfile "https://github.com/kh3rld/rfgrep/tree/main/Dockerfile"
    click Scripts "https://github.com/kh3rld/rfgrep/tree/main/scripts/"
    click ManPages "https://github.com/kh3rld/rfgrep/tree/main/man/"
    click Snapcraft "https://github.com/kh3rld/rfgrep/blob/main/snap/snapcraft.yaml"
    click CI "https://github.com/kh3rld/rfgrep/tree/main/.github/workflows/"

    %% Styles
    classDef core fill:#cce5ff,stroke:#4a90e2,color:#000;
    classDef perf fill:#d4edda,stroke:#28a745,color:#000;
    classDef cli fill:#ffe5b4,stroke:#ff8c00,color:#000;
    classDef ui fill:#ffe5b4,stroke:#ff8c00,color:#000;
    classDef plugin fill:#f3e5ff,stroke:#9b59b6,color:#000;
    classDef external fill:#e2e3e5,stroke:#6c757d,color:#000;
    classDef test fill:#f8d7da,stroke:#dc3545,color:#000
```
