# ppgamerer/llm_scanner architecture

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

- Interactive diagram: https://gitdiagram.com/ppgamerer/llm_scanner
- Repository: https://github.com/ppgamerer/llm_scanner

## Overview

This is an OWASP LLM vulnerability-scanning platform: users choose an Ollama target and OWASP categories, the backend selects a compatible scanner, runs it as a background job, normalizes results, and presents a unified report. The graph includes the Garak, Promptfoo, and promptmap2 branches, plus target adapters and report generation. Some relationships are supported by the SOURCE INDEX rather than full excerpts; the Promptfoo parser excerpt also notes its input format has not been verified against a real run.

Main entry points: [`core/selector.py`](https://github.com/ppgamerer/llm_scanner/blob/main/core/selector.py) (Scan Selector), [`ui/app.py`](https://github.com/ppgamerer/llm_scanner/blob/main/ui/app.py) (Streamlit UI), [`core/runners/promptmap2_runner.py`](https://github.com/ppgamerer/llm_scanner/blob/main/core/runners/promptmap2_runner.py) (promptmap2 Runner), [`core/owasp_mapping.py`](https://github.com/ppgamerer/llm_scanner/blob/main/core/owasp_mapping.py) (OWASP Mapping)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_experience["User Experience"]
  node_ui["Streamlit UI<br/>[app.py]"]
end

subgraph group_service["API and Orchestration"]
  node_api["FastAPI<br/>[main.py]"]
  node_selector["Scan Selector<br/>[selector.py]"]
end

subgraph group_engine["Scan Engine"]
  node_mapping["OWASP Mapping<br/>[owasp_mapping.py]"]
  node_target_adapter["Target Adapters<br/>[base.py]"]
  node_garak_runner["Garak Runner<br/>[garak_runner.py]"]
  node_promptfoo_runner["Promptfoo Runner"]
  node_promptmap_runner["promptmap2 Runner"]
end

subgraph group_results["Results and Reporting"]
  node_garak_parser["Garak Parser<br/>[garak_parser.py]"]
  node_promptfoo_parser["Promptfoo Parser"]
  node_promptmap_parser["promptmap2 Parser"]
  node_report["Unified Reports<br/>[report.py]"]
end

node_user(("Scanner User"))
node_ollama["Ollama"]
node_garak["Garak CLI"]
node_promptfoo["Promptfoo CLI"]
node_promptmap["promptmap2 CLI"]

node_user -->|"selects target"| node_ui
node_ui -->|"requests scans"| node_api
node_api -->|"returns categories"| node_ui
node_api -->|"dispatches scan"| node_selector
node_selector -->|"plans probes"| node_mapping
node_selector -->|"runs scans"| node_garak_runner
node_selector -->|"runs scans"| node_promptfoo_runner
node_selector -->|"runs scans"| node_promptmap_runner
node_garak_runner -->|"invokes CLI"| node_garak
node_promptfoo_runner -->|"invokes CLI"| node_promptfoo
node_promptmap_runner -->|"invokes CLI"| node_promptmap
node_garak_runner -->|"parses output"| node_garak_parser
node_promptfoo_runner -->|"parses output"| node_promptfoo_parser
node_promptmap_runner -->|"parses output"| node_promptmap_parser
node_garak_parser -->|"maps probes"| node_mapping
node_promptfoo_parser -->|"maps plugins"| node_mapping
node_promptmap_parser -->|"maps rules"| node_mapping
node_selector -->|"builds reports"| node_report
node_report -->|"shows results"| node_ui
node_target_adapter -->|"queries model"| node_ollama
node_promptmap_runner -->|"fetches prompt"| node_ollama
node_ui -->|"lists models"| node_ollama

click node_ui "https://github.com/ppgamerer/llm_scanner/blob/main/ui/app.py"
click node_api "https://github.com/ppgamerer/llm_scanner/blob/main/api/main.py"
click node_selector "https://github.com/ppgamerer/llm_scanner/blob/main/core/selector.py"
click node_mapping "https://github.com/ppgamerer/llm_scanner/blob/main/core/owasp_mapping.py"
click node_target_adapter "https://github.com/ppgamerer/llm_scanner/blob/main/core/generators/base.py"
click node_garak_runner "https://github.com/ppgamerer/llm_scanner/blob/main/core/runners/garak_runner.py"
click node_garak_parser "https://github.com/ppgamerer/llm_scanner/blob/main/core/parsers/garak_parser.py"
click node_promptfoo_runner "https://github.com/ppgamerer/llm_scanner/blob/main/core/runners/promptfoo_runner.py"
click node_promptfoo_parser "https://github.com/ppgamerer/llm_scanner/blob/main/core/parsers/promptfoo_parser.py"
click node_promptmap_runner "https://github.com/ppgamerer/llm_scanner/blob/main/core/runners/promptmap2_runner.py"
click node_promptmap_parser "https://github.com/ppgamerer/llm_scanner/blob/main/core/parsers/promptmap2_parser.py"
click node_report "https://github.com/ppgamerer/llm_scanner/blob/main/core/report.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_ui,node_user toneBlue
class node_api,node_selector toneAmber
class node_mapping,node_target_adapter,node_garak_runner,node_promptfoo_runner,node_promptmap_runner toneMint
class node_garak_parser,node_promptfoo_parser,node_promptmap_parser,node_report toneRose
class node_ollama,node_garak,node_promptfoo,node_promptmap toneIndigo
```

## Components

### User Experience

- [Streamlit UI](https://github.com/ppgamerer/llm_scanner/blob/main/ui/app.py): `ui/app.py`

### API and Orchestration

- [FastAPI](https://github.com/ppgamerer/llm_scanner/blob/main/api/main.py): `api/main.py`
- [Scan Selector](https://github.com/ppgamerer/llm_scanner/blob/main/core/selector.py): `core/selector.py`

### Scan Engine

- [OWASP Mapping](https://github.com/ppgamerer/llm_scanner/blob/main/core/owasp_mapping.py): `core/owasp_mapping.py`
- [Target Adapters](https://github.com/ppgamerer/llm_scanner/blob/main/core/generators/base.py): `core/generators/base.py`
- [Garak Runner](https://github.com/ppgamerer/llm_scanner/blob/main/core/runners/garak_runner.py): `core/runners/garak_runner.py`
- [Promptfoo Runner](https://github.com/ppgamerer/llm_scanner/blob/main/core/runners/promptfoo_runner.py): `core/runners/promptfoo_runner.py`
- [promptmap2 Runner](https://github.com/ppgamerer/llm_scanner/blob/main/core/runners/promptmap2_runner.py): `core/runners/promptmap2_runner.py`

### Results and Reporting

- [Garak Parser](https://github.com/ppgamerer/llm_scanner/blob/main/core/parsers/garak_parser.py): `core/parsers/garak_parser.py`
- [Promptfoo Parser](https://github.com/ppgamerer/llm_scanner/blob/main/core/parsers/promptfoo_parser.py): `core/parsers/promptfoo_parser.py`
- [promptmap2 Parser](https://github.com/ppgamerer/llm_scanner/blob/main/core/parsers/promptmap2_parser.py): `core/parsers/promptmap2_parser.py`
- [Unified Reports](https://github.com/ppgamerer/llm_scanner/blob/main/core/report.py): `core/report.py`

### Other components

- **Scanner User**
- **Ollama**
- **Garak CLI**
- **Promptfoo CLI**
- **promptmap2 CLI**

## Connections

- Scanner User → Streamlit UI: selects target (evidence: `ui/app.py`)
- Streamlit UI → FastAPI: requests scans (evidence: `ui/app.py`)
- FastAPI → Streamlit UI: returns categories (evidence: `api/main.py`)
- FastAPI → Scan Selector: dispatches scan (evidence: `api/main.py`)
- Scan Selector → OWASP Mapping: plans probes (evidence: `core/selector.py`)
- Scan Selector → Garak Runner: runs scans (evidence: `core/selector.py`)
- Scan Selector → Promptfoo Runner: runs scans (evidence: `core/selector.py`)
- Scan Selector → promptmap2 Runner: runs scans (evidence: `core/selector.py`)
- Garak Runner → Garak CLI: invokes CLI (evidence: `core/runners/garak_runner.py`)
- Promptfoo Runner → Promptfoo CLI: invokes CLI (evidence: `core/runners/promptfoo_runner.py`)
- promptmap2 Runner → promptmap2 CLI: invokes CLI (evidence: `core/runners/promptmap2_runner.py`)
- Garak Runner → Garak Parser: parses output (evidence: `core/runners/garak_runner.py`)
- Promptfoo Runner → Promptfoo Parser: parses output (evidence: `core/runners/promptfoo_runner.py`)
- promptmap2 Runner → promptmap2 Parser: parses output (evidence: `core/runners/promptmap2_runner.py`)
- Garak Parser → OWASP Mapping: maps probes (evidence: `core/parsers/garak_parser.py`)
- Promptfoo Parser → OWASP Mapping: maps plugins (evidence: `core/parsers/promptfoo_parser.py`)
- promptmap2 Parser → OWASP Mapping: maps rules (evidence: `core/parsers/promptmap2_parser.py`)
- Scan Selector → Unified Reports: builds reports (evidence: `core/selector.py`)
- Unified Reports → Streamlit UI: shows results (evidence: `ui/app.py`)
- Target Adapters → Ollama: queries model (evidence: `core/generators/base.py`)
- promptmap2 Runner → Ollama: fetches prompt (evidence: `core/runners/promptmap2_runner.py`)
- Streamlit UI → Ollama: lists models (evidence: `ui/app.py`)
