# yashk-arch/repoowl-extension architecture

> Architecture diagram of the GitHub repository yashk-arch/repoowl-extension, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-07-20). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/yashk-arch/repoowl-extension
- Repository: https://github.com/yashk-arch/repoowl-extension

## Overview

#### Purpose and entry points
RepoOwl is a GitHub Chrome extension for AI-assisted issue triage: it detects likely duplicates and presents technical insights inside GitHub’s native issue/PR UI. The primary client runtime is Manifest V3, with React/Vite popup and settings surfaces. Backend persistence and event processing use Supabase; Groq/Llama provides inference.

Key entry points: `extension/manifest.json`, `extension/src/background.js`, `extension/src/content/index.js`, `supabase/functions/registry/index.ts`.

#### Browser-extension integration layer
The manifest launches a background service worker and content scripts on GitHub pages. Content scripts inspect GitHub context and inject non-destructive UI into issue lists, issue details, PR details, and sidebars.

Core paths:
- `extension/src/content/index.js`
- `extension/src/content/issueDetailInjector.js`
- `extension/src/content/prDetailInjector.js`

`extension/src/lib/githubContext.js` is the boundary for deriving repository, issue, and page identity from GitHub URLs/DOM. This keeps GitHub-specific detection separate from downstream analysis and rendering.

#### In-page triage and insight presentation
Injected components retrieve persisted analysis and render badges, cards, or an on-demand overlay rather than replacing GitHub UI. This is the user-facing read path: GitHub page context → issue-insight fetch → DOM/React injection.

Core paths:
- `extension/src/content/fetchIssueInsights.js`
- `extension/src/content/badgeInjector.js`
- `extension/src/content/sidebarCard.js`
- `extension/src/overlay/InsightsOverlay.jsx`

The overlay provides a richer React-based display, while content injectors bridge React/UI output to arbitrary GitHub DOM locations.

#### Background orchestration and GitHub installation
The extension background process centralizes extension lifecycle work and GitHub integration/installation behavior. It is the durable browser-side control boundary for actions that should not be tied to a single GitHub tab.

Core paths:
- `extension/src/background.js`
- `extension/src/background/githubInstaller.js`
- `extension/src/prTriage.js`

#### Multi-tenant mediator and Supabase access
The v0.1.1 architecture uses a central registry/mediator so contributors can discover a repository maintainer’s Supabase connection without manually entering shared configuration. The extension’s Supabase client accesses this service; the Edge Function registry is the server-side counterpart.

Core paths:
- `extension/src/lib/supabase.js`
- `supabase/functions/registry/index.ts`
- `supabase/migrations/004_multi_tenant.sql`

Supabase provides PostgreSQL, Edge Functions, and real-time/service APIs. Schema evolution establishes issue identity, stronger RLS, and multi-tenant ownership boundaries.

#### Event-driven analysis pipeline
GitHub webhooks are intended to trigger processing when issues open. The backend persists issue data and AI-generated analysis; the extension later reads those results while viewing GitHub. Inference is performed through the Groq API using Llama 3.3 Versatile.

Core paths:
- `database-schema.sql`
- `supabase/migrations/001_initial_schema.sql`
- `supabase/migrations/003_tighten_rls.sql`

A deployment/documentation mismatch exists: the README names a `github-webhook` Edge Function, but the supplied tree exposes only `supabase/functions/registry/index.ts`; verify the webhook processor’s location or deployment configuration.

#### Prompting and response contract
Shared JavaScript code centralizes prompt composition, historical-context formatting, and the expected Groq response schema. This is the contract boundary between triage data and model output, reusable by browser and backend consumers.

Core paths:
- `shared/prompts/defaultPrompt.js`
- `shared/utils/renderPrompt.js`
- `shared/schemas/groqResponseSchema.js`

#### User configuration surfaces
The popup and options pages expose operational controls such as repository tracking, model configuration, prompt settings, and maintainer registration/sync status. These screens configure or invoke the mediator-backed workflow rather than serving as the main GitHub-page experience.

Core paths:
- `extension/src/popup/PopupApp.jsx`
- `extension/src/options/main.jsx`
- `extension/src/settings/TrackedRepos.jsx`

