# journey-ad/gemini-watermark-remover architecture

> Architecture diagram of the GitHub repository journey-ad/gemini-watermark-remover, 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/journey-ad/gemini-watermark-remover
- Repository: https://github.com/journey-ad/gemini-watermark-remover

## Overview

Gemini Watermark Remover is a local image and video watermark-removal product, exposed through browser workflows, a Chrome extension, a userscript, and a Node.js CLI/SDK. The principal image workflow detects a supported Gemini watermark, selects and evaluates a removal candidate, then returns a cleaned image for preview or download. Video processing is a separate capability, while userscript session and page-integration components connect Gemini previews and native copy/download actions to processing. Some subsystem links are documented or indexed rather than shown in excerpts; uncertain links are omitted.

Main entry points: [`src/video-app.js`](https://github.com/journey-ad/gemini-watermark-remover/blob/main/src/video-app.js) (Video interface), [`src/core/watermarkEngine.js`](https://github.com/journey-ad/gemini-watermark-remover/blob/main/src/core/watermarkEngine.js) (Watermark engine), [`src/userscript/index.js`](https://github.com/journey-ad/gemini-watermark-remover/blob/main/src/userscript/index.js) (Userscript integration), [`src/shared/imageProcessing.js`](https://github.com/journey-ad/gemini-watermark-remover/blob/main/src/shared/imageProcessing.js) (Image runtime)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_image["Image removal"]
  node_image_runtime["Image runtime<br/>[imageProcessing.js]"]
  node_engine["Watermark engine<br/>[watermarkEngine.js]"]
  node_catalog["Size catalog"]
  node_detector["Adaptive detection"]
  node_pipeline["Removal pipeline"]
  node_selection["Candidate selection"]
  node_quality["Candidate quality"]
  node_metrics["Restoration metrics"]
  node_alpha_maps["Embedded alpha maps"]
end

subgraph group_video["Video removal"]
  node_video_detector["Video detection"]
  node_video_catalog["Video watermark catalog"]
  node_video_backend["Video cleanup backends"]
  node_video_export["Video export<br/>[videoExport.js]"]
end

subgraph group_integration["Browser integrations"]
  node_extension["Chrome extension<br/>[contentMain.js]"]
  node_userscript["Userscript integration<br/>[index.js]"]
  node_action_context["Action context<br/>[actionContext.js]"]
  node_session_context["Session context"]
  node_session_store[("Session store")]
  node_page_bridge["Page processing bridge"]
  node_page_runtime["Page runtime"]
end

subgraph group_interfaces["Product interfaces"]
  node_image_ui["Image interface<br/>[app.js]"]
  node_cli["CLI command"]
  node_sdk["Node SDK<br/>[node.js]"]
  node_video_ui["Video interface<br/>[video-app.js]"]
end

node_user(("User"))
node_gemini(("Gemini page"))

node_user -->|"selects image"| node_image_ui
node_image_ui -->|"processes image"| node_image_runtime
node_image_runtime -->|"calls engine"| node_engine
node_engine -->|"processes pixels"| node_pipeline
node_engine -->|"loads maps"| node_alpha_maps
node_detector -->|"uses catalog"| node_catalog
node_selection -->|"queries catalog"| node_catalog
node_quality -->|"scores candidates"| node_metrics
node_quality -->|"reads maps"| node_alpha_maps
node_metrics -->|"uses detection"| node_detector
node_user -->|"runs command"| node_cli
node_cli -->|"calls SDK"| node_sdk
node_user -->|"selects video"| node_video_ui
node_video_ui -->|"loads catalog"| node_video_catalog
node_video_ui -->|"detects watermark"| node_video_detector
node_video_ui -.->|"cleans frames"| node_video_backend
node_video_ui -->|"exports video"| node_video_export
node_gemini -->|"hosts integration"| node_extension
node_gemini -->|"hosts integration"| node_userscript
node_userscript -->|"resolves actions"| node_action_context
node_action_context -->|"resolves session"| node_session_context
node_session_context -->|"reads session"| node_session_store
node_userscript -->|"uses bridge"| node_page_bridge
node_page_runtime -->|"uses bridge"| node_page_bridge
node_page_runtime -->|"processes image"| node_image_runtime

click node_image_ui "https://github.com/journey-ad/gemini-watermark-remover/blob/main/src/app.js"
click node_image_runtime "https://github.com/journey-ad/gemini-watermark-remover/blob/main/src/shared/imageProcessing.js"
click node_engine "https://github.com/journey-ad/gemini-watermark-remover/blob/main/src/core/watermarkEngine.js"
click node_catalog "https://github.com/journey-ad/gemini-watermark-remover/blob/main/src/core/geminiSizeCatalog.js"
click node_detector "https://github.com/journey-ad/gemini-watermark-remover/blob/main/src/core/adaptiveDetector.js"
click node_pipeline "https://github.com/journey-ad/gemini-watermark-remover/blob/main/src/core/watermarkProcessor.js"
click node_selection "https://github.com/journey-ad/gemini-watermark-remover/blob/main/src/core/pipelineInitialSelection.js"
click node_quality "https://github.com/journey-ad/gemini-watermark-remover/blob/main/src/core/pipelineCandidateQuality.js"
click node_metrics "https://github.com/journey-ad/gemini-watermark-remover/blob/main/src/core/restorationMetrics.js"
click node_alpha_maps "https://github.com/journey-ad/gemini-watermark-remover/blob/main/src/core/embeddedAlphaMaps.js"
click node_cli "https://github.com/journey-ad/gemini-watermark-remover/blob/main/src/cli/gwrRemoveCommand.js"
click node_sdk "https://github.com/journey-ad/gemini-watermark-remover/blob/main/src/sdk/node.js"
click node_video_ui "https://github.com/journey-ad/gemini-watermark-remover/blob/main/src/video-app.js"
click node_video_detector "https://github.com/journey-ad/gemini-watermark-remover/blob/main/src/video/videoWatermarkDetector.js"
click node_video_catalog "https://github.com/journey-ad/gemini-watermark-remover/blob/main/src/video/videoWatermarkCatalog.js"
click node_video_backend "https://github.com/journey-ad/gemini-watermark-remover/blob/main/src/video/videoCleanupBackends.js"
click node_video_export "https://github.com/journey-ad/gemini-watermark-remover/blob/main/src/video/videoExport.js"
click node_extension "https://github.com/journey-ad/gemini-watermark-remover/blob/main/src/extension/contentMain.js"
click node_userscript "https://github.com/journey-ad/gemini-watermark-remover/blob/main/src/userscript/index.js"
click node_action_context "https://github.com/journey-ad/gemini-watermark-remover/blob/main/src/userscript/actionContext.js"
click node_session_context "https://github.com/journey-ad/gemini-watermark-remover/blob/main/src/shared/imageSessionContext.js"
click node_session_store "https://github.com/journey-ad/gemini-watermark-remover/blob/main/src/shared/imageSessionStore.js"
click node_page_bridge "https://github.com/journey-ad/gemini-watermark-remover/blob/main/src/userscript/pageProcessBridge.js"
click node_page_runtime "https://github.com/journey-ad/gemini-watermark-remover/blob/main/src/page/pageProcessRuntime.js"

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_image_runtime,node_engine,node_catalog,node_detector,node_pipeline,node_selection,node_quality,node_metrics,node_alpha_maps,node_user toneBlue
class node_video_detector,node_video_catalog,node_video_backend,node_video_export toneAmber
class node_extension,node_userscript,node_action_context,node_session_context,node_session_store,node_page_bridge,node_page_runtime toneMint
class node_image_ui,node_cli,node_sdk,node_video_ui toneRose
class node_gemini toneIndigo
```

## Components

### Image removal

- [Image runtime](https://github.com/journey-ad/gemini-watermark-remover/blob/main/src/shared/imageProcessing.js): `src/shared/imageProcessing.js`
- [Watermark engine](https://github.com/journey-ad/gemini-watermark-remover/blob/main/src/core/watermarkEngine.js): `src/core/watermarkEngine.js`
- [Size catalog](https://github.com/journey-ad/gemini-watermark-remover/blob/main/src/core/geminiSizeCatalog.js): `src/core/geminiSizeCatalog.js`
- [Adaptive detection](https://github.com/journey-ad/gemini-watermark-remover/blob/main/src/core/adaptiveDetector.js): `src/core/adaptiveDetector.js`
- [Removal pipeline](https://github.com/journey-ad/gemini-watermark-remover/blob/main/src/core/watermarkProcessor.js): `src/core/watermarkProcessor.js`
- [Candidate selection](https://github.com/journey-ad/gemini-watermark-remover/blob/main/src/core/pipelineInitialSelection.js): `src/core/pipelineInitialSelection.js`
- [Candidate quality](https://github.com/journey-ad/gemini-watermark-remover/blob/main/src/core/pipelineCandidateQuality.js): `src/core/pipelineCandidateQuality.js`
- [Restoration metrics](https://github.com/journey-ad/gemini-watermark-remover/blob/main/src/core/restorationMetrics.js): `src/core/restorationMetrics.js`
- [Embedded alpha maps](https://github.com/journey-ad/gemini-watermark-remover/blob/main/src/core/embeddedAlphaMaps.js): `src/core/embeddedAlphaMaps.js`

### Video removal

- [Video detection](https://github.com/journey-ad/gemini-watermark-remover/blob/main/src/video/videoWatermarkDetector.js): `src/video/videoWatermarkDetector.js`
- [Video watermark catalog](https://github.com/journey-ad/gemini-watermark-remover/blob/main/src/video/videoWatermarkCatalog.js): `src/video/videoWatermarkCatalog.js`
- [Video cleanup backends](https://github.com/journey-ad/gemini-watermark-remover/blob/main/src/video/videoCleanupBackends.js): `src/video/videoCleanupBackends.js`
- [Video export](https://github.com/journey-ad/gemini-watermark-remover/blob/main/src/video/videoExport.js): `src/video/videoExport.js`

### Browser integrations

- [Chrome extension](https://github.com/journey-ad/gemini-watermark-remover/blob/main/src/extension/contentMain.js): `src/extension/contentMain.js`
- [Userscript integration](https://github.com/journey-ad/gemini-watermark-remover/blob/main/src/userscript/index.js): `src/userscript/index.js`
- [Action context](https://github.com/journey-ad/gemini-watermark-remover/blob/main/src/userscript/actionContext.js): `src/userscript/actionContext.js`
- [Session context](https://github.com/journey-ad/gemini-watermark-remover/blob/main/src/shared/imageSessionContext.js): `src/shared/imageSessionContext.js`
- [Session store](https://github.com/journey-ad/gemini-watermark-remover/blob/main/src/shared/imageSessionStore.js): `src/shared/imageSessionStore.js`
- [Page processing bridge](https://github.com/journey-ad/gemini-watermark-remover/blob/main/src/userscript/pageProcessBridge.js): `src/userscript/pageProcessBridge.js`
- [Page runtime](https://github.com/journey-ad/gemini-watermark-remover/blob/main/src/page/pageProcessRuntime.js): `src/page/pageProcessRuntime.js`

### Product interfaces

- [Image interface](https://github.com/journey-ad/gemini-watermark-remover/blob/main/src/app.js): `src/app.js`
- [CLI command](https://github.com/journey-ad/gemini-watermark-remover/blob/main/src/cli/gwrRemoveCommand.js): `src/cli/gwrRemoveCommand.js`
- [Node SDK](https://github.com/journey-ad/gemini-watermark-remover/blob/main/src/sdk/node.js): `src/sdk/node.js`
- [Video interface](https://github.com/journey-ad/gemini-watermark-remover/blob/main/src/video-app.js): `src/video-app.js`

### Other components

- **User**
- **Gemini page**

## Connections

- User → Image interface: selects image (evidence: `README.md`)
- Image interface → Image runtime: processes image (evidence: `src/app.js`)
- Image runtime → Watermark engine: calls engine (evidence: `src/shared/imageProcessing.js`)
- Watermark engine → Removal pipeline: processes pixels (evidence: `src/core/watermarkEngine.js`)
- Watermark engine → Embedded alpha maps: loads maps (evidence: `src/core/watermarkEngine.js`)
- Adaptive detection → Size catalog: uses catalog (evidence: `src/core/adaptiveDetector.js`)
- Candidate selection → Size catalog: queries catalog (evidence: `src/core/pipelineInitialSelection.js`)
- Candidate quality → Restoration metrics: scores candidates (evidence: `src/core/pipelineCandidateQuality.js`)
- Candidate quality → Embedded alpha maps: reads maps (evidence: `src/core/pipelineCandidateQuality.js`)
- Restoration metrics → Adaptive detection: uses detection (evidence: `src/core/restorationMetrics.js`)
- User → CLI command: runs command (evidence: `README.md`)
- CLI command → Node SDK: calls SDK (evidence: `src/cli/gwrRemoveCommand.js`)
- User → Video interface: selects video (evidence: `README.md`)
- Video interface → Video watermark catalog: loads catalog (evidence: `src/video-app.js`)
- Video interface → Video detection: detects watermark (evidence: `src/video/videoWatermarkDetector.js`)
- Video interface → Video cleanup backends: cleans frames
- Video interface → Video export: exports video (evidence: `src/video-app.js`)
- Gemini page → Chrome extension: hosts integration (evidence: `README.md`)
- Gemini page → Userscript integration: hosts integration (evidence: `README.md`)
- Userscript integration → Action context: resolves actions (evidence: `src/userscript/index.js`)
- Action context → Session context: resolves session (evidence: `src/userscript/actionContext.js`)
- Session context → Session store: reads session (evidence: `src/shared/imageSessionContext.js`)
- Userscript integration → Page processing bridge: uses bridge (evidence: `src/userscript/index.js`)
- Page runtime → Page processing bridge: uses bridge (evidence: `src/page/pageProcessRuntime.js`)
- Page runtime → Image runtime: processes image (evidence: `src/page/pageProcessRuntime.js`)
