# anonymmized/kard architecture

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

- Interactive diagram: https://gitdiagram.com/anonymmized/kard
- Repository: https://github.com/anonymmized/kard

## Overview

KARD is a terminal-based system-monitoring assistant. Its main workflow reads a user request, asks the Ollama-backed brain, dispatches metric tools, and presents text and metrics in the terminal, with optional voice output. Separate command modes manage a snapshot daemon and perform updates. The README gives no capability details beyond the product name, so these branches are based on the source index and excerpts; some platform-specific and terminal-rendering links remain unverified.

Main entry points: [`core/kardcore.cpp`](https://github.com/anonymmized/kard/blob/main/core/kardcore.cpp) (KARD core), [`selfupdate/selfUpdate.cpp`](https://github.com/anonymmized/kard/blob/main/selfupdate/selfUpdate.cpp) (Updater), [`brain/OllamaBrain.cpp`](https://github.com/anonymmized/kard/blob/main/brain/OllamaBrain.cpp) (Ollama brain), [`brain/ToolRegistry.cpp`](https://github.com/anonymmized/kard/blob/main/brain/ToolRegistry.cpp) (Tool registry)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_app["Application flow"]
  node_core["KARD core<br/>[kardcore.cpp]"]
  node_args["Argument parser<br/>[argsParse.cpp]"]
  node_brain["Ollama brain<br/>[OllamaBrain.cpp]"]
  node_tools["Tool registry<br/>[ToolRegistry.cpp]"]
end

subgraph group_metrics["Monitoring and snapshots"]
  node_collector["Metric collector"]
  node_host["Host metrics<br/>[monitor.cpp]"]
  node_platform["Platform metrics"]
  node_docker["Docker metrics<br/>[dockerMetrics.cpp]"]
  node_snapshots[("Snapshot log<br/>[snapshot_log.cpp]")]
end

subgraph group_terminal["Terminal interface"]
  node_input["Terminal input<br/>[TerminalInput.cpp]"]
  node_output["Terminal output<br/>[TerminalOutput.cpp]"]
  node_render["Terminal rendering<br/>[Render.cpp]"]
  node_voice["Voice output<br/>[voice.cpp]"]
end

subgraph group_ops["Daemon and updates"]
  node_scheduler["Snapshot scheduler"]
  node_snapshotjob["Snapshot executable<br/>[snapshot_main.cpp]"]
  node_updater["Updater<br/>[selfUpdate.cpp]"]
  node_updatepaths["Update paths<br/>[updatePaths.cpp]"]
  node_updatecommands["Update commands<br/>[commandBuilder.cpp]"]
  node_commandrunner["Command runner<br/>[commandRunner.hpp]"]
  node_fileops["Update file operations<br/>[fileOps.cpp]"]
end

subgraph group_integrations["External integrations"]
  node_ollama{{"Ollama service"}}
end

node_user(("User"))

node_user -->|"enters request"| node_input
node_input -.->|"provides text"| node_core
node_core -->|"parses arguments"| node_args
node_core -->|"reads input"| node_input
node_core -->|"asks question"| node_brain
node_brain -.->|"queries model"| node_ollama
node_brain -->|"runs tool calls"| node_tools
node_tools -->|"dispatches metrics"| node_collector
node_collector -->|"collects host data"| node_host
node_collector -->|"collects Docker data"| node_docker
node_host -.->|"uses platform metrics"| node_platform
node_tools -->|"appends snapshots"| node_snapshots
node_core -->|"shows answer"| node_output
node_output -->|"appends display text"| node_render
node_core -->|"selects voice output"| node_voice
node_output -->|"forwards output"| node_voice
node_core -->|"manages daemon"| node_scheduler
node_scheduler -.->|"schedules snapshots"| node_snapshotjob
node_snapshotjob -.->|"records snapshots"| node_snapshots
node_core -->|"runs updates"| node_updater
node_updater -->|"loads paths"| node_updatepaths
node_updater -->|"builds commands"| node_updatecommands
node_updater -->|"executes commands"| node_commandrunner
node_updater -->|"changes files"| node_fileops

click node_core "https://github.com/anonymmized/kard/blob/main/core/kardcore.cpp"
click node_args "https://github.com/anonymmized/kard/blob/main/core/argsParse.cpp"
click node_brain "https://github.com/anonymmized/kard/blob/main/brain/OllamaBrain.cpp"
click node_tools "https://github.com/anonymmized/kard/blob/main/brain/ToolRegistry.cpp"
click node_input "https://github.com/anonymmized/kard/blob/main/terminal/TerminalInput.cpp"
click node_output "https://github.com/anonymmized/kard/blob/main/terminal/TerminalOutput.cpp"
click node_render "https://github.com/anonymmized/kard/blob/main/terminal/render/Render.cpp"
click node_voice "https://github.com/anonymmized/kard/blob/main/voice/voice.cpp"
click node_collector "https://github.com/anonymmized/kard/blob/main/body/monitoring/MetricCollector.cpp"
click node_host "https://github.com/anonymmized/kard/blob/main/body/monitoring/monitor.cpp"
click node_platform "https://github.com/anonymmized/kard/tree/main/body/monitoring"
click node_docker "https://github.com/anonymmized/kard/blob/main/body/monitoring/dockerMetrics.cpp"
click node_snapshots "https://github.com/anonymmized/kard/blob/main/body/snapshot_log.cpp"
click node_scheduler "https://github.com/anonymmized/kard/tree/main/body/scheduler"
click node_snapshotjob "https://github.com/anonymmized/kard/blob/main/body/snapshot_main.cpp"
click node_updater "https://github.com/anonymmized/kard/blob/main/selfupdate/selfUpdate.cpp"
click node_updatepaths "https://github.com/anonymmized/kard/blob/main/selfupdate/updatePaths.cpp"
click node_updatecommands "https://github.com/anonymmized/kard/blob/main/selfupdate/commandBuilder.cpp"
click node_commandrunner "https://github.com/anonymmized/kard/blob/main/selfupdate/commandRunner.hpp"
click node_fileops "https://github.com/anonymmized/kard/blob/main/selfupdate/fileOps.cpp"

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_core,node_args,node_brain,node_tools,node_user toneBlue
class node_collector,node_host,node_platform,node_docker,node_snapshots toneAmber
class node_input,node_output,node_render,node_voice toneMint
class node_scheduler,node_snapshotjob,node_updater,node_updatepaths,node_updatecommands,node_commandrunner,node_fileops toneRose
class node_ollama toneIndigo
```

## Components

### Application flow

- [KARD core](https://github.com/anonymmized/kard/blob/main/core/kardcore.cpp): `core/kardcore.cpp`
- [Argument parser](https://github.com/anonymmized/kard/blob/main/core/argsParse.cpp): `core/argsParse.cpp`
- [Ollama brain](https://github.com/anonymmized/kard/blob/main/brain/OllamaBrain.cpp): `brain/OllamaBrain.cpp`
- [Tool registry](https://github.com/anonymmized/kard/blob/main/brain/ToolRegistry.cpp): `brain/ToolRegistry.cpp`

### Monitoring and snapshots

- [Metric collector](https://github.com/anonymmized/kard/blob/main/body/monitoring/MetricCollector.cpp): `body/monitoring/MetricCollector.cpp`
- [Host metrics](https://github.com/anonymmized/kard/blob/main/body/monitoring/monitor.cpp): `body/monitoring/monitor.cpp`
- [Platform metrics](https://github.com/anonymmized/kard/tree/main/body/monitoring): `body/monitoring`
- [Docker metrics](https://github.com/anonymmized/kard/blob/main/body/monitoring/dockerMetrics.cpp): `body/monitoring/dockerMetrics.cpp`
- [Snapshot log](https://github.com/anonymmized/kard/blob/main/body/snapshot_log.cpp): `body/snapshot_log.cpp`

### Terminal interface

- [Terminal input](https://github.com/anonymmized/kard/blob/main/terminal/TerminalInput.cpp): `terminal/TerminalInput.cpp`
- [Terminal output](https://github.com/anonymmized/kard/blob/main/terminal/TerminalOutput.cpp): `terminal/TerminalOutput.cpp`
- [Terminal rendering](https://github.com/anonymmized/kard/blob/main/terminal/render/Render.cpp): `terminal/render/Render.cpp`
- [Voice output](https://github.com/anonymmized/kard/blob/main/voice/voice.cpp): `voice/voice.cpp`

### Daemon and updates

- [Snapshot scheduler](https://github.com/anonymmized/kard/tree/main/body/scheduler): `body/scheduler`
- [Snapshot executable](https://github.com/anonymmized/kard/blob/main/body/snapshot_main.cpp): `body/snapshot_main.cpp`
- [Updater](https://github.com/anonymmized/kard/blob/main/selfupdate/selfUpdate.cpp): `selfupdate/selfUpdate.cpp`
- [Update paths](https://github.com/anonymmized/kard/blob/main/selfupdate/updatePaths.cpp): `selfupdate/updatePaths.cpp`
- [Update commands](https://github.com/anonymmized/kard/blob/main/selfupdate/commandBuilder.cpp): `selfupdate/commandBuilder.cpp`
- [Command runner](https://github.com/anonymmized/kard/blob/main/selfupdate/commandRunner.hpp): `selfupdate/commandRunner.hpp`
- [Update file operations](https://github.com/anonymmized/kard/blob/main/selfupdate/fileOps.cpp): `selfupdate/fileOps.cpp`

### External integrations

- **Ollama service**

### Other components

- **User**

## Connections

- User → Terminal input: enters request
- Terminal input → KARD core: provides text
- KARD core → Argument parser: parses arguments (evidence: `core/kardcore.cpp`)
- KARD core → Terminal input: reads input (evidence: `core/kardcore.cpp`)
- KARD core → Ollama brain: asks question (evidence: `core/kardcore.cpp`)
- Ollama brain → Ollama service: queries model
- Ollama brain → Tool registry: runs tool calls (evidence: `brain/OllamaBrain.cpp`)
- Tool registry → Metric collector: dispatches metrics (evidence: `brain/ToolRegistry.cpp`)
- Metric collector → Host metrics: collects host data (evidence: `body/monitoring/MetricCollector.cpp`)
- Metric collector → Docker metrics: collects Docker data (evidence: `body/monitoring/MetricCollector.cpp`)
- Host metrics → Platform metrics: uses platform metrics (evidence: `body/monitoring/monitor.cpp`)
- Tool registry → Snapshot log: appends snapshots (evidence: `brain/ToolRegistry.cpp`)
- KARD core → Terminal output: shows answer (evidence: `core/kardcore.cpp`)
- Terminal output → Terminal rendering: appends display text (evidence: `terminal/TerminalOutput.cpp`)
- KARD core → Voice output: selects voice output (evidence: `core/kardcore.cpp`)
- Terminal output → Voice output: forwards output (evidence: `terminal/TerminalOutput.cpp`)
- KARD core → Snapshot scheduler: manages daemon (evidence: `core/kardcore.cpp`)
- Snapshot scheduler → Snapshot executable: schedules snapshots
- Snapshot executable → Snapshot log: records snapshots
- KARD core → Updater: runs updates (evidence: `core/kardcore.cpp`)
- Updater → Update paths: loads paths (evidence: `selfupdate/selfUpdate.cpp`)
- Updater → Update commands: builds commands (evidence: `selfupdate/selfUpdate.cpp`)
- Updater → Command runner: executes commands (evidence: `selfupdate/selfUpdate.cpp`)
- Updater → Update file operations: changes files (evidence: `selfupdate/selfUpdate.cpp`)
