# root0ne/gguf-radar architecture

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

- Interactive diagram: https://gitdiagram.com/root0ne/gguf-radar
- Repository: https://github.com/root0ne/gguf-radar

## Overview

GGUF Radar is a zero-execution model-security scanner. Users scan local GGUF files or Hugging Face repositories, inspect verdicts for container anomalies and poisoned templates, compare a GGUF template with its source model, or sanitize a GGUF into a clean copy. Its core stages are remote/local scanning, GGUF forensics, static template analysis, and optional CDR reconstruction. The source index supports the main module relationships; unsampled details and the YARA rules’ runtime integration are not inferred.

Main entry points: [`src/gguf_radar/hf_scanner.py`](https://github.com/Root0ne/gguf-radar/blob/main/src/gguf_radar/hf_scanner.py) (Hugging Face scanner), [`src/gguf_radar/cli.py`](https://github.com/Root0ne/gguf-radar/blob/main/src/gguf_radar/cli.py) (CLI commands), [`src/gguf_radar/compare_template.py`](https://github.com/Root0ne/gguf-radar/blob/main/src/gguf_radar/compare_template.py) (Template comparison), [`src/gguf_radar/template_ast.py`](https://github.com/Root0ne/gguf-radar/blob/main/src/gguf_radar/template_ast.py) (Template auditor)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["User interface"]
  node_cli["CLI commands<br/>[cli.py]"]
  node_safe_text["Safe output text<br/>[safe_text.py]"]
end

subgraph group_scan["Scanning"]
  node_hf_scanner["Hugging Face scanner<br/>[hf_scanner.py]"]
end

subgraph group_analysis["Analysis"]
  node_gguf_parser["GGUF forensics<br/>[parser.py]"]
  node_template_ast["Template auditor<br/>[template_ast.py]"]
  node_unused_tokens["Unused-token checks<br/>[unused_tokens.py]"]
  node_known_templates[("Known-template families<br/>[known_templates.py]")]
  node_yara_rules["Supply-chain rules"]
end

subgraph group_remediation["Comparison and repair"]
  node_template_compare["Template comparison"]
  node_cdr["GGUF sanitization<br/>[cdr.py]"]
end

node_user(("Model owner"))
node_hugging_face[("Hugging Face")]
node_model_files["Model files"]

node_user -->|"runs commands"| node_cli
node_cli -->|"scans targets"| node_hf_scanner
node_cli -->|"compares templates"| node_template_compare
node_cli -->|"sanitizes GGUF"| node_cdr
node_cli -->|"escapes output"| node_safe_text
node_hf_scanner -->|"reads remote files"| node_hugging_face
node_model_files -->|"provides scan input"| node_hf_scanner
node_hf_scanner -->|"parses GGUF"| node_gguf_parser
node_hf_scanner -->|"audits templates"| node_template_ast
node_hf_scanner -->|"checks token types"| node_unused_tokens
node_gguf_parser -->|"checks tokenizer arrays"| node_unused_tokens
node_template_ast -->|"recognizes families"| node_known_templates
node_template_ast -->|"escapes findings"| node_safe_text
node_template_compare -->|"reads source model"| node_hugging_face
node_template_compare -->|"reads GGUF metadata"| node_gguf_parser
node_template_compare -->|"analyzes templates"| node_template_ast
node_cdr -->|"parses input"| node_gguf_parser
node_model_files -->|"supplies GGUF"| node_cdr
node_cdr -->|"writes clean copy"| node_model_files

click node_cli "https://github.com/Root0ne/gguf-radar/blob/main/src/gguf_radar/cli.py"
click node_safe_text "https://github.com/Root0ne/gguf-radar/blob/main/src/gguf_radar/safe_text.py"
click node_hf_scanner "https://github.com/Root0ne/gguf-radar/blob/main/src/gguf_radar/hf_scanner.py"
click node_gguf_parser "https://github.com/Root0ne/gguf-radar/blob/main/src/gguf_radar/parser.py"
click node_template_ast "https://github.com/Root0ne/gguf-radar/blob/main/src/gguf_radar/template_ast.py"
click node_unused_tokens "https://github.com/Root0ne/gguf-radar/blob/main/src/gguf_radar/unused_tokens.py"
click node_known_templates "https://github.com/Root0ne/gguf-radar/blob/main/src/gguf_radar/known_templates.py"
click node_yara_rules "https://github.com/Root0ne/gguf-radar/blob/main/rules/gguf_supply_chain_threats.yar"
click node_template_compare "https://github.com/Root0ne/gguf-radar/blob/main/src/gguf_radar/compare_template.py"
click node_cdr "https://github.com/Root0ne/gguf-radar/blob/main/src/gguf_radar/cdr.py"

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_safe_text toneBlue
class node_hf_scanner,node_hugging_face toneAmber
class node_gguf_parser,node_template_ast,node_unused_tokens,node_known_templates,node_yara_rules toneMint
class node_template_compare,node_cdr toneRose
class node_user,node_model_files toneIndigo
```

## Components

### User interface

- [CLI commands](https://github.com/Root0ne/gguf-radar/blob/main/src/gguf_radar/cli.py): `src/gguf_radar/cli.py`
- [Safe output text](https://github.com/Root0ne/gguf-radar/blob/main/src/gguf_radar/safe_text.py): `src/gguf_radar/safe_text.py`

### Scanning

- [Hugging Face scanner](https://github.com/Root0ne/gguf-radar/blob/main/src/gguf_radar/hf_scanner.py): `src/gguf_radar/hf_scanner.py`

### Analysis

- [GGUF forensics](https://github.com/Root0ne/gguf-radar/blob/main/src/gguf_radar/parser.py): `src/gguf_radar/parser.py`
- [Template auditor](https://github.com/Root0ne/gguf-radar/blob/main/src/gguf_radar/template_ast.py): `src/gguf_radar/template_ast.py`
- [Unused-token checks](https://github.com/Root0ne/gguf-radar/blob/main/src/gguf_radar/unused_tokens.py): `src/gguf_radar/unused_tokens.py`
- [Known-template families](https://github.com/Root0ne/gguf-radar/blob/main/src/gguf_radar/known_templates.py): `src/gguf_radar/known_templates.py`
- [Supply-chain rules](https://github.com/Root0ne/gguf-radar/blob/main/rules/gguf_supply_chain_threats.yar): `rules/gguf_supply_chain_threats.yar`

### Comparison and repair

- [Template comparison](https://github.com/Root0ne/gguf-radar/blob/main/src/gguf_radar/compare_template.py): `src/gguf_radar/compare_template.py`
- [GGUF sanitization](https://github.com/Root0ne/gguf-radar/blob/main/src/gguf_radar/cdr.py): `src/gguf_radar/cdr.py`

### Other components

- **Model owner**
- **Hugging Face**
- **Model files**

## Connections

- Model owner → CLI commands: runs commands (evidence: `README.md`)
- CLI commands → Hugging Face scanner: scans targets (evidence: `src/gguf_radar/cli.py`)
- CLI commands → Template comparison: compares templates (evidence: `src/gguf_radar/cli.py`)
- CLI commands → GGUF sanitization: sanitizes GGUF (evidence: `src/gguf_radar/cli.py`)
- CLI commands → Safe output text: escapes output (evidence: `src/gguf_radar/cli.py`)
- Hugging Face scanner → Hugging Face: reads remote files (evidence: `README.md`)
- Model files → Hugging Face scanner: provides scan input (evidence: `README.md`)
- Hugging Face scanner → GGUF forensics: parses GGUF (evidence: `src/gguf_radar/hf_scanner.py`)
- Hugging Face scanner → Template auditor: audits templates (evidence: `src/gguf_radar/hf_scanner.py`)
- Hugging Face scanner → Unused-token checks: checks token types (evidence: `src/gguf_radar/hf_scanner.py`)
- GGUF forensics → Unused-token checks: checks tokenizer arrays (evidence: `src/gguf_radar/parser.py`)
- Template auditor → Known-template families: recognizes families (evidence: `src/gguf_radar/template_ast.py`)
- Template auditor → Safe output text: escapes findings (evidence: `src/gguf_radar/template_ast.py`)
- Template comparison → Hugging Face: reads source model (evidence: `README.md`)
- Template comparison → GGUF forensics: reads GGUF metadata (evidence: `src/gguf_radar/compare_template.py`)
- Template comparison → Template auditor: analyzes templates (evidence: `src/gguf_radar/compare_template.py`)
- GGUF sanitization → GGUF forensics: parses input (evidence: `src/gguf_radar/cdr.py`)
- Model files → GGUF sanitization: supplies GGUF (evidence: `README.md`)
- GGUF sanitization → Model files: writes clean copy (evidence: `README.md`)
