# cyojkoy/aigithubingest architecture

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

- Interactive diagram: https://gitdiagram.com/cyojkoy/aigithubingest
- Repository: https://github.com/cyojkoy/aigithubingest

## Overview

AiGithubIngest is a browser extension and standalone web UI that turns a pasted GitHub URL into a filtered, size-bounded repository digest for an AI chat. The main path is paste interception → policy and URL checks → background ingest → GitHub archive parsing → digest delivery as native attachments or pseudo-files. The graph preserves the popup configuration and site-specific upload adapters. Some subsystems are represented by their exact directories because their individual source was not sampled; edges are limited to relationships shown in excerpts, the source index, or README.

Main entry points: [`src/content/paste-handler.ts`](https://github.com/cyojkoy/aigithubingest/blob/main/src/content/paste-handler.ts) (Paste interception), [`src/core/ingest.ts`](https://github.com/cyojkoy/aigithubingest/blob/main/src/core/ingest.ts) (Ingest orchestrator), [`src/pseudo/pseudo-file-engine.ts`](https://github.com/cyojkoy/aigithubingest/blob/main/src/pseudo/pseudo-file-engine.ts) (Pseudo-file lifecycle), [`src/pseudo/submit-interceptor.ts`](https://github.com/cyojkoy/aigithubingest/blob/main/src/pseudo/submit-interceptor.ts) (Send interception)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_capture["Page Capture"]
  node_content["Paste interception<br/>[paste-handler.ts]"]
  node_policy["Site policy<br/>[policy.ts]"]
  node_resolver["Page resolution<br/>[policy-resolver.ts]"]
  node_guard["Ingest guard<br/>[ingest-guard.ts]"]
end

subgraph group_ingest["Repository Ingest"]
  node_background["Background worker<br/>[index.ts]"]
  node_ingest["Ingest orchestrator<br/>[ingest.ts]"]
  node_github["GitHub access<br/>[github-engine.ts]"]
  node_parser["URL parser<br/>[parser.ts]"]
  node_filter["File filtering<br/>[file-filter.ts]"]
  node_tree["Tree builder<br/>[tree-builder.ts]"]
  node_formatter["Digest formatter"]
  node_tokens["Token estimator<br/>[token-estimator.ts]"]
end

subgraph group_delivery["Chat Delivery"]
  node_real["Native upload adapters"]
  node_editor["Editor orchestrator"]
  node_writer["Editor writer<br/>[editor-writer.ts]"]
  node_pseudoengine["Pseudo-file lifecycle"]
  node_manager["Payload registry"]
  node_renderer["Metadata cards"]
  node_interceptor["Send interception"]
end

subgraph group_settings["Settings"]
  node_cache["Settings cache<br/>[storage-cache.ts]"]
  node_popup["Popup settings"]
  node_storage[("Browser sync storage")]
  node_standalone["Standalone UI<br/>[main.ts]"]
end

node_user(("Chat user"))
node_chat["AI chat page"]
node_githubservice["GitHub API / Codeload"]

node_user -->|"pastes URL"| node_chat
node_chat -->|"fires paste"| node_content
node_content -->|"checks access"| node_policy
node_content -->|"parses URL"| node_parser
node_content -->|"resolves editor"| node_resolver
node_content -->|"reads config"| node_cache
node_content -->|"acquires lock"| node_guard
node_content -->|"requests ingest"| node_background
node_background -->|"calls ingest"| node_ingest
node_ingest -->|"parses repository"| node_parser
node_ingest -->|"resolves branch"| node_github
node_github -.->|"fetches archive"| node_githubservice
node_ingest -.->|"downloads zipball"| node_githubservice
node_ingest -->|"filters files"| node_filter
node_ingest -->|"builds tree"| node_tree
node_ingest -->|"formats digest"| node_formatter
node_ingest -->|"estimates tokens"| node_tokens
node_background -.->|"returns result"| node_content
node_content -->|"splits output"| node_formatter
node_content -->|"mounts pseudo-files"| node_pseudoengine
node_pseudoengine -->|"registers payloads"| node_manager
node_pseudoengine -->|"renders cards"| node_renderer
node_pseudoengine -->|"attaches submit hook"| node_interceptor
node_content -->|"uploads real files"| node_editor
node_editor -->|"dispatches upload"| node_real
node_editor -->|"writes editor text"| node_writer
node_interceptor -->|"reads payloads"| node_manager
node_interceptor -->|"removes cards"| node_renderer
node_interceptor -->|"splices prompt"| node_writer
node_popup -->|"saves settings"| node_storage
node_cache -->|"loads changes"| node_storage
node_popup -->|"configures policy"| node_policy
node_user -.->|"configures options"| node_popup
node_user -.->|"submits URL"| node_standalone
node_standalone -->|"runs ingest"| node_ingest

click node_content "https://github.com/cyojkoy/aigithubingest/blob/main/src/content/paste-handler.ts"
click node_policy "https://github.com/cyojkoy/aigithubingest/blob/main/src/core/policy.ts"
click node_resolver "https://github.com/cyojkoy/aigithubingest/blob/main/src/content/policy-resolver.ts"
click node_cache "https://github.com/cyojkoy/aigithubingest/blob/main/src/content/storage-cache.ts"
click node_guard "https://github.com/cyojkoy/aigithubingest/blob/main/src/core/ingest-guard.ts"
click node_background "https://github.com/cyojkoy/aigithubingest/blob/main/src/background/index.ts"
click node_ingest "https://github.com/cyojkoy/aigithubingest/blob/main/src/core/ingest.ts"
click node_github "https://github.com/cyojkoy/aigithubingest/blob/main/src/core/github-engine.ts"
click node_parser "https://github.com/cyojkoy/aigithubingest/blob/main/src/core/parser.ts"
click node_filter "https://github.com/cyojkoy/aigithubingest/blob/main/src/core/file-filter.ts"
click node_tree "https://github.com/cyojkoy/aigithubingest/blob/main/src/core/tree-builder.ts"
click node_formatter "https://github.com/cyojkoy/aigithubingest/blob/main/src/core/output-formatter.ts"
click node_tokens "https://github.com/cyojkoy/aigithubingest/blob/main/src/core/token-estimator.ts"
click node_real "https://github.com/cyojkoy/aigithubingest/tree/main/src/dom/adapters"
click node_editor "https://github.com/cyojkoy/aigithubingest/blob/main/src/dom/universal-editor.ts"
click node_writer "https://github.com/cyojkoy/aigithubingest/blob/main/src/dom/editor-writer.ts"
click node_pseudoengine "https://github.com/cyojkoy/aigithubingest/blob/main/src/pseudo/pseudo-file-engine.ts"
click node_manager "https://github.com/cyojkoy/aigithubingest/blob/main/src/pseudo/pseudo-file-manager.ts"
click node_renderer "https://github.com/cyojkoy/aigithubingest/blob/main/src/pseudo/pseudo-file-renderer.ts"
click node_interceptor "https://github.com/cyojkoy/aigithubingest/blob/main/src/pseudo/submit-interceptor.ts"
click node_popup "https://github.com/cyojkoy/aigithubingest/tree/main/src/popup"
click node_standalone "https://github.com/cyojkoy/aigithubingest/blob/main/src/main.ts"

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_content,node_policy,node_resolver,node_guard,node_user toneBlue
class node_background,node_ingest,node_github,node_parser,node_filter,node_tree,node_formatter,node_tokens toneAmber
class node_real,node_editor,node_writer,node_pseudoengine,node_manager,node_renderer,node_interceptor,node_githubservice toneMint
class node_cache,node_popup,node_storage,node_standalone toneRose
class node_chat toneIndigo
```

## Components

### Page Capture

- [Paste interception](https://github.com/cyojkoy/aigithubingest/blob/main/src/content/paste-handler.ts): `src/content/paste-handler.ts`
- [Site policy](https://github.com/cyojkoy/aigithubingest/blob/main/src/core/policy.ts): `src/core/policy.ts`
- [Page resolution](https://github.com/cyojkoy/aigithubingest/blob/main/src/content/policy-resolver.ts): `src/content/policy-resolver.ts`
- [Ingest guard](https://github.com/cyojkoy/aigithubingest/blob/main/src/core/ingest-guard.ts): `src/core/ingest-guard.ts`

### Repository Ingest

- [Background worker](https://github.com/cyojkoy/aigithubingest/blob/main/src/background/index.ts): `src/background/index.ts`
- [Ingest orchestrator](https://github.com/cyojkoy/aigithubingest/blob/main/src/core/ingest.ts): `src/core/ingest.ts`
- [GitHub access](https://github.com/cyojkoy/aigithubingest/blob/main/src/core/github-engine.ts): `src/core/github-engine.ts`
- [URL parser](https://github.com/cyojkoy/aigithubingest/blob/main/src/core/parser.ts): `src/core/parser.ts`
- [File filtering](https://github.com/cyojkoy/aigithubingest/blob/main/src/core/file-filter.ts): `src/core/file-filter.ts`
- [Tree builder](https://github.com/cyojkoy/aigithubingest/blob/main/src/core/tree-builder.ts): `src/core/tree-builder.ts`
- [Digest formatter](https://github.com/cyojkoy/aigithubingest/blob/main/src/core/output-formatter.ts): `src/core/output-formatter.ts`
- [Token estimator](https://github.com/cyojkoy/aigithubingest/blob/main/src/core/token-estimator.ts): `src/core/token-estimator.ts`

### Chat Delivery

- [Native upload adapters](https://github.com/cyojkoy/aigithubingest/tree/main/src/dom/adapters): `src/dom/adapters`
- [Editor orchestrator](https://github.com/cyojkoy/aigithubingest/blob/main/src/dom/universal-editor.ts): `src/dom/universal-editor.ts`
- [Editor writer](https://github.com/cyojkoy/aigithubingest/blob/main/src/dom/editor-writer.ts): `src/dom/editor-writer.ts`
- [Pseudo-file lifecycle](https://github.com/cyojkoy/aigithubingest/blob/main/src/pseudo/pseudo-file-engine.ts): `src/pseudo/pseudo-file-engine.ts`
- [Payload registry](https://github.com/cyojkoy/aigithubingest/blob/main/src/pseudo/pseudo-file-manager.ts): `src/pseudo/pseudo-file-manager.ts`
- [Metadata cards](https://github.com/cyojkoy/aigithubingest/blob/main/src/pseudo/pseudo-file-renderer.ts): `src/pseudo/pseudo-file-renderer.ts`
- [Send interception](https://github.com/cyojkoy/aigithubingest/blob/main/src/pseudo/submit-interceptor.ts): `src/pseudo/submit-interceptor.ts`

### Settings

- [Settings cache](https://github.com/cyojkoy/aigithubingest/blob/main/src/content/storage-cache.ts): `src/content/storage-cache.ts`
- [Popup settings](https://github.com/cyojkoy/aigithubingest/tree/main/src/popup): `src/popup`
- **Browser sync storage**
- [Standalone UI](https://github.com/cyojkoy/aigithubingest/blob/main/src/main.ts): `src/main.ts`

### Other components

- **Chat user**
- **AI chat page**
- **GitHub API / Codeload**

## Connections

- Chat user → AI chat page: pastes URL
- AI chat page → Paste interception: fires paste
- Paste interception → Site policy: checks access (evidence: `src/content/paste-handler.ts`)
- Paste interception → URL parser: parses URL (evidence: `src/content/paste-handler.ts`)
- Paste interception → Page resolution: resolves editor (evidence: `src/content/paste-handler.ts`)
- Paste interception → Settings cache: reads config (evidence: `src/content/paste-handler.ts`)
- Paste interception → Ingest guard: acquires lock (evidence: `src/content/paste-handler.ts`)
- Paste interception → Background worker: requests ingest (evidence: `src/background/index.ts`)
- Background worker → Ingest orchestrator: calls ingest (evidence: `src/background/index.ts`)
- Ingest orchestrator → URL parser: parses repository (evidence: `src/core/ingest.ts`)
- Ingest orchestrator → GitHub access: resolves branch (evidence: `src/core/ingest.ts`)
- GitHub access → GitHub API / Codeload: fetches archive
- Ingest orchestrator → GitHub API / Codeload: downloads zipball
- Ingest orchestrator → File filtering: filters files (evidence: `src/core/ingest.ts`)
- Ingest orchestrator → Tree builder: builds tree (evidence: `src/core/ingest.ts`)
- Ingest orchestrator → Digest formatter: formats digest (evidence: `src/core/ingest.ts`)
- Ingest orchestrator → Token estimator: estimates tokens (evidence: `src/core/ingest.ts`)
- Background worker → Paste interception: returns result
- Paste interception → Digest formatter: splits output (evidence: `src/content/paste-handler.ts`)
- Paste interception → Pseudo-file lifecycle: mounts pseudo-files (evidence: `src/content/paste-handler.ts`)
- Pseudo-file lifecycle → Payload registry: registers payloads (evidence: `src/pseudo/pseudo-file-engine.ts`)
- Pseudo-file lifecycle → Metadata cards: renders cards (evidence: `src/pseudo/pseudo-file-engine.ts`)
- Pseudo-file lifecycle → Send interception: attaches submit hook (evidence: `src/pseudo/pseudo-file-engine.ts`)
- Paste interception → Editor orchestrator: uploads real files (evidence: `src/content/paste-handler.ts`)
- Editor orchestrator → Native upload adapters: dispatches upload (evidence: `src/dom/universal-editor.ts`)
- Editor orchestrator → Editor writer: writes editor text (evidence: `src/dom/universal-editor.ts`)
- Send interception → Payload registry: reads payloads (evidence: `src/pseudo/submit-interceptor.ts`)
- Send interception → Metadata cards: removes cards (evidence: `src/pseudo/submit-interceptor.ts`)
- Send interception → Editor writer: splices prompt (evidence: `src/pseudo/submit-interceptor.ts`)
- Popup settings → Browser sync storage: saves settings (evidence: `src/popup/storage-service.ts`)
- Settings cache → Browser sync storage: loads changes (evidence: `src/content/storage-cache.ts`)
- Popup settings → Site policy: configures policy (evidence: `src/popup/site-policy-view.ts`)
- Chat user → Popup settings: configures options
- Chat user → Standalone UI: submits URL
- Standalone UI → Ingest orchestrator: runs ingest (evidence: `src/main.ts`)
