# kavinr24/patch architecture

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

- Interactive diagram: https://gitdiagram.com/kavinr24/patch
- Repository: https://github.com/kavinr24/patch

## Overview

Patch accepts a repository issue, fetches the target file, asks Groq for a unified diff, applies it in a fork, and opens a GitHub pull request. Users can start that workflow manually through the dashboard or register repositories for polling and automatic triage; the tracker also comments on issues and records processed IDs. The FastAPI routes manage session-scoped tracking and fixes, while the Streamlit UI is an additional interface present in the source. The README documents the product workflow; links to unsampled route behavior are shown only where documented.

Main entry points: [`core/tracker.py`](https://github.com/kavinr24/patch/blob/main/core/tracker.py) (Auto-tracker), [`web/routes.py`](https://github.com/kavinr24/patch/blob/main/web/routes.py) (Dashboard API), [`core/fetcher.py`](https://github.com/kavinr24/patch/blob/main/core/fetcher.py) (File fetcher), [`core/analyzer.py`](https://github.com/kavinr24/patch/blob/main/core/analyzer.py) (Diff generator)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_interfaces["User interfaces"]
  node_fastapi["FastAPI app<br/>[main.py]"]
  node_routes["Dashboard API<br/>[routes.py]"]
  node_dashboard["Dashboard page<br/>[dashboard.html]"]
  node_assets["Web assets<br/>[assets.py]"]
  node_streamlit["Streamlit UI<br/>[app.py]"]
end

subgraph group_orchestration["Workflow orchestration"]
  node_tracker["Auto-tracker<br/>[tracker.py]"]
end

subgraph group_patching["Patch pipeline"]
  node_fetcher["File fetcher<br/>[fetcher.py]"]
  node_analyzer["Diff generator<br/>[analyzer.py]"]
  node_pr_creator["Fork and PR creator<br/>[pr_creator.py]"]
end

subgraph group_integrations["External services and state"]
  node_repo_registry[("Tracked repo registry<br/>[tracked_repos.json]")]
  node_config["Credentials config<br/>[config.py]"]
end

node_user(("User"))
node_github{{"GitHub API"}}
node_groq{{"Groq LLM"}}

node_user -->|"uses dashboard"| node_routes
node_routes -->|"loads page"| node_assets
node_assets -->|"reads template"| node_dashboard
node_user -->|"runs fixes"| node_streamlit
node_fastapi -->|"mounts routes"| node_routes
node_fastapi -->|"starts poller"| node_tracker
node_routes -->|"manages tracking"| node_tracker
node_routes -->|"runs manual pipeline"| node_fetcher
node_routes -->|"runs manual pipeline"| node_analyzer
node_routes -->|"runs manual pipeline"| node_pr_creator
node_streamlit -->|"fetches file"| node_fetcher
node_streamlit -->|"requests diff"| node_analyzer
node_streamlit -->|"creates PR"| node_pr_creator
node_tracker -->|"persists registry"| node_repo_registry
node_tracker -->|"scans issues"| node_github
node_tracker -->|"fetches target file"| node_fetcher
node_tracker -->|"generates diff"| node_analyzer
node_tracker -->|"creates pull request"| node_pr_creator
node_tracker -->|"comments on issue"| node_github
node_fetcher -->|"fetches file"| node_github
node_analyzer -->|"requests diff"| node_groq
node_pr_creator -->|"opens pull request"| node_github
node_fetcher -->|"uses token"| node_config
node_analyzer -->|"uses key"| node_config
node_pr_creator -->|"uses token"| node_config

click node_fastapi "https://github.com/kavinr24/patch/blob/main/main.py"
click node_routes "https://github.com/kavinr24/patch/blob/main/web/routes.py"
click node_dashboard "https://github.com/kavinr24/patch/blob/main/web/dashboard.html"
click node_assets "https://github.com/kavinr24/patch/blob/main/web/assets.py"
click node_streamlit "https://github.com/kavinr24/patch/blob/main/app.py"
click node_tracker "https://github.com/kavinr24/patch/blob/main/core/tracker.py"
click node_repo_registry "https://github.com/kavinr24/patch/blob/main/tracked_repos.json"
click node_config "https://github.com/kavinr24/patch/blob/main/config.py"
click node_fetcher "https://github.com/kavinr24/patch/blob/main/core/fetcher.py"
click node_analyzer "https://github.com/kavinr24/patch/blob/main/core/analyzer.py"
click node_pr_creator "https://github.com/kavinr24/patch/blob/main/core/pr_creator.py"

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_fastapi,node_routes,node_dashboard,node_assets,node_streamlit,node_user toneBlue
class node_tracker toneAmber
class node_fetcher,node_analyzer,node_pr_creator,node_github toneMint
class node_repo_registry,node_config toneRose
class node_groq toneIndigo
```

## Components

### User interfaces

- [FastAPI app](https://github.com/kavinr24/patch/blob/main/main.py): `main.py`
- [Dashboard API](https://github.com/kavinr24/patch/blob/main/web/routes.py): `web/routes.py`
- [Dashboard page](https://github.com/kavinr24/patch/blob/main/web/dashboard.html): `web/dashboard.html`
- [Web assets](https://github.com/kavinr24/patch/blob/main/web/assets.py): `web/assets.py`
- [Streamlit UI](https://github.com/kavinr24/patch/blob/main/app.py): `app.py`

### Workflow orchestration

- [Auto-tracker](https://github.com/kavinr24/patch/blob/main/core/tracker.py): `core/tracker.py`

### Patch pipeline

- [File fetcher](https://github.com/kavinr24/patch/blob/main/core/fetcher.py): `core/fetcher.py`
- [Diff generator](https://github.com/kavinr24/patch/blob/main/core/analyzer.py): `core/analyzer.py`
- [Fork and PR creator](https://github.com/kavinr24/patch/blob/main/core/pr_creator.py): `core/pr_creator.py`

### External services and state

- [Tracked repo registry](https://github.com/kavinr24/patch/blob/main/tracked_repos.json): `tracked_repos.json`
- [Credentials config](https://github.com/kavinr24/patch/blob/main/config.py): `config.py`

### Other components

- **User**
- **GitHub API**
- **Groq LLM**

## Connections

- User → Dashboard API: uses dashboard (evidence: `README.md`)
- Dashboard API → Web assets: loads page (evidence: `web/routes.py`)
- Web assets → Dashboard page: reads template (evidence: `web/assets.py`)
- User → Streamlit UI: runs fixes (evidence: `app.py`)
- FastAPI app → Dashboard API: mounts routes (evidence: `main.py`)
- FastAPI app → Auto-tracker: starts poller (evidence: `main.py`)
- Dashboard API → Auto-tracker: manages tracking (evidence: `web/routes.py`)
- Dashboard API → File fetcher: runs manual pipeline (evidence: `README.md`)
- Dashboard API → Diff generator: runs manual pipeline (evidence: `README.md`)
- Dashboard API → Fork and PR creator: runs manual pipeline (evidence: `README.md`)
- Streamlit UI → File fetcher: fetches file (evidence: `app.py`)
- Streamlit UI → Diff generator: requests diff (evidence: `app.py`)
- Streamlit UI → Fork and PR creator: creates PR (evidence: `app.py`)
- Auto-tracker → Tracked repo registry: persists registry (evidence: `core/tracker.py`)
- Auto-tracker → GitHub API: scans issues (evidence: `core/tracker.py`)
- Auto-tracker → File fetcher: fetches target file (evidence: `core/tracker.py`)
- Auto-tracker → Diff generator: generates diff (evidence: `core/tracker.py`)
- Auto-tracker → Fork and PR creator: creates pull request (evidence: `core/tracker.py`)
- Auto-tracker → GitHub API: comments on issue (evidence: `core/tracker.py`)
- File fetcher → GitHub API: fetches file (evidence: `core/fetcher.py`)
- Diff generator → Groq LLM: requests diff (evidence: `core/analyzer.py`)
- Fork and PR creator → GitHub API: opens pull request (evidence: `core/pr_creator.py`)
- File fetcher → Credentials config: uses token (evidence: `core/fetcher.py`)
- Diff generator → Credentials config: uses key (evidence: `core/analyzer.py`)
- Fork and PR creator → Credentials config: uses token (evidence: `core/pr_creator.py`)
