# xecipher/copygit architecture

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

- Interactive diagram: https://gitdiagram.com/xecipher/copygit
- Repository: https://github.com/xecipher/copygit

## Overview

CopyGit turns a GitHub repository URL into a selective, AI-ready text bundle. The user supplies a URL and optional token; the Angular app discovers repository metadata and branches, retrieves a branch tree, supports file selection, then requests selected contents for in-memory extraction and formatting before showing estimates and enabling copy or download. The README documents the broader selection, private-repository, theme, and output capabilities; the supplied excerpts do not show every UI binding or all API implementation details.

Main entry points: [`frontend/src/app/app.component.ts`](https://github.com/xecipher/copygit/blob/main/frontend/src/app/app.component.ts) (App workflow), [`frontend/src/app/services/api.service.ts`](https://github.com/xecipher/copygit/blob/main/frontend/src/app/services/api.service.ts) (API client), [`frontend/api/process.js`](https://github.com/xecipher/copygit/blob/main/frontend/api/process.js) (Archive extraction), [`frontend/src/app/components/tree-node/tree-node.component.ts`](https://github.com/xecipher/copygit/blob/main/frontend/src/app/components/tree-node/tree-node.component.ts) (File tree UI)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Browser app"]
  node_app["App workflow<br/>[app.component.ts]"]
  node_tree["File tree UI"]
  node_api_client["API client<br/>[api.service.ts]"]
end

subgraph group_discovery["Repository discovery"]
  node_repo_info["Repo metadata<br/>[repo-info.js]"]
  node_latest_commit["Latest commit<br/>[latest-commit.js]"]
  node_analyzer["Tree analysis<br/>[analyze.js]"]
end

subgraph group_bundle["Bundle generation"]
  node_process["Archive extraction<br/>[process.js]"]
end

subgraph group_integrations["External services"]
  node_github{{"GitHub API"}}
  node_browser_storage[("Browser storage")]
  node_clipboard["Clipboard"]
  node_download["Text download"]
end

node_user(("Developer"))

node_user -->|"submits URL"| node_app
node_app -->|"requests data"| node_api_client
node_api_client -->|"posts metadata request"| node_repo_info
node_repo_info -->|"fetches repo and branches"| node_github
node_api_client -->|"posts commit request"| node_latest_commit
node_latest_commit -->|"fetches branch commit"| node_github
node_api_client -->|"posts tree request"| node_analyzer
node_analyzer -->|"fetches recursive tree"| node_github
node_app -->|"renders selection tree"| node_tree
node_tree -->|"emits selection changes"| node_app
node_app -->|"requests selected files"| node_api_client
node_api_client -->|"posts selected paths"| node_process
node_process -->|"streams repository tarball"| node_github
node_process -->|"returns formatted bundle"| node_api_client
node_api_client -->|"returns results"| node_app
node_app -->|"reads and saves preferences"| node_browser_storage
node_app -->|"copies bundle"| node_clipboard
node_app -->|"downloads bundle"| node_download
node_app -->|"presents bundle and estimates"| node_user

click node_app "https://github.com/xecipher/copygit/blob/main/frontend/src/app/app.component.ts"
click node_tree "https://github.com/xecipher/copygit/blob/main/frontend/src/app/components/tree-node/tree-node.component.ts"
click node_api_client "https://github.com/xecipher/copygit/blob/main/frontend/src/app/services/api.service.ts"
click node_repo_info "https://github.com/xecipher/copygit/blob/main/frontend/api/repo-info.js"
click node_latest_commit "https://github.com/xecipher/copygit/blob/main/frontend/api/latest-commit.js"
click node_analyzer "https://github.com/xecipher/copygit/blob/main/frontend/api/analyze.js"
click node_process "https://github.com/xecipher/copygit/blob/main/frontend/api/process.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_app,node_tree,node_api_client toneBlue
class node_repo_info,node_latest_commit,node_analyzer toneAmber
class node_process toneMint
class node_github,node_browser_storage,node_clipboard,node_download toneRose
class node_user toneIndigo
```

## Components

### Browser app

- [App workflow](https://github.com/xecipher/copygit/blob/main/frontend/src/app/app.component.ts): `frontend/src/app/app.component.ts`
- [File tree UI](https://github.com/xecipher/copygit/blob/main/frontend/src/app/components/tree-node/tree-node.component.ts): `frontend/src/app/components/tree-node/tree-node.component.ts`
- [API client](https://github.com/xecipher/copygit/blob/main/frontend/src/app/services/api.service.ts): `frontend/src/app/services/api.service.ts`

### Repository discovery

- [Repo metadata](https://github.com/xecipher/copygit/blob/main/frontend/api/repo-info.js): `frontend/api/repo-info.js`
- [Latest commit](https://github.com/xecipher/copygit/blob/main/frontend/api/latest-commit.js): `frontend/api/latest-commit.js`
- [Tree analysis](https://github.com/xecipher/copygit/blob/main/frontend/api/analyze.js): `frontend/api/analyze.js`

### Bundle generation

- [Archive extraction](https://github.com/xecipher/copygit/blob/main/frontend/api/process.js): `frontend/api/process.js`

### External services

- **GitHub API**
- **Browser storage**
- **Clipboard**
- **Text download**

### Other components

- **Developer**

## Connections

- Developer → App workflow: submits URL
- App workflow → API client: requests data
- API client → Repo metadata: posts metadata request
- Repo metadata → GitHub API: fetches repo and branches
- API client → Latest commit: posts commit request
- Latest commit → GitHub API: fetches branch commit
- API client → Tree analysis: posts tree request
- Tree analysis → GitHub API: fetches recursive tree
- App workflow → File tree UI: renders selection tree
- File tree UI → App workflow: emits selection changes
- App workflow → API client: requests selected files
- API client → Archive extraction: posts selected paths
- Archive extraction → GitHub API: streams repository tarball
- Archive extraction → API client: returns formatted bundle
- API client → App workflow: returns results
- App workflow → Browser storage: reads and saves preferences
- App workflow → Clipboard: copies bundle
- App workflow → Text download: downloads bundle
- App workflow → Developer: presents bundle and estimates
