# justin-panagos/relay-v2 architecture

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

- Interactive diagram: https://gitdiagram.com/justin-panagos/relay-v2
- Repository: https://github.com/justin-panagos/relay-v2

## Overview

ReLay is a Tauri desktop download manager with a browser-extension entry point. Its main user flow is to submit a URL or torrent, manage the transfer and queue, scan completed files, then review downloads or quarantine results. The graph also preserves the documented ICP threat network, Pro licensing, and developer/community capabilities. Some command and integration internals are unsampled; those branches are included at the exact supported paths, with relationships shown only where the excerpts or README support them.

Main entry points: [`src-tauri/src/commands/download.rs`](https://github.com/justin-panagos/relay-v2/blob/develop/src-tauri/src/commands/download.rs) (Tauri command handlers), [`src/scripts/main.js`](https://github.com/justin-panagos/relay-v2/blob/develop/src/scripts/main.js) (Desktop interface), [`src-tauri/src/db/mod.rs`](https://github.com/justin-panagos/relay-v2/blob/develop/src-tauri/src/db/mod.rs) (SQLite state), [`src-tauri/src/download/chunked.rs`](https://github.com/justin-panagos/relay-v2/blob/develop/src-tauri/src/download/chunked.rs) (HTTP chunked transfers)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["User Interfaces"]
  node_desktop_ui["Desktop interface<br/>[main.js]"]
  node_download_ui["Download controls<br/>[downloads.js]"]
  node_torrent_ui["Torrent controls<br/>[torrent.js]"]
  node_community_ui["Community and developer tools<br/>[community.js]"]
  node_extension["Browser interception and popup<br/>[background.js]"]
  node_native_host["Native messaging host<br/>[mod.rs]"]
  node_quarantine_ui["Quarantine review<br/>[quarantine.js]"]
end

subgraph group_transfer["Download Runtime"]
  node_commands["Tauri command handlers<br/>[download.rs]"]
  node_http_download["HTTP chunked transfers<br/>[chunked.rs]"]
  node_lifecycle["Download lifecycle and queue<br/>[lifecycle.rs]"]
  node_torrent["Torrent engine<br/>[mod.rs]"]
  node_database[("SQLite state<br/>[mod.rs]")]
end

subgraph group_safety["Shield Security"]
  node_shield_pipeline["Shield scan pipeline<br/>[mod.rs]"]
  node_shield_layers["Seven scan layers<br/>[layer7_sandbox.rs]"]
end

subgraph group_network["ICP Threat Network"]
  node_icp_runtime["ICP agent and sync<br/>[sync.rs]"]
  node_icp_canisters{{"Pattern, identity, governance canisters<br/>[lib.rs]"}}
  node_governance_ui["Threat community interface<br/>[community.js]"]
  node_developer_api["Public threat API<br/>[developer.rs]"]
end

subgraph group_services["Account Services"]
  node_pro_licence["Pro licensing gates<br/>[mod.rs]"]
  node_payments{{"Paystack and Cloudflare Worker<br/>[index.js]"}}
end

node_user(("Desktop user"))
node_browser(("Browser user"))
node_web(("Web sources and peers"))

node_user -->|"uses"| node_desktop_ui
node_browser -->|"intercepts downloads"| node_extension
node_extension -->|"sends messages"| node_native_host
node_native_host -->|"queues and reads status"| node_database
node_desktop_ui -->|"invokes commands"| node_commands
node_desktop_ui -->|"delegates controls"| node_download_ui
node_desktop_ui -->|"loads torrents"| node_torrent_ui
node_desktop_ui -->|"loads community"| node_community_ui
node_desktop_ui -->|"loads quarantine"| node_quarantine_ui
node_commands -->|"starts transfers"| node_http_download
node_commands -->|"manages transfer state"| node_lifecycle
node_commands -.->|"dispatches torrent actions"| node_torrent
node_http_download -->|"fetches file ranges"| node_web
node_torrent -->|"discovers peers and transfers"| node_web
node_http_download -->|"updates transfer state"| node_database
node_lifecycle -.->|"persists lifecycle"| node_database
node_torrent -.->|"records torrent state"| node_database
node_http_download -->|"scans completed files"| node_shield_pipeline
node_shield_pipeline -->|"runs layer checks"| node_shield_layers
node_shield_pipeline -.->|"records verdicts"| node_database
node_quarantine_ui -.->|"requests review actions"| node_commands
node_shield_pipeline -->|"checks threat intelligence"| node_icp_runtime
node_icp_runtime -->|"syncs and queries"| node_icp_canisters
node_governance_ui -.->|"submits community actions"| node_commands
node_developer_api -->|"uses ICP services"| node_icp_runtime
node_developer_api -->|"serves developer intelligence"| node_user
node_commands -->|"checks feature access"| node_pro_licence
node_pro_licence -->|"uses verified licence state"| node_icp_runtime
node_payments -.->|"supports subscription flow"| node_pro_licence

click node_desktop_ui "https://github.com/justin-panagos/relay-v2/blob/develop/src/scripts/main.js"
click node_download_ui "https://github.com/justin-panagos/relay-v2/blob/develop/src/scripts/downloads.js"
click node_torrent_ui "https://github.com/justin-panagos/relay-v2/blob/develop/src/scripts/torrent.js"
click node_community_ui "https://github.com/justin-panagos/relay-v2/blob/develop/src/scripts/community.js"
click node_extension "https://github.com/justin-panagos/relay-v2/blob/develop/extension/background.js"
click node_native_host "https://github.com/justin-panagos/relay-v2/blob/develop/src-tauri/src/native_messaging/mod.rs"
click node_commands "https://github.com/justin-panagos/relay-v2/blob/develop/src-tauri/src/commands/download.rs"
click node_http_download "https://github.com/justin-panagos/relay-v2/blob/develop/src-tauri/src/download/chunked.rs"
click node_lifecycle "https://github.com/justin-panagos/relay-v2/blob/develop/src-tauri/src/download/lifecycle.rs"
click node_torrent "https://github.com/justin-panagos/relay-v2/blob/develop/src-tauri/src/torrent/mod.rs"
click node_database "https://github.com/justin-panagos/relay-v2/blob/develop/src-tauri/src/db/mod.rs"
click node_shield_pipeline "https://github.com/justin-panagos/relay-v2/blob/develop/src-tauri/src/shield/mod.rs"
click node_shield_layers "https://github.com/justin-panagos/relay-v2/blob/develop/src-tauri/src/shield/layer7_sandbox.rs"
click node_quarantine_ui "https://github.com/justin-panagos/relay-v2/blob/develop/src/scripts/quarantine.js"
click node_icp_runtime "https://github.com/justin-panagos/relay-v2/blob/develop/src-tauri/src/icp/sync.rs"
click node_icp_canisters "https://github.com/justin-panagos/relay-v2/blob/develop/icp/pattern/src/lib.rs"
click node_governance_ui "https://github.com/justin-panagos/relay-v2/blob/develop/src/scripts/community.js"
click node_developer_api "https://github.com/justin-panagos/relay-v2/blob/develop/src-tauri/src/commands/developer.rs"
click node_pro_licence "https://github.com/justin-panagos/relay-v2/blob/develop/src-tauri/src/pro/mod.rs"
click node_payments "https://github.com/justin-panagos/relay-v2/blob/develop/worker/index.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_desktop_ui,node_download_ui,node_torrent_ui,node_community_ui,node_extension,node_native_host,node_quarantine_ui,node_user,node_browser toneBlue
class node_commands,node_http_download,node_lifecycle,node_torrent,node_database toneAmber
class node_shield_pipeline,node_shield_layers toneMint
class node_icp_runtime,node_icp_canisters,node_governance_ui,node_developer_api toneRose
class node_pro_licence,node_payments,node_web toneIndigo
```

## Components

### User Interfaces

- [Desktop interface](https://github.com/justin-panagos/relay-v2/blob/develop/src/scripts/main.js): `src/scripts/main.js`
- [Download controls](https://github.com/justin-panagos/relay-v2/blob/develop/src/scripts/downloads.js): `src/scripts/downloads.js`
- [Torrent controls](https://github.com/justin-panagos/relay-v2/blob/develop/src/scripts/torrent.js): `src/scripts/torrent.js`
- [Community and developer tools](https://github.com/justin-panagos/relay-v2/blob/develop/src/scripts/community.js): `src/scripts/community.js`
- [Browser interception and popup](https://github.com/justin-panagos/relay-v2/blob/develop/extension/background.js): `extension/background.js`
- [Native messaging host](https://github.com/justin-panagos/relay-v2/blob/develop/src-tauri/src/native_messaging/mod.rs): `src-tauri/src/native_messaging/mod.rs`
- [Quarantine review](https://github.com/justin-panagos/relay-v2/blob/develop/src/scripts/quarantine.js): `src/scripts/quarantine.js`

### Download Runtime

- [Tauri command handlers](https://github.com/justin-panagos/relay-v2/blob/develop/src-tauri/src/commands/download.rs): `src-tauri/src/commands/download.rs`
- [HTTP chunked transfers](https://github.com/justin-panagos/relay-v2/blob/develop/src-tauri/src/download/chunked.rs): `src-tauri/src/download/chunked.rs`
- [Download lifecycle and queue](https://github.com/justin-panagos/relay-v2/blob/develop/src-tauri/src/download/lifecycle.rs): `src-tauri/src/download/lifecycle.rs`
- [Torrent engine](https://github.com/justin-panagos/relay-v2/blob/develop/src-tauri/src/torrent/mod.rs): `src-tauri/src/torrent/mod.rs`
- [SQLite state](https://github.com/justin-panagos/relay-v2/blob/develop/src-tauri/src/db/mod.rs): `src-tauri/src/db/mod.rs`

### Shield Security

- [Shield scan pipeline](https://github.com/justin-panagos/relay-v2/blob/develop/src-tauri/src/shield/mod.rs): `src-tauri/src/shield/mod.rs`
- [Seven scan layers](https://github.com/justin-panagos/relay-v2/blob/develop/src-tauri/src/shield/layer7_sandbox.rs): `src-tauri/src/shield/layer7_sandbox.rs`

### ICP Threat Network

- [ICP agent and sync](https://github.com/justin-panagos/relay-v2/blob/develop/src-tauri/src/icp/sync.rs): `src-tauri/src/icp/sync.rs`
- [Pattern, identity, governance canisters](https://github.com/justin-panagos/relay-v2/blob/develop/icp/pattern/src/lib.rs): `icp/pattern/src/lib.rs`
- [Threat community interface](https://github.com/justin-panagos/relay-v2/blob/develop/src/scripts/community.js): `src/scripts/community.js`
- [Public threat API](https://github.com/justin-panagos/relay-v2/blob/develop/src-tauri/src/commands/developer.rs): `src-tauri/src/commands/developer.rs`

### Account Services

- [Pro licensing gates](https://github.com/justin-panagos/relay-v2/blob/develop/src-tauri/src/pro/mod.rs): `src-tauri/src/pro/mod.rs`
- [Paystack and Cloudflare Worker](https://github.com/justin-panagos/relay-v2/blob/develop/worker/index.js): `worker/index.js`

### Other components

- **Desktop user**
- **Browser user**
- **Web sources and peers**

## Connections

- Desktop user → Desktop interface: uses (evidence: `README.md`)
- Browser user → Browser interception and popup: intercepts downloads (evidence: `README.md`)
- Browser interception and popup → Native messaging host: sends messages (evidence: `src-tauri/src/native_messaging/mod.rs`)
- Native messaging host → SQLite state: queues and reads status (evidence: `src-tauri/src/native_messaging/mod.rs`)
- Desktop interface → Tauri command handlers: invokes commands (evidence: `src/scripts/main.js`)
- Desktop interface → Download controls: delegates controls (evidence: `src/scripts/main.js`)
- Desktop interface → Torrent controls: loads torrents (evidence: `src/scripts/main.js`)
- Desktop interface → Community and developer tools: loads community (evidence: `src/scripts/main.js`)
- Desktop interface → Quarantine review: loads quarantine (evidence: `src/scripts/main.js`)
- Tauri command handlers → HTTP chunked transfers: starts transfers (evidence: `src-tauri/src/commands/download.rs`)
- Tauri command handlers → Download lifecycle and queue: manages transfer state (evidence: `src-tauri/src/commands/download.rs`)
- Tauri command handlers → Torrent engine: dispatches torrent actions
- HTTP chunked transfers → Web sources and peers: fetches file ranges (evidence: `README.md`)
- Torrent engine → Web sources and peers: discovers peers and transfers (evidence: `README.md`)
- HTTP chunked transfers → SQLite state: updates transfer state (evidence: `src-tauri/src/download/mod.rs`)
- Download lifecycle and queue → SQLite state: persists lifecycle (evidence: `src-tauri/src/download/lifecycle.rs`)
- Torrent engine → SQLite state: records torrent state (evidence: `src-tauri/src/torrent/mod.rs`)
- HTTP chunked transfers → Shield scan pipeline: scans completed files (evidence: `src-tauri/src/download/mod.rs`)
- Shield scan pipeline → Seven scan layers: runs layer checks (evidence: `src-tauri/src/shield/mod.rs`)
- Shield scan pipeline → SQLite state: records verdicts (evidence: `src-tauri/src/shield/mod.rs`)
- Quarantine review → Tauri command handlers: requests review actions
- Shield scan pipeline → ICP agent and sync: checks threat intelligence (evidence: `src-tauri/src/shield/mod.rs`)
- ICP agent and sync → Pattern, identity, governance canisters: syncs and queries
- Threat community interface → Tauri command handlers: submits community actions
- Public threat API → ICP agent and sync: uses ICP services (evidence: `src-tauri/src/commands/developer.rs`)
- Public threat API → Desktop user: serves developer intelligence (evidence: `README.md`)
- Tauri command handlers → Pro licensing gates: checks feature access (evidence: `src-tauri/src/commands/download.rs`)
- Pro licensing gates → ICP agent and sync: uses verified licence state (evidence: `src-tauri/src/pro/mod.rs`)
- Paystack and Cloudflare Worker → Pro licensing gates: supports subscription flow (evidence: `README.md`)
