# lingyang15359/defenseclaw architecture

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

- Interactive diagram: https://gitdiagram.com/lingyang15359/defenseclaw
- Repository: https://github.com/lingyang15359/defenseclaw

## Overview

DefenseClaw is an OpenClaw security-governance system: operators configure it through a CLI, while a Go daemon scans and admits installed agent components, enforces policy, inspects runtime traffic, and records outcomes. A TypeScript plugin connects OpenClaw hooks to the daemon; a separate gateway proxy inspects LLM messages. The graph retains documented scanning, CodeGuard, sandbox, inventory, alerting, and SIEM capabilities. Edges are limited to README statements and sampled source/index references; unsampled subsystem links are omitted where evidence is insufficient.

Main entry points: [`cli/defenseclaw/commands`](https://github.com/lingyang15359/defenseclaw/tree/main/cli/defenseclaw/commands) (CLI commands), [`internal/gateway/router.go`](https://github.com/lingyang15359/defenseclaw/blob/main/internal/gateway/router.go) (Event router), [`internal/audit/store.go`](https://github.com/lingyang15359/defenseclaw/blob/main/internal/audit/store.go) (Audit store), [`internal/watcher/watcher.go`](https://github.com/lingyang15359/defenseclaw/blob/main/internal/watcher/watcher.go) (Install watcher)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_operator["Operator CLI"]
  node_pycli["Python CLI<br/>[main.py]"]
  node_commands["CLI commands"]
  node_cliguard["CodeGuard<br/>[codeguard_skill.py]"]
  node_gocli["Go CLI"]
end

subgraph group_admission["Scanning and admission"]
  node_watcher["Install watcher<br/>[watcher.go]"]
  node_scanners["Component scanners"]
  node_codescan["CodeGuard scanner<br/>[codeguard.go]"]
  node_admission["Admission gate<br/>[admission.py]"]
  node_policy["Policy engine<br/>[engine.go]"]
end

subgraph group_runtime["Runtime governance"]
  node_plugin["OpenClaw plugin<br/>[index.ts]"]
  node_pluginclient["Plugin API client<br/>[client.ts]"]
  node_daemon["Go daemon<br/>[daemon.go]"]
  node_eventrouter["Event router<br/>[router.go]"]
  node_inspect["Tool inspection<br/>[inspect.go]"]
  node_proxy["Guardrail proxy<br/>[proxy.go]"]
  node_providers["LLM providers<br/>[provider.go]"]
  node_sandbox["Sandbox controls"]
end

subgraph group_operations["State and operations"]
  node_audit[("Audit store<br/>[store.go]")]
  node_siem["SIEM export<br/>[splunk.go]"]
  node_telemetry["Telemetry"]
  node_inventory["Agent inventory<br/>[claw_inventory.py]"]
  node_dashboard["TUI dashboard<br/>[app.go]"]
end

node_operator(("Operator"))
node_openclaw["OpenClaw"]

node_operator -->|"runs commands"| node_pycli
node_pycli -->|"dispatches"| node_commands
node_commands -->|"requests scans"| node_scanners
node_commands -->|"submits findings"| node_admission
node_commands -->|"runs standalone"| node_cliguard
node_watcher -->|"evaluates admission"| node_policy
node_watcher -->|"scans installs"| node_scanners
node_watcher -->|"logs outcomes"| node_audit
node_scanners -.->|"includes code checks"| node_codescan
node_admission -->|"records decisions"| node_audit
node_operator -->|"runs commands"| node_gocli
node_plugin -->|"calls API"| node_pluginclient
node_plugin -->|"hooks tool calls"| node_openclaw
node_pluginclient -->|"sends REST requests"| node_daemon
node_openclaw -->|"sends WebSocket events"| node_eventrouter
node_daemon -->|"routes events"| node_eventrouter
node_eventrouter -->|"logs actions"| node_audit
node_eventrouter -->|"records spans"| node_telemetry
node_eventrouter -.->|"inspects tool events"| node_inspect
node_openclaw -->|"routes LLM calls"| node_proxy
node_proxy -.->|"forwards requests"| node_providers
node_daemon -.->|"manages isolation"| node_sandbox
node_audit -->|"forwards audit events"| node_siem
node_audit -->|"supplies dashboard data"| node_dashboard
node_commands -->|"generates bill of materials"| node_inventory

click node_pycli "https://github.com/lingyang15359/defenseclaw/blob/main/cli/defenseclaw/main.py"
click node_commands "https://github.com/lingyang15359/defenseclaw/tree/main/cli/defenseclaw/commands"
click node_cliguard "https://github.com/lingyang15359/defenseclaw/blob/main/cli/defenseclaw/codeguard_skill.py"
click node_gocli "https://github.com/lingyang15359/defenseclaw/tree/main/internal/cli"
click node_watcher "https://github.com/lingyang15359/defenseclaw/blob/main/internal/watcher/watcher.go"
click node_scanners "https://github.com/lingyang15359/defenseclaw/tree/main/internal/scanner"
click node_codescan "https://github.com/lingyang15359/defenseclaw/blob/main/internal/scanner/codeguard.go"
click node_admission "https://github.com/lingyang15359/defenseclaw/blob/main/cli/defenseclaw/enforce/admission.py"
click node_policy "https://github.com/lingyang15359/defenseclaw/blob/main/internal/policy/engine.go"
click node_plugin "https://github.com/lingyang15359/defenseclaw/blob/main/extensions/defenseclaw/src/index.ts"
click node_pluginclient "https://github.com/lingyang15359/defenseclaw/blob/main/extensions/defenseclaw/src/client.ts"
click node_daemon "https://github.com/lingyang15359/defenseclaw/blob/main/internal/daemon/daemon.go"
click node_eventrouter "https://github.com/lingyang15359/defenseclaw/blob/main/internal/gateway/router.go"
click node_inspect "https://github.com/lingyang15359/defenseclaw/blob/main/internal/gateway/inspect.go"
click node_proxy "https://github.com/lingyang15359/defenseclaw/blob/main/internal/gateway/proxy.go"
click node_providers "https://github.com/lingyang15359/defenseclaw/blob/main/internal/gateway/provider.go"
click node_sandbox "https://github.com/lingyang15359/defenseclaw/tree/main/internal/sandbox"
click node_audit "https://github.com/lingyang15359/defenseclaw/blob/main/internal/audit/store.go"
click node_siem "https://github.com/lingyang15359/defenseclaw/blob/main/internal/audit/splunk.go"
click node_telemetry "https://github.com/lingyang15359/defenseclaw/tree/main/internal/telemetry"
click node_inventory "https://github.com/lingyang15359/defenseclaw/blob/main/cli/defenseclaw/inventory/claw_inventory.py"
click node_dashboard "https://github.com/lingyang15359/defenseclaw/blob/main/internal/tui/app.go"

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_pycli,node_commands,node_cliguard,node_gocli toneBlue
class node_watcher,node_scanners,node_codescan,node_admission,node_policy toneAmber
class node_plugin,node_pluginclient,node_daemon,node_eventrouter,node_inspect,node_proxy,node_providers,node_sandbox toneMint
class node_audit,node_siem,node_telemetry,node_inventory,node_dashboard toneRose
class node_operator,node_openclaw toneIndigo
```

## Components

### Operator CLI

- [Python CLI](https://github.com/lingyang15359/defenseclaw/blob/main/cli/defenseclaw/main.py): `cli/defenseclaw/main.py`
- [CLI commands](https://github.com/lingyang15359/defenseclaw/tree/main/cli/defenseclaw/commands): `cli/defenseclaw/commands`
- [CodeGuard](https://github.com/lingyang15359/defenseclaw/blob/main/cli/defenseclaw/codeguard_skill.py): `cli/defenseclaw/codeguard_skill.py`
- [Go CLI](https://github.com/lingyang15359/defenseclaw/tree/main/internal/cli): `internal/cli`

### Scanning and admission

- [Install watcher](https://github.com/lingyang15359/defenseclaw/blob/main/internal/watcher/watcher.go): `internal/watcher/watcher.go`
- [Component scanners](https://github.com/lingyang15359/defenseclaw/tree/main/internal/scanner): `internal/scanner`
- [CodeGuard scanner](https://github.com/lingyang15359/defenseclaw/blob/main/internal/scanner/codeguard.go): `internal/scanner/codeguard.go`
- [Admission gate](https://github.com/lingyang15359/defenseclaw/blob/main/cli/defenseclaw/enforce/admission.py): `cli/defenseclaw/enforce/admission.py`
- [Policy engine](https://github.com/lingyang15359/defenseclaw/blob/main/internal/policy/engine.go): `internal/policy/engine.go`

### Runtime governance

- [OpenClaw plugin](https://github.com/lingyang15359/defenseclaw/blob/main/extensions/defenseclaw/src/index.ts): `extensions/defenseclaw/src/index.ts`
- [Plugin API client](https://github.com/lingyang15359/defenseclaw/blob/main/extensions/defenseclaw/src/client.ts): `extensions/defenseclaw/src/client.ts`
- [Go daemon](https://github.com/lingyang15359/defenseclaw/blob/main/internal/daemon/daemon.go): `internal/daemon/daemon.go`
- [Event router](https://github.com/lingyang15359/defenseclaw/blob/main/internal/gateway/router.go): `internal/gateway/router.go`
- [Tool inspection](https://github.com/lingyang15359/defenseclaw/blob/main/internal/gateway/inspect.go): `internal/gateway/inspect.go`
- [Guardrail proxy](https://github.com/lingyang15359/defenseclaw/blob/main/internal/gateway/proxy.go): `internal/gateway/proxy.go`
- [LLM providers](https://github.com/lingyang15359/defenseclaw/blob/main/internal/gateway/provider.go): `internal/gateway/provider.go`
- [Sandbox controls](https://github.com/lingyang15359/defenseclaw/tree/main/internal/sandbox): `internal/sandbox`

### State and operations

- [Audit store](https://github.com/lingyang15359/defenseclaw/blob/main/internal/audit/store.go): `internal/audit/store.go`
- [SIEM export](https://github.com/lingyang15359/defenseclaw/blob/main/internal/audit/splunk.go): `internal/audit/splunk.go`
- [Telemetry](https://github.com/lingyang15359/defenseclaw/tree/main/internal/telemetry): `internal/telemetry`
- [Agent inventory](https://github.com/lingyang15359/defenseclaw/blob/main/cli/defenseclaw/inventory/claw_inventory.py): `cli/defenseclaw/inventory/claw_inventory.py`
- [TUI dashboard](https://github.com/lingyang15359/defenseclaw/blob/main/internal/tui/app.go): `internal/tui/app.go`

### Other components

- **Operator**
- **OpenClaw**

## Connections

- Operator → Python CLI: runs commands (evidence: `README.md`)
- Python CLI → CLI commands: dispatches (evidence: `cli/defenseclaw/main.py`)
- CLI commands → Component scanners: requests scans (evidence: `cli/defenseclaw/commands/cmd_skill.py`)
- CLI commands → Admission gate: submits findings (evidence: `cli/defenseclaw/commands/cmd_skill.py`)
- CLI commands → CodeGuard: runs standalone (evidence: `cli/defenseclaw/commands/cmd_codeguard.py`)
- Install watcher → Policy engine: evaluates admission (evidence: `internal/watcher/watcher.go`)
- Install watcher → Component scanners: scans installs (evidence: `internal/watcher/watcher.go`)
- Install watcher → Audit store: logs outcomes (evidence: `internal/watcher/watcher.go`)
- Component scanners → CodeGuard scanner: includes code checks
- Admission gate → Audit store: records decisions (evidence: `README.md`)
- Operator → Go CLI: runs commands (evidence: `README.md`)
- OpenClaw plugin → Plugin API client: calls API (evidence: `README.md`)
- OpenClaw plugin → OpenClaw: hooks tool calls (evidence: `README.md`)
- Plugin API client → Go daemon: sends REST requests (evidence: `README.md`)
- OpenClaw → Event router: sends WebSocket events (evidence: `README.md`)
- Go daemon → Event router: routes events (evidence: `internal/gateway/router.go`)
- Event router → Audit store: logs actions (evidence: `internal/gateway/router.go`)
- Event router → Telemetry: records spans (evidence: `internal/gateway/router.go`)
- Event router → Tool inspection: inspects tool events
- OpenClaw → Guardrail proxy: routes LLM calls (evidence: `README.md`)
- Guardrail proxy → LLM providers: forwards requests
- Go daemon → Sandbox controls: manages isolation
- Audit store → SIEM export: forwards audit events (evidence: `README.md`)
- Audit store → TUI dashboard: supplies dashboard data (evidence: `internal/tui/app.go`)
- CLI commands → Agent inventory: generates bill of materials (evidence: `cli/defenseclaw/commands/cmd_aibom.py`)
