# antifox-ai/antifox architecture

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

- Interactive diagram: https://gitdiagram.com/antifox-ai/antifox
- Repository: https://github.com/antifox-ai/antifox

## Overview

AntiFox is an AI-assisted penetration-testing platform: an engineer configures an authorized target and goal, then follows an event-driven task from reconnaissance and asset discovery through validation, evidence capture, and report delivery. The documented dual graph separates shared assets from per-task exploration history; planner/worker agents drive exploration, while the web UI supports monitoring and human intervention. The README documents the broad subsystem links; sampled excerpts additionally show task persistence and engine scheduling. Most server wiring and domain implementations were not sampled, so those links rely on README statements.

Main entry points: [`agent/worker.go`](https://github.com/antifox-ai/antifox/blob/main/agent/worker.go) (Worker), [`server/engine.go`](https://github.com/antifox-ai/antifox/blob/main/server/engine.go) (Task engine), [`server/server.go`](https://github.com/antifox-ai/antifox/blob/main/server/server.go) (HTTP API), [`web/src/lib/preferences/preferences-storage.ts`](https://github.com/antifox-ai/antifox/blob/main/web/src/lib/preferences/preferences-storage.ts) (Preference persistence)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_ui["Web interface"]
  node_web["Operations UI<br/>[page.tsx]"]
  node_chat["Agent chat<br/>[page.tsx]"]
  node_pref["Preference persistence"]
  node_prefconfig["Preference config"]
  node_cookie["Browser cookies<br/>[cookie.client.ts]"]
  node_localstorage["Local storage"]
end

subgraph group_control["Task control"]
  node_api["HTTP API<br/>[server.go]"]
  node_engine["Task engine<br/>[engine.go]"]
  node_timeout["Deadline coordinator<br/>[engine_timeout.go]"]
  node_manager["Task manager<br/>[manager.go]"]
  node_main["Service startup<br/>[main.go]"]
end

subgraph group_agents["Exploration runtime"]
  node_planner["Planner<br/>[planner.go]"]
  node_worker["Worker<br/>[worker.go]"]
  node_tooling["Agent tools<br/>[tools.go]"]
  node_llm["LLM harness<br/>[query.go]"]
end

subgraph group_delivery["Evidence and delivery"]
  node_assets[("Shared asset graph<br/>[assets.go]")]
  node_exploration[("Exploration graph<br/>[tasks.go]")]
  node_traffic["MITM traffic<br/>[traffic.go]"]
  node_findings[("Finding evidence")]
  node_knowledge["Knowledge RAG<br/>[service.go]"]
  node_report["Report generation<br/>[build.go]"]
end

node_user(("Engineer"))

node_user -->|"operates"| node_web
node_web -->|"calls API"| node_api
node_chat -.->|"calls API"| node_api
node_pref -->|"reads policy"| node_prefconfig
node_pref -->|"writes cookie"| node_cookie
node_pref -->|"writes storage"| node_localstorage
node_api -->|"dispatches tasks"| node_engine
node_api -.->|"manages tasks"| node_manager
node_engine -->|"runs planning"| node_planner
node_engine -->|"dispatches work"| node_worker
node_engine -->|"coordinates deadlines"| node_timeout
node_planner -->|"reads task graph"| node_exploration
node_worker -->|"uses tools"| node_tooling
node_worker -.->|"runs agent loop"| node_llm
node_worker -->|"writes discoveries"| node_assets
node_worker -->|"writes findings"| node_exploration
node_worker -->|"routes target traffic"| node_traffic
node_traffic -->|"links packets"| node_findings
node_worker -->|"retrieves context"| node_knowledge
node_user -.->|"requests delivery"| node_report
node_report -.->|"renders evidence"| node_findings
node_main -->|"creates manager"| node_manager

click node_web "https://github.com/antifox-ai/antifox/blob/main/web/src/app/(main)/dashboard/page.tsx"
click node_chat "https://github.com/antifox-ai/antifox/blob/main/web/src/app/(main)/chat/page.tsx"
click node_pref "https://github.com/antifox-ai/antifox/blob/main/web/src/lib/preferences/preferences-storage.ts"
click node_prefconfig "https://github.com/antifox-ai/antifox/blob/main/web/src/lib/preferences/preferences-config.ts"
click node_cookie "https://github.com/antifox-ai/antifox/blob/main/web/src/lib/cookie.client.ts"
click node_localstorage "https://github.com/antifox-ai/antifox/blob/main/web/src/lib/local-storage.client.ts"
click node_api "https://github.com/antifox-ai/antifox/blob/main/server/server.go"
click node_engine "https://github.com/antifox-ai/antifox/blob/main/server/engine.go"
click node_timeout "https://github.com/antifox-ai/antifox/blob/main/server/engine_timeout.go"
click node_manager "https://github.com/antifox-ai/antifox/blob/main/server/manager.go"
click node_planner "https://github.com/antifox-ai/antifox/blob/main/agent/planner.go"
click node_worker "https://github.com/antifox-ai/antifox/blob/main/agent/worker.go"
click node_tooling "https://github.com/antifox-ai/antifox/blob/main/agent/tools.go"
click node_llm "https://github.com/antifox-ai/antifox/blob/main/engine/harness/query.go"
click node_assets "https://github.com/antifox-ai/antifox/blob/main/db/assets.go"
click node_exploration "https://github.com/antifox-ai/antifox/blob/main/db/tasks.go"
click node_traffic "https://github.com/antifox-ai/antifox/blob/main/traffic/traffic.go"
click node_findings "https://github.com/antifox-ai/antifox/blob/main/db/finding_evidence.go"
click node_knowledge "https://github.com/antifox-ai/antifox/blob/main/knowledge/service.go"
click node_report "https://github.com/antifox-ai/antifox/blob/main/report/build.go"
click node_main "https://github.com/antifox-ai/antifox/blob/main/cmd/antifox/main.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_web,node_chat,node_pref,node_prefconfig,node_cookie,node_localstorage toneBlue
class node_api,node_engine,node_timeout,node_manager,node_main toneAmber
class node_planner,node_worker,node_tooling,node_llm toneMint
class node_assets,node_exploration,node_traffic,node_findings,node_knowledge,node_report toneRose
class node_user toneIndigo
```

## Components

### Web interface

- [Operations UI](https://github.com/antifox-ai/antifox/blob/main/web/src/app/(main)/dashboard/page.tsx): `web/src/app/(main)/dashboard/page.tsx`
- [Agent chat](https://github.com/antifox-ai/antifox/blob/main/web/src/app/(main)/chat/page.tsx): `web/src/app/(main)/chat/page.tsx`
- [Preference persistence](https://github.com/antifox-ai/antifox/blob/main/web/src/lib/preferences/preferences-storage.ts): `web/src/lib/preferences/preferences-storage.ts`
- [Preference config](https://github.com/antifox-ai/antifox/blob/main/web/src/lib/preferences/preferences-config.ts): `web/src/lib/preferences/preferences-config.ts`
- [Browser cookies](https://github.com/antifox-ai/antifox/blob/main/web/src/lib/cookie.client.ts): `web/src/lib/cookie.client.ts`
- [Local storage](https://github.com/antifox-ai/antifox/blob/main/web/src/lib/local-storage.client.ts): `web/src/lib/local-storage.client.ts`

### Task control

- [HTTP API](https://github.com/antifox-ai/antifox/blob/main/server/server.go): `server/server.go`
- [Task engine](https://github.com/antifox-ai/antifox/blob/main/server/engine.go): `server/engine.go`
- [Deadline coordinator](https://github.com/antifox-ai/antifox/blob/main/server/engine_timeout.go): `server/engine_timeout.go`
- [Task manager](https://github.com/antifox-ai/antifox/blob/main/server/manager.go): `server/manager.go`
- [Service startup](https://github.com/antifox-ai/antifox/blob/main/cmd/antifox/main.go): `cmd/antifox/main.go`

### Exploration runtime

- [Planner](https://github.com/antifox-ai/antifox/blob/main/agent/planner.go): `agent/planner.go`
- [Worker](https://github.com/antifox-ai/antifox/blob/main/agent/worker.go): `agent/worker.go`
- [Agent tools](https://github.com/antifox-ai/antifox/blob/main/agent/tools.go): `agent/tools.go`
- [LLM harness](https://github.com/antifox-ai/antifox/blob/main/engine/harness/query.go): `engine/harness/query.go`

### Evidence and delivery

- [Shared asset graph](https://github.com/antifox-ai/antifox/blob/main/db/assets.go): `db/assets.go`
- [Exploration graph](https://github.com/antifox-ai/antifox/blob/main/db/tasks.go): `db/tasks.go`
- [MITM traffic](https://github.com/antifox-ai/antifox/blob/main/traffic/traffic.go): `traffic/traffic.go`
- [Finding evidence](https://github.com/antifox-ai/antifox/blob/main/db/finding_evidence.go): `db/finding_evidence.go`
- [Knowledge RAG](https://github.com/antifox-ai/antifox/blob/main/knowledge/service.go): `knowledge/service.go`
- [Report generation](https://github.com/antifox-ai/antifox/blob/main/report/build.go): `report/build.go`

### Other components

- **Engineer**

## Connections

- Engineer → Operations UI: operates (evidence: `README.md`)
- Operations UI → HTTP API: calls API (evidence: `README.md`)
- Agent chat → HTTP API: calls API
- Preference persistence → Preference config: reads policy (evidence: `web/src/lib/preferences/preferences-storage.ts`)
- Preference persistence → Browser cookies: writes cookie (evidence: `web/src/lib/preferences/preferences-storage.ts`)
- Preference persistence → Local storage: writes storage (evidence: `web/src/lib/preferences/preferences-storage.ts`)
- HTTP API → Task engine: dispatches tasks (evidence: `README.md`)
- HTTP API → Task manager: manages tasks
- Task engine → Planner: runs planning (evidence: `README.md`)
- Task engine → Worker: dispatches work (evidence: `README.md`)
- Task engine → Deadline coordinator: coordinates deadlines (evidence: `server/engine.go`)
- Planner → Exploration graph: reads task graph (evidence: `README.md`)
- Worker → Agent tools: uses tools (evidence: `agent/worker.go`)
- Worker → LLM harness: runs agent loop
- Worker → Shared asset graph: writes discoveries (evidence: `README.md`)
- Worker → Exploration graph: writes findings (evidence: `README.md`)
- Worker → MITM traffic: routes target traffic (evidence: `README.md`)
- MITM traffic → Finding evidence: links packets (evidence: `README.md`)
- Worker → Knowledge RAG: retrieves context (evidence: `README.md`)
- Engineer → Report generation: requests delivery
- Report generation → Finding evidence: renders evidence
- Service startup → Task manager: creates manager (evidence: `cmd/antifox/main.go`)
