# kilopal/ghostmark architecture

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

## Overview

GhostMark is a local-first toolkit for stripping AI provenance from text and files, with browser, CLI, and WASM interfaces. The main workflow accepts text or a file, dispatches to format-appropriate cleanup, and returns cleaned output; the eval harness can separately embed, score, and measure watermark-breaking. The README also describes browser AI rewriting, detection integrations, X-Ray scanning, and proofreading. Several of these capabilities are documented but their implementation wiring was not sampled, so those links are omitted or marked unverified.

Main entry points: [`playground/src/App.tsx`](https://github.com/kilopal/ghostmark/blob/main/playground/src/App.tsx) (Web playground), [`cli/src/main.rs`](https://github.com/kilopal/ghostmark/blob/main/cli/src/main.rs) (CLI commands), [`playground/src/wasm-worker.ts`](https://github.com/kilopal/ghostmark/blob/main/playground/src/wasm-worker.ts) (WASM worker), [`wasm/src/lib.rs`](https://github.com/kilopal/ghostmark/blob/main/wasm/src/lib.rs) (WASM API)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_interfaces["User interfaces"]
  node_extension["Browser extension<br/>[popup.js]"]
  node_playground["Web playground<br/>[App.tsx]"]
  node_cli["CLI commands<br/>[main.rs]"]
  node_worker["WASM worker<br/>[wasm-worker.ts]"]
end

subgraph group_engine["Scrubbing engine"]
  node_wasm_bindings["WASM bindings<br/>[ghostmark_wasm.js]"]
  node_wasm_api["WASM API<br/>[lib.rs]"]
  node_text_cleanup["Text scrubbing<br/>[text_scrubber.rs]"]
end

subgraph group_files["File cleanup"]
  node_image_cleanup["Image metadata<br/>[image_stripper.rs]"]
  node_document_cleanup["Document metadata"]
end

subgraph group_analysis["Watermark analysis"]
  node_eval["Watermark eval<br/>[eval.rs]"]
  node_xray["X-Ray scanning<br/>[App.tsx]"]
end

subgraph group_integrations["AI and detection"]
  node_local_ai["Local AI rewriting<br/>[App.tsx]"]
  node_ollama["Ollama inference<br/>[main.rs]"]
  node_gemini_api["Gemini detection API"]
  node_anthropic_api["Anthropic detection API"]
end

node_user(("User"))

node_user -->|"submits input"| node_playground
node_user -->|"submits input"| node_extension
node_user -->|"runs command"| node_cli
node_playground -.->|"dispatches work"| node_worker
node_worker -->|"calls bindings"| node_wasm_bindings
node_wasm_bindings -.->|"invokes WASM"| node_wasm_api
node_wasm_api -.->|"uses engine"| node_text_cleanup
node_wasm_api -.->|"uses engine"| node_image_cleanup
node_wasm_api -.->|"uses engine"| node_document_cleanup
node_cli -->|"cleans text"| node_text_cleanup
node_cli -->|"cleans images"| node_image_cleanup
node_cli -->|"cleans documents"| node_document_cleanup
node_cli -->|"runs evaluation"| node_eval
node_worker -->|"runs evaluation"| node_eval
node_worker -->|"strips image bytes"| node_image_cleanup
node_worker -->|"strips file metadata"| node_document_cleanup
node_playground -->|"scans files"| node_xray
node_playground -.->|"rewrites text"| node_local_ai
node_cli -->|"requests inference"| node_ollama
node_playground -.->|"checks watermark"| node_gemini_api
node_playground -.->|"checks watermark"| node_anthropic_api

click node_extension "https://github.com/kilopal/ghostmark/blob/main/extension/popup.js"
click node_playground "https://github.com/kilopal/ghostmark/blob/main/playground/src/App.tsx"
click node_cli "https://github.com/kilopal/ghostmark/blob/main/cli/src/main.rs"
click node_worker "https://github.com/kilopal/ghostmark/blob/main/playground/src/wasm-worker.ts"
click node_wasm_bindings "https://github.com/kilopal/ghostmark/blob/main/playground/src/pkg/ghostmark_wasm.js"
click node_wasm_api "https://github.com/kilopal/ghostmark/blob/main/wasm/src/lib.rs"
click node_text_cleanup "https://github.com/kilopal/ghostmark/blob/main/core/src/text_scrubber.rs"
click node_image_cleanup "https://github.com/kilopal/ghostmark/blob/main/core/src/image_stripper.rs"
click node_document_cleanup "https://github.com/kilopal/ghostmark/blob/main/core/src/document_stripper.rs"
click node_eval "https://github.com/kilopal/ghostmark/blob/main/core/src/eval.rs"
click node_xray "https://github.com/kilopal/ghostmark/blob/main/playground/src/App.tsx"
click node_local_ai "https://github.com/kilopal/ghostmark/blob/main/playground/src/App.tsx"
click node_ollama "https://github.com/kilopal/ghostmark/blob/main/cli/src/main.rs"

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_extension,node_playground,node_cli,node_worker,node_user toneBlue
class node_wasm_bindings,node_wasm_api,node_text_cleanup toneAmber
class node_image_cleanup,node_document_cleanup toneMint
class node_eval,node_xray toneRose
class node_local_ai,node_ollama,node_gemini_api,node_anthropic_api toneIndigo
```

## Components

### User interfaces

- [Browser extension](https://github.com/kilopal/ghostmark/blob/main/extension/popup.js): `extension/popup.js`
- [Web playground](https://github.com/kilopal/ghostmark/blob/main/playground/src/App.tsx): `playground/src/App.tsx`
- [CLI commands](https://github.com/kilopal/ghostmark/blob/main/cli/src/main.rs): `cli/src/main.rs`
- [WASM worker](https://github.com/kilopal/ghostmark/blob/main/playground/src/wasm-worker.ts): `playground/src/wasm-worker.ts`

### Scrubbing engine

- [WASM bindings](https://github.com/kilopal/ghostmark/blob/main/playground/src/pkg/ghostmark_wasm.js): `playground/src/pkg/ghostmark_wasm.js`
- [WASM API](https://github.com/kilopal/ghostmark/blob/main/wasm/src/lib.rs): `wasm/src/lib.rs`
- [Text scrubbing](https://github.com/kilopal/ghostmark/blob/main/core/src/text_scrubber.rs): `core/src/text_scrubber.rs`

### File cleanup

- [Image metadata](https://github.com/kilopal/ghostmark/blob/main/core/src/image_stripper.rs): `core/src/image_stripper.rs`
- [Document metadata](https://github.com/kilopal/ghostmark/blob/main/core/src/document_stripper.rs): `core/src/document_stripper.rs`

### Watermark analysis

- [Watermark eval](https://github.com/kilopal/ghostmark/blob/main/core/src/eval.rs): `core/src/eval.rs`
- [X-Ray scanning](https://github.com/kilopal/ghostmark/blob/main/playground/src/App.tsx): `playground/src/App.tsx`

### AI and detection

- [Local AI rewriting](https://github.com/kilopal/ghostmark/blob/main/playground/src/App.tsx): `playground/src/App.tsx`
- [Ollama inference](https://github.com/kilopal/ghostmark/blob/main/cli/src/main.rs): `cli/src/main.rs`
- **Gemini detection API**
- **Anthropic detection API**

### Other components

- **User**

## Connections

- User → Web playground: submits input (evidence: `README.md`)
- User → Browser extension: submits input (evidence: `README.md`)
- User → CLI commands: runs command (evidence: `README.md`)
- Web playground → WASM worker: dispatches work
- WASM worker → WASM bindings: calls bindings (evidence: `playground/src/wasm-worker.ts`)
- WASM bindings → WASM API: invokes WASM
- WASM API → Text scrubbing: uses engine (evidence: `README.md`)
- WASM API → Image metadata: uses engine (evidence: `README.md`)
- WASM API → Document metadata: uses engine (evidence: `README.md`)
- CLI commands → Text scrubbing: cleans text (evidence: `cli/src/main.rs`)
- CLI commands → Image metadata: cleans images (evidence: `cli/src/main.rs`)
- CLI commands → Document metadata: cleans documents (evidence: `cli/src/main.rs`)
- CLI commands → Watermark eval: runs evaluation (evidence: `cli/src/main.rs`)
- WASM worker → Watermark eval: runs evaluation (evidence: `playground/src/wasm-worker.ts`)
- WASM worker → Image metadata: strips image bytes (evidence: `playground/src/wasm-worker.ts`)
- WASM worker → Document metadata: strips file metadata (evidence: `playground/src/wasm-worker.ts`)
- Web playground → X-Ray scanning: scans files (evidence: `README.md`)
- Web playground → Local AI rewriting: rewrites text (evidence: `playground/src/App.tsx`)
- CLI commands → Ollama inference: requests inference (evidence: `cli/src/main.rs`)
- Web playground → Gemini detection API: checks watermark (evidence: `README.md`)
- Web playground → Anthropic detection API: checks watermark (evidence: `README.md`)
