# hiteshsai01/garak architecture

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

- Interactive diagram: https://gitdiagram.com/hiteshsai01/garak
- Repository: https://github.com/hiteshsai01/garak

## Overview

garak is a command-line red-team scanner for LLM-backed systems. A user selects a target generator and vulnerability probes; the runtime loads plugins, runs probe attempts against the target, evaluates responses with detectors, and records results for later analysis. Its separate garak-report frontend presents report summaries and charts. The map includes documented plugin families and reporting capabilities, but detailed connections among unsampled implementations are omitted unless supported by the README or source index.

Main entry points: [`garak/command.py`](https://github.com/hiteshsai01/garak/blob/main/garak/command.py) (Run coordinator), [`garak/cli.py`](https://github.com/hiteshsai01/garak/blob/main/garak/cli.py) (CLI commands), [`garak-report/src/pages/Report.tsx`](https://github.com/hiteshsai01/garak/blob/main/garak-report/src/pages/Report.tsx) (Report views), [`garak/_config.py`](https://github.com/hiteshsai01/garak/blob/main/garak/_config.py) (Run configuration)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["Scan orchestration"]
  node_cli["CLI commands<br/>[cli.py]"]
  node_config["Run configuration<br/>[_config.py]"]
  node_selection["Plugin selection<br/>[_selection.py]"]
  node_plugin_loader["Plugin loader<br/>[_plugins.py]"]
  node_command["Run coordinator<br/>[command.py]"]
  node_attempt["Attempt records<br/>[attempt.py]"]
end

subgraph group_plugins["Assessment plugins"]
  node_probes["Probe families"]
  node_detectors["Detector families"]
  node_harnesses["Harnesses"]
  node_intents["Intent service<br/>[intentservice.py]"]
end

subgraph group_execution["Target execution"]
  node_generators["Target generators"]
  node_language["Language providers<br/>[langservice.py]"]
end

subgraph group_results["Results and analysis"]
  node_report_writer["Report output<br/>[report.py]"]
  node_analysis["Report analysis"]
end

subgraph group_frontend["Report interface"]
  node_report_app["Report application<br/>[App.tsx]"]
  node_report_page["Report views<br/>[Report.tsx]"]
  node_charts["Charts and summaries"]
end

node_user(("CLI user"))
node_target(("LLM target"))
node_report_data["Scan report"]

node_user -->|"selects scan"| node_cli
node_cli -->|"loads options"| node_config
node_cli -->|"lists plugins"| node_plugin_loader
node_cli -->|"starts run"| node_command
node_config -->|"builds selection"| node_selection
node_command -->|"loads plugins"| node_plugin_loader
node_command -->|"invokes probes"| node_probes
node_command -->|"dispatches run"| node_harnesses
node_command -->|"requests intent data"| node_intents
node_probes -->|"creates attempts"| node_attempt
node_command -->|"selects target"| node_generators
node_generators -.->|"queries"| node_target
node_command -->|"selects detectors"| node_detectors
node_command -->|"runs digest"| node_analysis
node_command -.->|"writes results"| node_report_writer
node_analysis -->|"reads run logs"| node_report_data
node_report_data -.->|"provides report"| node_report_page
node_report_app -->|"renders"| node_report_page
node_report_page -.->|"presents summaries"| node_charts

click node_cli "https://github.com/hiteshsai01/garak/blob/main/garak/cli.py"
click node_config "https://github.com/hiteshsai01/garak/blob/main/garak/_config.py"
click node_selection "https://github.com/hiteshsai01/garak/blob/main/garak/_selection.py"
click node_plugin_loader "https://github.com/hiteshsai01/garak/blob/main/garak/_plugins.py"
click node_command "https://github.com/hiteshsai01/garak/blob/main/garak/command.py"
click node_attempt "https://github.com/hiteshsai01/garak/blob/main/garak/attempt.py"
click node_probes "https://github.com/hiteshsai01/garak/tree/main/garak/probes"
click node_detectors "https://github.com/hiteshsai01/garak/tree/main/garak/detectors"
click node_harnesses "https://github.com/hiteshsai01/garak/tree/main/garak/harnesses"
click node_intents "https://github.com/hiteshsai01/garak/blob/main/garak/services/intentservice.py"
click node_generators "https://github.com/hiteshsai01/garak/tree/main/garak/generators"
click node_language "https://github.com/hiteshsai01/garak/blob/main/garak/services/langservice.py"
click node_report_writer "https://github.com/hiteshsai01/garak/blob/main/garak/report.py"
click node_analysis "https://github.com/hiteshsai01/garak/tree/main/garak/analyze"
click node_report_app "https://github.com/hiteshsai01/garak/blob/main/garak-report/src/App.tsx"
click node_report_page "https://github.com/hiteshsai01/garak/blob/main/garak-report/src/pages/Report.tsx"
click node_charts "https://github.com/hiteshsai01/garak/tree/main/garak-report/src/components"

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_config,node_selection,node_plugin_loader,node_command,node_attempt,node_user toneBlue
class node_probes,node_detectors,node_harnesses,node_intents toneAmber
class node_generators,node_language toneMint
class node_report_writer,node_analysis toneRose
class node_report_app,node_report_page,node_charts,node_target,node_report_data toneIndigo
```

## Components

### Scan orchestration

- [CLI commands](https://github.com/hiteshsai01/garak/blob/main/garak/cli.py): `garak/cli.py`
- [Run configuration](https://github.com/hiteshsai01/garak/blob/main/garak/_config.py): `garak/_config.py`
- [Plugin selection](https://github.com/hiteshsai01/garak/blob/main/garak/_selection.py): `garak/_selection.py`
- [Plugin loader](https://github.com/hiteshsai01/garak/blob/main/garak/_plugins.py): `garak/_plugins.py`
- [Run coordinator](https://github.com/hiteshsai01/garak/blob/main/garak/command.py): `garak/command.py`
- [Attempt records](https://github.com/hiteshsai01/garak/blob/main/garak/attempt.py): `garak/attempt.py`

### Assessment plugins

- [Probe families](https://github.com/hiteshsai01/garak/tree/main/garak/probes): `garak/probes`
- [Detector families](https://github.com/hiteshsai01/garak/tree/main/garak/detectors): `garak/detectors`
- [Harnesses](https://github.com/hiteshsai01/garak/tree/main/garak/harnesses): `garak/harnesses`
- [Intent service](https://github.com/hiteshsai01/garak/blob/main/garak/services/intentservice.py): `garak/services/intentservice.py`

### Target execution

- [Target generators](https://github.com/hiteshsai01/garak/tree/main/garak/generators): `garak/generators`
- [Language providers](https://github.com/hiteshsai01/garak/blob/main/garak/services/langservice.py): `garak/services/langservice.py`

### Results and analysis

- [Report output](https://github.com/hiteshsai01/garak/blob/main/garak/report.py): `garak/report.py`
- [Report analysis](https://github.com/hiteshsai01/garak/tree/main/garak/analyze): `garak/analyze`

### Report interface

- [Report application](https://github.com/hiteshsai01/garak/blob/main/garak-report/src/App.tsx): `garak-report/src/App.tsx`
- [Report views](https://github.com/hiteshsai01/garak/blob/main/garak-report/src/pages/Report.tsx): `garak-report/src/pages/Report.tsx`
- [Charts and summaries](https://github.com/hiteshsai01/garak/tree/main/garak-report/src/components): `garak-report/src/components`

### Other components

- **CLI user**
- **LLM target**
- **Scan report**

## Connections

- CLI user → CLI commands: selects scan (evidence: `README.md`)
- CLI commands → Run configuration: loads options (evidence: `garak/cli.py`)
- CLI commands → Plugin loader: lists plugins (evidence: `garak/cli.py`)
- CLI commands → Run coordinator: starts run (evidence: `garak/cli.py`)
- Run configuration → Plugin selection: builds selection (evidence: `garak/_config.py`)
- Run coordinator → Plugin loader: loads plugins (evidence: `garak/command.py`)
- Run coordinator → Probe families: invokes probes (evidence: `garak/command.py`)
- Run coordinator → Harnesses: dispatches run (evidence: `garak/command.py`)
- Run coordinator → Intent service: requests intent data (evidence: `garak/command.py`)
- Probe families → Attempt records: creates attempts (evidence: `garak/probes/base.py`)
- Run coordinator → Target generators: selects target (evidence: `garak/command.py`)
- Target generators → LLM target: queries (evidence: `README.md`)
- Run coordinator → Detector families: selects detectors (evidence: `README.md`)
- Run coordinator → Report analysis: runs digest (evidence: `garak/command.py`)
- Run coordinator → Report output: writes results (evidence: `README.md`)
- Report analysis → Scan report: reads run logs (evidence: `README.md`)
- Scan report → Report views: provides report
- Report application → Report views: renders (evidence: `garak-report/src/App.tsx`)
- Report views → Charts and summaries: presents summaries
