# newsand/beholder architecture

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

- Interactive diagram: https://gitdiagram.com/newsand/beholder
- Repository: https://github.com/newsand/beholder

## Overview

Beholder is a Linux process and NVIDIA VRAM monitor with two entry modes: an egui dashboard and an MCP stdio server. Both let users select targets and inspect collected metrics; sampling gathers RAM/CPU and optional process VRAM, while the GUI and MCP expose history, window statistics, and export. The graph groups the interfaces, target discovery, metric acquisition, and history. Some wiring is supported by imports and the SOURCE INDEX rather than complete excerpts; those limits are reflected by omitting uncertain links.

Main entry points: [`crates/app/src/app.rs`](https://github.com/newsand/beholder/blob/main/crates/app/src/app.rs) (Dashboard), [`crates/app/src/main.rs`](https://github.com/newsand/beholder/blob/main/crates/app/src/main.rs) (Mode Entry), [`crates/core/src/mcp.rs`](https://github.com/newsand/beholder/blob/main/crates/core/src/mcp.rs) (MCP Server), [`crates/core/src/buffer.rs`](https://github.com/newsand/beholder/blob/main/crates/core/src/buffer.rs) (Time-Series Buffer)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_interfaces["User Interfaces"]
  node_entry["Mode Entry<br/>[main.rs]"]
  node_dashboard["Dashboard<br/>[app.rs]"]
  node_mcp["MCP Server<br/>[mcp.rs]"]
end

subgraph group_targets["Target Management"]
  node_target_manager["Target Manager<br/>[targets.rs]"]
  node_procfs["Linux Process Data"]
end

subgraph group_telemetry["Metric Acquisition"]
  node_sampler["Process Sampler<br/>[sampler.rs]"]
  node_nvml["NVML Wrapper<br/>[nvml.rs]"]
  node_models["Metric Models<br/>[model.rs]"]
end

subgraph group_history["History and Export"]
  node_buffer[("Time-Series Buffer<br/>[buffer.rs]")]
  node_gui_export["GUI Export<br/>[app.rs]"]
  node_mcp_export["MCP Tools and Export<br/>[mcp.rs]"]
end

node_user(("Desktop User"))
node_agent(("MCP Client"))
node_gpu["NVIDIA GPU"]

node_user -->|"launches"| node_entry
node_agent -->|"sends stdio requests"| node_entry
node_entry -->|"starts GUI"| node_dashboard
node_entry -->|"starts headless server"| node_mcp
node_dashboard -->|"manages targets"| node_target_manager
node_mcp -->|"manages targets"| node_target_manager
node_target_manager -->|"reads process info"| node_procfs
node_dashboard -->|"samples PIDs"| node_sampler
node_sampler -->|"queries process VRAM"| node_nvml
node_entry -->|"initializes optionally"| node_nvml
node_nvml -.->|"queries GPU memory"| node_gpu
node_sampler -->|"produces samples"| node_models
node_dashboard -->|"reads and clears history"| node_buffer
node_mcp -->|"reads and manages history"| node_buffer
node_dashboard -->|"exports CSV or JSON"| node_gui_export
node_mcp -->|"dispatches export tools"| node_mcp_export
node_gui_export -->|"reads samples"| node_buffer
node_mcp_export -->|"reads samples"| node_buffer

click node_entry "https://github.com/newsand/beholder/blob/main/crates/app/src/main.rs"
click node_dashboard "https://github.com/newsand/beholder/blob/main/crates/app/src/app.rs"
click node_mcp "https://github.com/newsand/beholder/blob/main/crates/core/src/mcp.rs"
click node_target_manager "https://github.com/newsand/beholder/blob/main/crates/core/src/targets.rs"
click node_sampler "https://github.com/newsand/beholder/blob/main/crates/core/src/sampler.rs"
click node_nvml "https://github.com/newsand/beholder/blob/main/crates/core/src/nvml.rs"
click node_models "https://github.com/newsand/beholder/blob/main/crates/core/src/model.rs"
click node_buffer "https://github.com/newsand/beholder/blob/main/crates/core/src/buffer.rs"
click node_gui_export "https://github.com/newsand/beholder/blob/main/crates/app/src/app.rs"
click node_mcp_export "https://github.com/newsand/beholder/blob/main/crates/core/src/mcp.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_entry,node_dashboard,node_mcp,node_user,node_agent toneBlue
class node_target_manager,node_procfs toneAmber
class node_sampler,node_nvml,node_models toneMint
class node_buffer,node_gui_export,node_mcp_export toneRose
class node_gpu toneIndigo
```

## Components

### User Interfaces

- [Mode Entry](https://github.com/newsand/beholder/blob/main/crates/app/src/main.rs): `crates/app/src/main.rs`
- [Dashboard](https://github.com/newsand/beholder/blob/main/crates/app/src/app.rs): `crates/app/src/app.rs`
- [MCP Server](https://github.com/newsand/beholder/blob/main/crates/core/src/mcp.rs): `crates/core/src/mcp.rs`

### Target Management

- [Target Manager](https://github.com/newsand/beholder/blob/main/crates/core/src/targets.rs): `crates/core/src/targets.rs`
- **Linux Process Data**

### Metric Acquisition

- [Process Sampler](https://github.com/newsand/beholder/blob/main/crates/core/src/sampler.rs): `crates/core/src/sampler.rs`
- [NVML Wrapper](https://github.com/newsand/beholder/blob/main/crates/core/src/nvml.rs): `crates/core/src/nvml.rs`
- [Metric Models](https://github.com/newsand/beholder/blob/main/crates/core/src/model.rs): `crates/core/src/model.rs`

### History and Export

- [Time-Series Buffer](https://github.com/newsand/beholder/blob/main/crates/core/src/buffer.rs): `crates/core/src/buffer.rs`
- [GUI Export](https://github.com/newsand/beholder/blob/main/crates/app/src/app.rs): `crates/app/src/app.rs`
- [MCP Tools and Export](https://github.com/newsand/beholder/blob/main/crates/core/src/mcp.rs): `crates/core/src/mcp.rs`

### Other components

- **Desktop User**
- **MCP Client**
- **NVIDIA GPU**

## Connections

- Desktop User → Mode Entry: launches (evidence: `README.md`)
- MCP Client → Mode Entry: sends stdio requests (evidence: `README.md`)
- Mode Entry → Dashboard: starts GUI (evidence: `crates/app/src/main.rs`)
- Mode Entry → MCP Server: starts headless server (evidence: `crates/app/src/main.rs`)
- Dashboard → Target Manager: manages targets (evidence: `crates/app/src/app.rs`)
- MCP Server → Target Manager: manages targets (evidence: `crates/core/src/mcp.rs`)
- Target Manager → Linux Process Data: reads process info (evidence: `crates/core/src/targets.rs`)
- Dashboard → Process Sampler: samples PIDs (evidence: `crates/app/src/app.rs`)
- Process Sampler → NVML Wrapper: queries process VRAM (evidence: `crates/core/src/sampler.rs`)
- Mode Entry → NVML Wrapper: initializes optionally (evidence: `crates/app/src/main.rs`)
- NVML Wrapper → NVIDIA GPU: queries GPU memory (evidence: `README.md`)
- Process Sampler → Metric Models: produces samples (evidence: `crates/core/src/sampler.rs`)
- Dashboard → Time-Series Buffer: reads and clears history (evidence: `crates/app/src/app.rs`)
- MCP Server → Time-Series Buffer: reads and manages history (evidence: `crates/core/src/mcp.rs`)
- Dashboard → GUI Export: exports CSV or JSON (evidence: `crates/app/src/app.rs`)
- MCP Server → MCP Tools and Export: dispatches export tools (evidence: `crates/core/src/mcp.rs`)
- GUI Export → Time-Series Buffer: reads samples (evidence: `crates/app/src/app.rs`)
- MCP Tools and Export → Time-Series Buffer: reads samples (evidence: `crates/core/src/mcp.rs`)
