# vmvarela/gh-replicate architecture

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

- Interactive diagram: https://gitdiagram.com/vmvarela/gh-replicate
- Repository: https://github.com/vmvarela/gh-replicate

## Overview

gh-replicate is a GitHub CLI extension that copies selected repository content into an existing GitHub repository. The main workflow parses the command, preflights source and destination, then applies selected refs, metadata, labels and releases; LFS objects are scanned, transferred and verified before refs are published. Release assets use a persistent journal to support safe retries. The orchestration is concentrated in replicate.go. Relationships for unsampled replication stages are limited to those documented in the README; the graph does not imply a transaction across stages.

Main entry points: [`replicate.go`](https://github.com/vmvarela/gh-replicate/blob/master/replicate.go) (Run orchestration), [`lfs_transfer.go`](https://github.com/vmvarela/gh-replicate/blob/master/lfs_transfer.go) (Object transfer), [`safeguards.go`](https://github.com/vmvarela/gh-replicate/blob/master/safeguards.go) (History scan safeguards), [`main.go`](https://github.com/vmvarela/gh-replicate/blob/master/main.go) (Command entry)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_command["Command and orchestration"]
  node_entry["Command entry<br/>[main.go]"]
  node_orchestrator["Run orchestration<br/>[replicate.go]"]
  node_preflight["Accounts and preflight<br/>[replicate.go]"]
end

subgraph group_replication["Repository replication"]
  node_refs["Refs replication<br/>[replicate.go]"]
  node_metadata["Metadata replication<br/>[replicate.go]"]
  node_labels["Labels replication<br/>[replicate.go]"]
end

subgraph group_lfs["Git LFS transfer"]
  node_lfs_scan["History scan safeguards<br/>[safeguards.go]"]
  node_pointer_parser["Pointer parsing<br/>[lfs_pointer.go]"]
  node_lfs_aux["Isolated LFS repository<br/>[lfs_auxiliary.go]"]
  node_lfs_transfer["Object transfer<br/>[lfs_transfer.go]"]
  node_object_verify["Object verification<br/>[lfs_objects.go]"]
end

subgraph group_assets["Release assets and state"]
  node_releases["Release replication<br/>[replicate.go]"]
  node_asset_journal[("Asset journal<br/>[journal.go]")]
end

node_user(("CLI user"))
node_github_api{{"GitHub API"}}
node_git_hosts{{"Git remotes"}}
node_github_lfs{{"GitHub LFS"}}

node_user -->|"runs command"| node_entry
node_entry -->|"calls run"| node_orchestrator
node_orchestrator -->|"preflights"| node_preflight
node_preflight -->|"reads repositories"| node_github_api
node_orchestrator -->|"replicates refs"| node_refs
node_orchestrator -->|"replicates metadata"| node_metadata
node_orchestrator -->|"replicates labels"| node_labels
node_orchestrator -->|"replicates releases"| node_releases
node_refs -->|"pushes refs"| node_git_hosts
node_metadata -->|"writes metadata"| node_github_api
node_labels -->|"writes labels"| node_github_api
node_releases -->|"reads and writes"| node_github_api
node_releases -->|"records staged assets"| node_asset_journal
node_orchestrator -->|"guards history scan"| node_lfs_scan
node_lfs_scan -.->|"classifies pointers"| node_pointer_parser
node_lfs_scan -.->|"prepares transfer"| node_lfs_aux
node_lfs_transfer -->|"runs Git LFS"| node_lfs_aux
node_lfs_transfer -->|"verifies downloads"| node_object_verify
node_lfs_transfer -->|"fetches and pushes"| node_github_lfs
node_orchestrator -->|"transfers before refs"| node_lfs_transfer

click node_entry "https://github.com/vmvarela/gh-replicate/blob/master/main.go"
click node_orchestrator "https://github.com/vmvarela/gh-replicate/blob/master/replicate.go"
click node_preflight "https://github.com/vmvarela/gh-replicate/blob/master/replicate.go"
click node_refs "https://github.com/vmvarela/gh-replicate/blob/master/replicate.go"
click node_metadata "https://github.com/vmvarela/gh-replicate/blob/master/replicate.go"
click node_labels "https://github.com/vmvarela/gh-replicate/blob/master/replicate.go"
click node_releases "https://github.com/vmvarela/gh-replicate/blob/master/replicate.go"
click node_asset_journal "https://github.com/vmvarela/gh-replicate/blob/master/journal.go"
click node_lfs_scan "https://github.com/vmvarela/gh-replicate/blob/master/safeguards.go"
click node_pointer_parser "https://github.com/vmvarela/gh-replicate/blob/master/lfs_pointer.go"
click node_lfs_aux "https://github.com/vmvarela/gh-replicate/blob/master/lfs_auxiliary.go"
click node_lfs_transfer "https://github.com/vmvarela/gh-replicate/blob/master/lfs_transfer.go"
click node_object_verify "https://github.com/vmvarela/gh-replicate/blob/master/lfs_objects.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_entry,node_orchestrator,node_preflight,node_user toneBlue
class node_refs,node_metadata,node_labels toneAmber
class node_lfs_scan,node_pointer_parser,node_lfs_aux,node_lfs_transfer,node_object_verify,node_github_api toneMint
class node_releases,node_asset_journal toneRose
class node_git_hosts,node_github_lfs toneIndigo
```

## Components

### Command and orchestration

- [Command entry](https://github.com/vmvarela/gh-replicate/blob/master/main.go): `main.go`
- [Run orchestration](https://github.com/vmvarela/gh-replicate/blob/master/replicate.go): `replicate.go`
- [Accounts and preflight](https://github.com/vmvarela/gh-replicate/blob/master/replicate.go): `replicate.go`

### Repository replication

- [Refs replication](https://github.com/vmvarela/gh-replicate/blob/master/replicate.go): `replicate.go`
- [Metadata replication](https://github.com/vmvarela/gh-replicate/blob/master/replicate.go): `replicate.go`
- [Labels replication](https://github.com/vmvarela/gh-replicate/blob/master/replicate.go): `replicate.go`

### Git LFS transfer

- [History scan safeguards](https://github.com/vmvarela/gh-replicate/blob/master/safeguards.go): `safeguards.go`
- [Pointer parsing](https://github.com/vmvarela/gh-replicate/blob/master/lfs_pointer.go): `lfs_pointer.go`
- [Isolated LFS repository](https://github.com/vmvarela/gh-replicate/blob/master/lfs_auxiliary.go): `lfs_auxiliary.go`
- [Object transfer](https://github.com/vmvarela/gh-replicate/blob/master/lfs_transfer.go): `lfs_transfer.go`
- [Object verification](https://github.com/vmvarela/gh-replicate/blob/master/lfs_objects.go): `lfs_objects.go`

### Release assets and state

- [Release replication](https://github.com/vmvarela/gh-replicate/blob/master/replicate.go): `replicate.go`
- [Asset journal](https://github.com/vmvarela/gh-replicate/blob/master/journal.go): `journal.go`

### Other components

- **CLI user**
- **GitHub API**
- **Git remotes**
- **GitHub LFS**

## Connections

- CLI user → Command entry: runs command (evidence: `README.md`)
- Command entry → Run orchestration: calls run (evidence: `main.go`)
- Run orchestration → Accounts and preflight: preflights (evidence: `README.md`)
- Accounts and preflight → GitHub API: reads repositories (evidence: `README.md`)
- Run orchestration → Refs replication: replicates refs (evidence: `README.md`)
- Run orchestration → Metadata replication: replicates metadata (evidence: `README.md`)
- Run orchestration → Labels replication: replicates labels (evidence: `README.md`)
- Run orchestration → Release replication: replicates releases (evidence: `README.md`)
- Refs replication → Git remotes: pushes refs (evidence: `README.md`)
- Metadata replication → GitHub API: writes metadata (evidence: `README.md`)
- Labels replication → GitHub API: writes labels (evidence: `README.md`)
- Release replication → GitHub API: reads and writes (evidence: `README.md`)
- Release replication → Asset journal: records staged assets (evidence: `replicate.go`)
- Run orchestration → History scan safeguards: guards history scan (evidence: `replicate.go`)
- History scan safeguards → Pointer parsing: classifies pointers
- History scan safeguards → Isolated LFS repository: prepares transfer
- Object transfer → Isolated LFS repository: runs Git LFS (evidence: `lfs_transfer.go`)
- Object transfer → Object verification: verifies downloads (evidence: `lfs_transfer.go`)
- Object transfer → GitHub LFS: fetches and pushes (evidence: `README.md`)
- Run orchestration → Object transfer: transfers before refs (evidence: `README.md`)
