# vikhayatrana0110-crypto/patchpilot architecture

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

- Interactive diagram: https://gitdiagram.com/vikhayatrana0110-crypto/patchpilot
- Repository: https://github.com/vikhayatrana0110-crypto/patchpilot

## Overview

PatchPilot is a repository-debugging application: a user uploads a codebase, describes a bug, reviews an automatically generated and validated patch, then approves, rejects, or requests a revision. Its main path runs from the Streamlit UI through the FastAPI API and repository indexing into a LangGraph debugging session. The graph retrieves context, generates and validates a patch, and pauses for human review. The README documents the graph stages and tool capabilities; several implementation files were not sampled, so those relationships are cited to the README rather than inferred from imports.

Main entry points: [`backend/graph/nodes.py`](https://github.com/vikhayatrana0110-crypto/patchpilot/blob/main/backend/graph/nodes.py) (Agent stages), [`backend/api/routes.py`](https://github.com/vikhayatrana0110-crypto/patchpilot/blob/main/backend/api/routes.py) (HTTP API routes), [`backend/graph/workflow.py`](https://github.com/vikhayatrana0110-crypto/patchpilot/blob/main/backend/graph/workflow.py) (Graph workflow), [`frontend/app.py`](https://github.com/vikhayatrana0110-crypto/patchpilot/blob/main/frontend/app.py) (Streamlit interface)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_interface["User interface and API"]
  node_ui["Streamlit interface<br/>[app.py]"]
  node_api["HTTP API routes<br/>[routes.py]"]
  node_contracts["API schemas<br/>[schemas.py]"]
end

subgraph group_indexing["Repository indexing"]
  node_loader["Repository loader"]
  node_splitter["Code splitter<br/>[code_splitter.py]"]
  node_vectors[("Vector index<br/>[vector_store.py]")]
end

subgraph group_agent["Debugging agent"]
  node_workflow["Graph workflow<br/>[workflow.py]"]
  node_state["Debugging state<br/>[state.py]"]
  node_nodes["Agent stages<br/>[nodes.py]"]
  node_routing["Retry and routing<br/>[routing.py]"]
  node_code_search["Semantic code search<br/>[code_search.py]"]
  node_trace["Stack trace analysis<br/>[stack_trace.py]"]
  node_dependencies["Dependency inspection"]
end

subgraph group_validation["Patch validation"]
  node_validation_tools["Syntax and lint checks<br/>[linter.py]"]
  node_test_runner["Test runner<br/>[test_runner.py]"]
  node_repo_files[("Uploaded repository files")]
end

subgraph group_sessions["Review and persistence"]
  node_checkpoint[("Session checkpoints")]
end

node_user(("Repository owner"))
node_groq{{"Groq model service"}}
node_reviewer(("Human reviewer"))

node_user -->|"uploads and describes"| node_ui
node_ui -->|"calls over HTTP"| node_api
node_api -->|"validates and returns"| node_contracts
node_api -->|"loads repository"| node_loader
node_api -->|"chunks source"| node_splitter
node_api -->|"indexes chunks"| node_vectors
node_api -->|"starts or resumes"| node_workflow
node_workflow -->|"dispatches stages"| node_nodes
node_workflow -->|"routes transitions"| node_routing
node_workflow -->|"tracks session state"| node_state
node_nodes -->|"searches repository"| node_code_search
node_nodes -->|"analyzes traceback"| node_trace
node_nodes -->|"inspects dependencies"| node_dependencies
node_nodes -->|"retrieves code context"| node_vectors
node_nodes -->|"requests patch"| node_groq
node_nodes -->|"checks syntax and lint"| node_validation_tools
node_nodes -->|"runs test suite"| node_test_runner
node_validation_tools -->|"checks target file"| node_repo_files
node_test_runner -->|"tests repository"| node_repo_files
node_routing -->|"retries failed patch"| node_nodes
node_nodes -->|"presents validated patch"| node_reviewer
node_reviewer -->|"approves or revises"| node_api
node_api -->|"resumes sessions"| node_checkpoint
node_reviewer -->|"reviews results"| node_ui

click node_ui "https://github.com/vikhayatrana0110-crypto/patchpilot/blob/main/frontend/app.py"
click node_api "https://github.com/vikhayatrana0110-crypto/patchpilot/blob/main/backend/api/routes.py"
click node_contracts "https://github.com/vikhayatrana0110-crypto/patchpilot/blob/main/backend/api/schemas.py"
click node_loader "https://github.com/vikhayatrana0110-crypto/patchpilot/blob/main/backend/rag/repository_loader.py"
click node_splitter "https://github.com/vikhayatrana0110-crypto/patchpilot/blob/main/backend/rag/code_splitter.py"
click node_vectors "https://github.com/vikhayatrana0110-crypto/patchpilot/blob/main/backend/rag/vector_store.py"
click node_workflow "https://github.com/vikhayatrana0110-crypto/patchpilot/blob/main/backend/graph/workflow.py"
click node_state "https://github.com/vikhayatrana0110-crypto/patchpilot/blob/main/backend/graph/state.py"
click node_nodes "https://github.com/vikhayatrana0110-crypto/patchpilot/blob/main/backend/graph/nodes.py"
click node_routing "https://github.com/vikhayatrana0110-crypto/patchpilot/blob/main/backend/graph/routing.py"
click node_code_search "https://github.com/vikhayatrana0110-crypto/patchpilot/blob/main/backend/tools/code_search.py"
click node_trace "https://github.com/vikhayatrana0110-crypto/patchpilot/blob/main/backend/tools/stack_trace.py"
click node_dependencies "https://github.com/vikhayatrana0110-crypto/patchpilot/blob/main/backend/tools/dependency_inspector.py"
click node_validation_tools "https://github.com/vikhayatrana0110-crypto/patchpilot/blob/main/backend/tools/linter.py"
click node_test_runner "https://github.com/vikhayatrana0110-crypto/patchpilot/blob/main/backend/tools/test_runner.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_ui,node_api,node_contracts,node_reviewer toneBlue
class node_loader,node_splitter,node_vectors toneAmber
class node_workflow,node_state,node_nodes,node_routing,node_code_search,node_trace,node_dependencies toneMint
class node_validation_tools,node_test_runner,node_repo_files toneRose
class node_checkpoint,node_user,node_groq toneIndigo
```

## Components

### User interface and API

- [Streamlit interface](https://github.com/vikhayatrana0110-crypto/patchpilot/blob/main/frontend/app.py): `frontend/app.py`
- [HTTP API routes](https://github.com/vikhayatrana0110-crypto/patchpilot/blob/main/backend/api/routes.py): `backend/api/routes.py`
- [API schemas](https://github.com/vikhayatrana0110-crypto/patchpilot/blob/main/backend/api/schemas.py): `backend/api/schemas.py`

### Repository indexing

- [Repository loader](https://github.com/vikhayatrana0110-crypto/patchpilot/blob/main/backend/rag/repository_loader.py): `backend/rag/repository_loader.py`
- [Code splitter](https://github.com/vikhayatrana0110-crypto/patchpilot/blob/main/backend/rag/code_splitter.py): `backend/rag/code_splitter.py`
- [Vector index](https://github.com/vikhayatrana0110-crypto/patchpilot/blob/main/backend/rag/vector_store.py): `backend/rag/vector_store.py`

### Debugging agent

- [Graph workflow](https://github.com/vikhayatrana0110-crypto/patchpilot/blob/main/backend/graph/workflow.py): `backend/graph/workflow.py`
- [Debugging state](https://github.com/vikhayatrana0110-crypto/patchpilot/blob/main/backend/graph/state.py): `backend/graph/state.py`
- [Agent stages](https://github.com/vikhayatrana0110-crypto/patchpilot/blob/main/backend/graph/nodes.py): `backend/graph/nodes.py`
- [Retry and routing](https://github.com/vikhayatrana0110-crypto/patchpilot/blob/main/backend/graph/routing.py): `backend/graph/routing.py`
- [Semantic code search](https://github.com/vikhayatrana0110-crypto/patchpilot/blob/main/backend/tools/code_search.py): `backend/tools/code_search.py`
- [Stack trace analysis](https://github.com/vikhayatrana0110-crypto/patchpilot/blob/main/backend/tools/stack_trace.py): `backend/tools/stack_trace.py`
- [Dependency inspection](https://github.com/vikhayatrana0110-crypto/patchpilot/blob/main/backend/tools/dependency_inspector.py): `backend/tools/dependency_inspector.py`

### Patch validation

- [Syntax and lint checks](https://github.com/vikhayatrana0110-crypto/patchpilot/blob/main/backend/tools/linter.py): `backend/tools/linter.py`
- [Test runner](https://github.com/vikhayatrana0110-crypto/patchpilot/blob/main/backend/tools/test_runner.py): `backend/tools/test_runner.py`
- **Uploaded repository files**

### Review and persistence

- **Session checkpoints**

### Other components

- **Repository owner**
- **Groq model service**
- **Human reviewer**

## Connections

- Repository owner → Streamlit interface: uploads and describes (evidence: `README.md`)
- Streamlit interface → HTTP API routes: calls over HTTP (evidence: `frontend/app.py`)
- HTTP API routes → API schemas: validates and returns (evidence: `backend/api/routes.py`)
- HTTP API routes → Repository loader: loads repository (evidence: `README.md`)
- HTTP API routes → Code splitter: chunks source (evidence: `README.md`)
- HTTP API routes → Vector index: indexes chunks (evidence: `README.md`)
- HTTP API routes → Graph workflow: starts or resumes (evidence: `backend/api/routes.py`)
- Graph workflow → Agent stages: dispatches stages (evidence: `README.md`)
- Graph workflow → Retry and routing: routes transitions (evidence: `README.md`)
- Graph workflow → Debugging state: tracks session state (evidence: `README.md`)
- Agent stages → Semantic code search: searches repository (evidence: `README.md`)
- Agent stages → Stack trace analysis: analyzes traceback (evidence: `README.md`)
- Agent stages → Dependency inspection: inspects dependencies (evidence: `README.md`)
- Agent stages → Vector index: retrieves code context (evidence: `README.md`)
- Agent stages → Groq model service: requests patch (evidence: `README.md`)
- Agent stages → Syntax and lint checks: checks syntax and lint (evidence: `README.md`)
- Agent stages → Test runner: runs test suite (evidence: `README.md`)
- Syntax and lint checks → Uploaded repository files: checks target file (evidence: `backend/tools/linter.py`)
- Test runner → Uploaded repository files: tests repository (evidence: `README.md`)
- Retry and routing → Agent stages: retries failed patch (evidence: `backend/graph/routing.py`)
- Agent stages → Human reviewer: presents validated patch (evidence: `README.md`)
- Human reviewer → HTTP API routes: approves or revises (evidence: `README.md`)
- HTTP API routes → Session checkpoints: resumes sessions (evidence: `README.md`)
- Human reviewer → Streamlit interface: reviews results (evidence: `README.md`)