Main entry points: [`extension/src/content/index.js`](https://github.com/yashk-arch/repoowl-extension/blob/main/extension/src/content/index.js) (Content runtime), [`extension/src/lib/supabase.js`](https://github.com/yashk-arch/repoowl-extension/blob/main/extension/src/lib/supabase.js) (Supabase client), [`extension/src/content/fetchIssueInsights.js`](https://github.com/yashk-arch/repoowl-extension/blob/main/extension/src/content/fetchIssueInsights.js) (Insight reader), [`extension/src/background.js`](https://github.com/yashk-arch/repoowl-extension/blob/main/extension/src/background.js) (Background worker)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_browser["Chrome extension"]
  node_manifest["Extension manifest<br/>MV3 entrypoint<br/>[manifest.json]"]
  node_content["Content runtime<br/>content scripts<br/>[index.js]"]
  node_github_context["GitHub context<br/>page identity boundary<br/>[githubContext.js]"]
  node_issue_pr_injectors["Issue and PR injectors<br/>DOM integration"]
  node_insight_fetch["Insight reader<br/>analysis fetch"]
  node_page_ui["Badges, cards, overlay<br/>in-page React UI<br/>[badgeInjector.js]"]
  node_background["Background worker<br/>service worker<br/>[background.js]"]
  node_installer["GitHub installer<br/>installation integration<br/>[githubInstaller.js]"]
  node_settings["Popup and settings<br/>configuration UI<br/>[PopupApp.jsx]"]
  node_supabase_client["Supabase client<br/>backend access<br/>[supabase.js]"]
end

subgraph group_backend["Supabase backend"]
  node_registry{{"Tenant registry<br/>Supabase Edge Function<br/>[index.ts]"}}
  node_tenant_schema["Tenant and RLS schema<br/>database migrations"]
  node_issue_store[("Issue analysis store<br/>Supabase PostgreSQL")]
  node_webhook_processor{{"Webhook analysis processor<br/>deployment boundary"}}
end

subgraph group_shared["Shared AI contract"]
  node_prompts["Prompt composition<br/>shared prompting<br/>[defaultPrompt.js]"]
  node_response_schema["Groq response contract<br/>shared schema"]
end

subgraph group_external["External platforms"]
  node_github(("GitHub<br/>issue and PR platform"))
  node_groq(("Groq / Llama 3.3<br/>inference API"))
end

node_manifest -->|"launches"| node_background
node_manifest -->|"injects on GitHub"| node_content
node_github -->|"page DOM"| node_content
node_content -->|"derives context"| node_github_context
node_content -->|"routes by page"| node_issue_pr_injectors
node_github_context -->|"issue identity"| node_insight_fetch
node_issue_pr_injectors -->|"injection points"| node_page_ui
node_insight_fetch -->|"persisted insights"| node_page_ui
node_insight_fetch -->|"reads through"| node_supabase_client
node_background -->|"orchestrates"| node_installer
node_settings -->|"invokes actions"| node_background
node_settings -->|"configures workflow"| node_supabase_client
node_supabase_client -->|"resolves tenant"| node_registry
node_registry -->|"enforces ownership"| node_tenant_schema
node_supabase_client -->|"reads analysis"| node_issue_store
node_github -.->|"issue-open webhook"| node_webhook_processor
node_webhook_processor -->|"persists issue and analysis"| node_issue_store
node_webhook_processor -->|"builds request"| node_prompts
node_prompts -->|"inference prompt"| node_groq
node_groq -->|"structured output"| node_response_schema
node_response_schema -->|"validated analysis"| node_webhook_processor

click node_manifest "https://github.com/yashk-arch/repoowl-extension/blob/main/extension/manifest.json"
click node_content "https://github.com/yashk-arch/repoowl-extension/blob/main/extension/src/content/index.js"
click node_github_context "https://github.com/yashk-arch/repoowl-extension/blob/main/extension/src/lib/githubContext.js"
click node_issue_pr_injectors "https://github.com/yashk-arch/repoowl-extension/blob/main/extension/src/content/issueDetailInjector.js"
click node_insight_fetch "https://github.com/yashk-arch/repoowl-extension/blob/main/extension/src/content/fetchIssueInsights.js"
click node_page_ui "https://github.com/yashk-arch/repoowl-extension/blob/main/extension/src/content/badgeInjector.js"
click node_background "https://github.com/yashk-arch/repoowl-extension/blob/main/extension/src/background.js"
click node_installer "https://github.com/yashk-arch/repoowl-extension/blob/main/extension/src/background/githubInstaller.js"
click node_settings "https://github.com/yashk-arch/repoowl-extension/blob/main/extension/src/popup/PopupApp.jsx"
click node_supabase_client "https://github.com/yashk-arch/repoowl-extension/blob/main/extension/src/lib/supabase.js"
click node_registry "https://github.com/yashk-arch/repoowl-extension/blob/main/supabase/functions/registry/index.ts"
click node_tenant_schema "https://github.com/yashk-arch/repoowl-extension/blob/main/supabase/migrations/004_multi_tenant.sql"
click node_issue_store "https://github.com/yashk-arch/repoowl-extension/blob/main/database-schema.sql"
click node_prompts "https://github.com/yashk-arch/repoowl-extension/blob/main/shared/prompts/defaultPrompt.js"
click node_response_schema "https://github.com/yashk-arch/repoowl-extension/blob/main/shared/schemas/groqResponseSchema.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_manifest,node_content,node_github_context,node_issue_pr_injectors,node_insight_fetch,node_page_ui,node_background,node_installer,node_settings,node_supabase_client toneBlue
class node_registry,node_tenant_schema,node_issue_store,node_webhook_processor toneAmber
class node_prompts,node_response_schema toneMint
class node_github,node_groq toneRose
```

## Components

### Chrome extension

Manifest V3 runtime and GitHub-page experience.

- [Extension manifest](https://github.com/yashk-arch/repoowl-extension/blob/main/extension/manifest.json): MV3 entrypoint · Registers service worker and GitHub content scripts. · `extension/manifest.json`
- [Content runtime](https://github.com/yashk-arch/repoowl-extension/blob/main/extension/src/content/index.js): content scripts · Inspects GitHub pages and coordinates page-specific injection. · `extension/src/content/index.js`
- [GitHub context](https://github.com/yashk-arch/repoowl-extension/blob/main/extension/src/lib/githubContext.js): page identity boundary · Derives repository, issue, and page identity from GitHub DOM and URLs. · `extension/src/lib/githubContext.js`
- [Issue and PR injectors](https://github.com/yashk-arch/repoowl-extension/blob/main/extension/src/content/issueDetailInjector.js): DOM integration · Adds non-destructive triage UI to issue and PR detail pages. · `extension/src/content/issueDetailInjector.js`
- [Insight reader](https://github.com/yashk-arch/repoowl-extension/blob/main/extension/src/content/fetchIssueInsights.js): analysis fetch · Retrieves persisted issue analysis for the current GitHub context. · `extension/src/content/fetchIssueInsights.js`
- [Badges, cards, overlay](https://github.com/yashk-arch/repoowl-extension/blob/main/extension/src/content/badgeInjector.js): in-page React UI · Renders results in GitHub lists, sidebars, and an on-demand overlay. · `extension/src/content/badgeInjector.js`
- [Background worker](https://github.com/yashk-arch/repoowl-extension/blob/main/extension/src/background.js): service worker · Centralizes lifecycle and tab-independent GitHub actions. · `extension/src/background.js`
- [GitHub installer](https://github.com/yashk-arch/repoowl-extension/blob/main/extension/src/background/githubInstaller.js): installation integration · `extension/src/background/githubInstaller.js`
- [Popup and settings](https://github.com/yashk-arch/repoowl-extension/blob/main/extension/src/popup/PopupApp.jsx): configuration UI · Controls tracking, model and prompt settings, and maintainer registration. · `extension/src/popup/PopupApp.jsx`
- [Supabase client](https://github.com/yashk-arch/repoowl-extension/blob/main/extension/src/lib/supabase.js): backend access · Uses the mediator-backed Supabase connection. · `extension/src/lib/supabase.js`

### Supabase backend

Tenant mediation, persistence, and event-driven analysis.

- [Tenant registry](https://github.com/yashk-arch/repoowl-extension/blob/main/supabase/functions/registry/index.ts): Supabase Edge Function · Resolves a repository maintainer's Supabase connection. · `supabase/functions/registry/index.ts`
- [Tenant and RLS schema](https://github.com/yashk-arch/repoowl-extension/blob/main/supabase/migrations/004_multi_tenant.sql): database migrations · Defines issue identity, ownership boundaries, and stronger RLS. · `supabase/migrations/004_multi_tenant.sql`
- [Issue analysis store](https://github.com/yashk-arch/repoowl-extension/blob/main/database-schema.sql): Supabase PostgreSQL · Persists GitHub issue data and generated analysis. · `database-schema.sql`
- **Webhook analysis processor**: deployment boundary · Intended issue-open processor; its deployed source location is unverified.

### Shared AI contract

Reusable prompt and response boundaries.

- [Prompt composition](https://github.com/yashk-arch/repoowl-extension/blob/main/shared/prompts/defaultPrompt.js): shared prompting · Builds prompts and formats historical context. · `shared/prompts/defaultPrompt.js`
- [Groq response contract](https://github.com/yashk-arch/repoowl-extension/blob/main/shared/schemas/groqResponseSchema.js): shared schema · Defines expected structured model output. · `shared/schemas/groqResponseSchema.js`

### External platforms

- **GitHub**: issue and PR platform · Hosts pages, repositories, and issue-open webhook events.
- **Groq / Llama 3.3**: inference API

## Connections

- Extension manifest → Background worker: launches
- Extension manifest → Content runtime: injects on GitHub
- GitHub → Content runtime: page DOM
- Content runtime → GitHub context: derives context
- Content runtime → Issue and PR injectors: routes by page
- GitHub context → Insight reader: issue identity
- Issue and PR injectors → Badges, cards, overlay: injection points
- Insight reader → Badges, cards, overlay: persisted insights
- Insight reader → Supabase client: reads through
- Background worker → GitHub installer: orchestrates
- Popup and settings → Background worker: invokes actions
- Popup and settings → Supabase client: configures workflow
- Supabase client → Tenant registry: resolves tenant
- Tenant registry → Tenant and RLS schema: enforces ownership
- Supabase client → Issue analysis store: reads analysis
- GitHub → Webhook analysis processor: issue-open webhook
- Webhook analysis processor → Issue analysis store: persists issue and analysis
- Webhook analysis processor → Prompt composition: builds request
- Prompt composition → Groq / Llama 3.3: inference prompt
- Groq / Llama 3.3 → Groq response contract: structured output
- Groq response contract → Webhook analysis processor: validated analysis
