# capture0x/redwitness architecture

> Architecture diagram of the GitHub repository capture0x/redwitness, 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/capture0x/redwitness
- Repository: https://github.com/capture0x/redwitness

## Overview

RedWitness is a self-hosted LLM application penetration-testing platform. Operators configure a target and sign a bounded authorization scope, then choose test cases and launch a scan. The engine sends probes through target adapters under governor limits, judges responses, and replays suspected violations before recording findings. Operators review evidence and can produce client reports. The graph includes major documented scan capabilities; several specialized scanners and UI-to-API links are represented at their source paths, but their internal wiring was not sampled, so uncertain links are omitted.

Main entry points: [`backend/llm_redteam/engine.py`](https://github.com/capture0x/redwitness/blob/main/backend/llm_redteam/engine.py) (Scan engine), [`backend/main.py`](https://github.com/capture0x/redwitness/blob/main/backend/main.py) (HTTP API), [`backend/llm_redteam/clientreport.py`](https://github.com/capture0x/redwitness/blob/main/backend/llm_redteam/clientreport.py) (Client reports), [`frontend/app/scopes/page.tsx`](https://github.com/capture0x/redwitness/blob/main/frontend/app/scopes/page.tsx) (Scope setup)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_authorization["Authorization"]
  node_scope_ui["Scope setup<br/>[page.tsx]"]
  node_scope_model["Signed scope<br/>[scope.py]"]
  node_scope_signing["Scope signing<br/>[signing.py]"]
  node_governor["Request governor<br/>[governor.py]"]
end

subgraph group_testing["Scan execution"]
  node_target_ui["Target setup<br/>[page.tsx]"]
  node_target_adapters["Target adapters<br/>[targets.py]"]
  node_target_service{{"Test target"}}
  node_library_ui["Probe library UI<br/>[page.tsx]"]
  node_probe_library["Probe library<br/>[library.py]"]
  node_special_scans["Specialized scans"]
  node_scan_engine["Scan engine<br/>[engine.py]"]
end

subgraph group_analysis["Analysis and reporting"]
  node_judge["Response judge<br/>[evaluator.py]"]
  node_replay_verify["Replay verification<br/>[verifier.py]"]
  node_taxonomy["OWASP mapping<br/>[owasp.py]"]
  node_risk["Finding risk<br/>[risk.py]"]
  node_remediation["Remediation<br/>[remediator.py]"]
  node_reporting["Client reports<br/>[clientreport.py]"]
  node_run_ui["Run review<br/>[page.tsx]"]
end

subgraph group_operations["Platform operations"]
  node_api["HTTP API<br/>[main.py]"]
  node_store[("Run and scope store<br/>[store.py]")]
  node_auth["User authentication<br/>[auth.py]"]
end

node_operator(("Operator"))

node_operator -->|"configures"| node_scope_ui
node_scope_ui -.->|"defines limits"| node_scope_model
node_scope_model -->|"signs content"| node_scope_signing
node_operator -.->|"configures"| node_target_ui
node_operator -.->|"chooses probes"| node_library_ui
node_operator -.->|"starts scan"| node_api
node_api -->|"checks access"| node_auth
node_api -->|"loads scope"| node_store
node_api -->|"starts run"| node_scan_engine
node_scan_engine -->|"records evidence"| node_store
node_scan_engine -->|"executes cases"| node_probe_library
node_scan_engine -->|"checks requests"| node_governor
node_scan_engine -->|"sends probes"| node_target_adapters
node_target_adapters -->|"sends requests"| node_target_service
node_scan_engine -->|"evaluates replies"| node_judge
node_scan_engine -->|"confirms findings"| node_replay_verify
node_probe_library -->|"includes scenarios"| node_special_scans
node_judge -->|"maps categories"| node_taxonomy
node_reporting -->|"summarizes coverage"| node_taxonomy
node_reporting -->|"scores findings"| node_risk
node_reporting -.->|"uses guidance"| node_remediation
node_operator -.->|"reviews results"| node_run_ui
node_api -->|"builds reports"| node_reporting
node_api -.->|"offers scan capabilities"| node_special_scans

click node_scope_ui "https://github.com/capture0x/redwitness/blob/main/frontend/app/scopes/page.tsx"
click node_scope_model "https://github.com/capture0x/redwitness/blob/main/backend/llm_redteam/scope.py"
click node_scope_signing "https://github.com/capture0x/redwitness/blob/main/backend/llm_redteam/signing.py"
click node_governor "https://github.com/capture0x/redwitness/blob/main/backend/llm_redteam/governor.py"
click node_target_ui "https://github.com/capture0x/redwitness/blob/main/frontend/app/targets/page.tsx"
click node_target_adapters "https://github.com/capture0x/redwitness/blob/main/backend/llm_redteam/targets.py"
click node_library_ui "https://github.com/capture0x/redwitness/blob/main/frontend/app/library/page.tsx"
click node_probe_library "https://github.com/capture0x/redwitness/blob/main/backend/llm_redteam/library.py"
click node_special_scans "https://github.com/capture0x/redwitness/tree/main/backend/llm_redteam"
click node_scan_engine "https://github.com/capture0x/redwitness/blob/main/backend/llm_redteam/engine.py"
click node_judge "https://github.com/capture0x/redwitness/blob/main/backend/llm_redteam/evaluator.py"
click node_replay_verify "https://github.com/capture0x/redwitness/blob/main/backend/llm_redteam/verifier.py"
click node_taxonomy "https://github.com/capture0x/redwitness/blob/main/backend/llm_redteam/owasp.py"
click node_risk "https://github.com/capture0x/redwitness/blob/main/backend/llm_redteam/risk.py"
click node_remediation "https://github.com/capture0x/redwitness/blob/main/backend/llm_redteam/remediator.py"
click node_reporting "https://github.com/capture0x/redwitness/blob/main/backend/llm_redteam/clientreport.py"
click node_run_ui "https://github.com/capture0x/redwitness/blob/main/frontend/app/runs/%5Bid%5D/page.tsx"
click node_api "https://github.com/capture0x/redwitness/blob/main/backend/main.py"
click node_store "https://github.com/capture0x/redwitness/blob/main/backend/llm_redteam/store.py"
click node_auth "https://github.com/capture0x/redwitness/blob/main/backend/llm_redteam/auth.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_scope_ui,node_scope_model,node_scope_signing,node_governor toneBlue
class node_target_ui,node_target_adapters,node_target_service,node_library_ui,node_probe_library,node_special_scans,node_scan_engine toneAmber
class node_judge,node_replay_verify,node_taxonomy,node_risk,node_remediation,node_reporting,node_run_ui toneMint
class node_api,node_store,node_auth toneRose
class node_operator toneIndigo
```

## Components

### Authorization

- [Scope setup](https://github.com/capture0x/redwitness/blob/main/frontend/app/scopes/page.tsx): `frontend/app/scopes/page.tsx`
- [Signed scope](https://github.com/capture0x/redwitness/blob/main/backend/llm_redteam/scope.py): `backend/llm_redteam/scope.py`
- [Scope signing](https://github.com/capture0x/redwitness/blob/main/backend/llm_redteam/signing.py): `backend/llm_redteam/signing.py`
- [Request governor](https://github.com/capture0x/redwitness/blob/main/backend/llm_redteam/governor.py): `backend/llm_redteam/governor.py`

### Scan execution

- [Target setup](https://github.com/capture0x/redwitness/blob/main/frontend/app/targets/page.tsx): `frontend/app/targets/page.tsx`
- [Target adapters](https://github.com/capture0x/redwitness/blob/main/backend/llm_redteam/targets.py): `backend/llm_redteam/targets.py`
- **Test target**
- [Probe library UI](https://github.com/capture0x/redwitness/blob/main/frontend/app/library/page.tsx): `frontend/app/library/page.tsx`
- [Probe library](https://github.com/capture0x/redwitness/blob/main/backend/llm_redteam/library.py): `backend/llm_redteam/library.py`
- [Specialized scans](https://github.com/capture0x/redwitness/tree/main/backend/llm_redteam): `backend/llm_redteam`
- [Scan engine](https://github.com/capture0x/redwitness/blob/main/backend/llm_redteam/engine.py): `backend/llm_redteam/engine.py`

### Analysis and reporting

- [Response judge](https://github.com/capture0x/redwitness/blob/main/backend/llm_redteam/evaluator.py): `backend/llm_redteam/evaluator.py`
- [Replay verification](https://github.com/capture0x/redwitness/blob/main/backend/llm_redteam/verifier.py): `backend/llm_redteam/verifier.py`
- [OWASP mapping](https://github.com/capture0x/redwitness/blob/main/backend/llm_redteam/owasp.py): `backend/llm_redteam/owasp.py`
- [Finding risk](https://github.com/capture0x/redwitness/blob/main/backend/llm_redteam/risk.py): `backend/llm_redteam/risk.py`
- [Remediation](https://github.com/capture0x/redwitness/blob/main/backend/llm_redteam/remediator.py): `backend/llm_redteam/remediator.py`
- [Client reports](https://github.com/capture0x/redwitness/blob/main/backend/llm_redteam/clientreport.py): `backend/llm_redteam/clientreport.py`
- [Run review](https://github.com/capture0x/redwitness/blob/main/frontend/app/runs/%5Bid%5D/page.tsx): `frontend/app/runs/[id]/page.tsx`

### Platform operations

- [HTTP API](https://github.com/capture0x/redwitness/blob/main/backend/main.py): `backend/main.py`
- [Run and scope store](https://github.com/capture0x/redwitness/blob/main/backend/llm_redteam/store.py): `backend/llm_redteam/store.py`
- [User authentication](https://github.com/capture0x/redwitness/blob/main/backend/llm_redteam/auth.py): `backend/llm_redteam/auth.py`

### Other components

- **Operator**

## Connections

- Operator → Scope setup: configures
- Scope setup → Signed scope: defines limits
- Signed scope → Scope signing: signs content (evidence: `backend/llm_redteam/scope.py`)
- Operator → Target setup: configures
- Operator → Probe library UI: chooses probes
- Operator → HTTP API: starts scan
- HTTP API → User authentication: checks access (evidence: `backend/main.py`)
- HTTP API → Run and scope store: loads scope (evidence: `backend/main.py`)
- HTTP API → Scan engine: starts run (evidence: `backend/main.py`)
- Scan engine → Run and scope store: records evidence (evidence: `backend/llm_redteam/engine.py`)
- Scan engine → Probe library: executes cases (evidence: `backend/llm_redteam/engine.py`)
- Scan engine → Request governor: checks requests (evidence: `backend/llm_redteam/engine.py`)
- Scan engine → Target adapters: sends probes (evidence: `backend/llm_redteam/engine.py`)
- Target adapters → Test target: sends requests
- Scan engine → Response judge: evaluates replies (evidence: `backend/llm_redteam/engine.py`)
- Scan engine → Replay verification: confirms findings (evidence: `backend/llm_redteam/engine.py`)
- Probe library → Specialized scans: includes scenarios (evidence: `backend/llm_redteam/library.py`)
- Response judge → OWASP mapping: maps categories (evidence: `backend/llm_redteam/evaluator.py`)
- Client reports → OWASP mapping: summarizes coverage (evidence: `backend/llm_redteam/clientreport.py`)
- Client reports → Finding risk: scores findings (evidence: `backend/llm_redteam/clientreport.py`)
- Client reports → Remediation: uses guidance
- Operator → Run review: reviews results
- HTTP API → Client reports: builds reports (evidence: `backend/main.py`)
- HTTP API → Specialized scans: offers scan capabilities (evidence: `backend/main.py`)
