# hrishikeshchandi/patchops architecture

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

- Interactive diagram: https://gitdiagram.com/hrishikeshchandi/patchops
- Repository: https://github.com/hrishikeshchandi/patchops

## Overview

PatchOps is an autonomous security-remediation tool for Python repositories. A user starts a run through the pipeline API; the pipeline scans the target, generates and applies patches, checks neighboring components and dependencies, runs system tests, and can open GitHub pull requests. The repository also builds a dependency graph and includes LLM-backed analysis and exploit-generation agents. The README contains no workflow details; edges for stages whose calls fall in omitted excerpts are dashed and unverified.

Main entry points: [`pipeline_api.py`](https://github.com/hrishikeshchandi/patchops/blob/main/pipeline_api.py) (Pipeline API), [`PatchOps-Target/app.py`](https://github.com/hrishikeshchandi/patchops/blob/main/PatchOps-Target/app.py) (Target Flask App), [`lambdas/pr_generator/handler.py`](https://github.com/hrishikeshchandi/patchops/blob/main/lambdas/pr_generator/handler.py) (PR Generator), [`lambdas/shared/utils.py`](https://github.com/hrishikeshchandi/patchops/blob/main/lambdas/shared/utils.py) (LLM Utilities)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_interface["Run Interface"]
  node_frontend["Security Terminal<br/>[script.js]"]
  node_api["Pipeline API<br/>[pipeline_api.py]"]
end

subgraph group_pipeline["Remediation Pipeline"]
  node_orchestrator["Orchestrator<br/>[handler.py]"]
  node_graph["Graph Builder<br/>[handler.py]"]
  node_patch["Patch Writer<br/>[handler.py]"]
  node_component["Component Tester<br/>[handler.py]"]
  node_neighbor["Neighbor Resolver<br/>[handler.py]"]
  node_system["System Tester<br/>[handler.py]"]
  node_pr["PR Generator<br/>[handler.py]"]
  node_template["PR Body Template<br/>[template.py]"]
end

subgraph group_agents["Analysis Agents"]
  node_analyzer["Code Analyzer<br/>[handler.py]"]
  node_exploit["Exploit Crafter<br/>[handler.py]"]
  node_security["Security Reviewer<br/>[handler.py]"]
  node_requirements["Requirements Checker<br/>[handler.py]"]
  node_llm["LLM Utilities<br/>[utils.py]"]
end

subgraph group_target["Target Application"]
  node_app["Target Flask App<br/>[app.py]"]
  node_auth["Authentication<br/>[auth.py]"]
  node_config["Configuration<br/>[config.py]"]
  node_db["Database Utilities<br/>[db_utils.py]"]
  node_initdb["Database Initialization<br/>[init_db.py]"]
end

node_user(("User"))
node_github["GitHub"]

node_user -.->|"uses"| node_frontend
node_frontend -.->|"starts runs"| node_api
node_api -.->|"runs workflow"| node_orchestrator
node_api -->|"builds graph"| node_graph
node_api -->|"scans code"| node_analyzer
node_api -->|"generates patch"| node_patch
node_api -.->|"checks compatibility"| node_component
node_api -.->|"resolves neighbors"| node_neighbor
node_api -.->|"crafts exploits"| node_exploit
node_api -.->|"reviews security"| node_security
node_api -.->|"checks dependencies"| node_requirements
node_api -->|"tests patch"| node_system
node_api -->|"opens pull requests"| node_pr
node_analyzer -->|"calls"| node_llm
node_exploit -->|"calls"| node_llm
node_requirements -->|"calls"| node_llm
node_pr -->|"generates body"| node_template
node_pr -->|"creates pull request"| node_github
node_system -->|"launches and probes"| node_app
node_app -->|"gets profile"| node_auth
node_app -->|"queries database"| node_db
node_app -.->|"imports"| node_config
node_app -.->|"initializes database"| node_initdb

click node_frontend "https://github.com/hrishikeshchandi/patchops/blob/main/frontend/script.js"
click node_api "https://github.com/hrishikeshchandi/patchops/blob/main/pipeline_api.py"
click node_orchestrator "https://github.com/hrishikeshchandi/patchops/blob/main/lambdas/orchestrator/handler.py"
click node_graph "https://github.com/hrishikeshchandi/patchops/blob/main/lambdas/graph_builder/handler.py"
click node_analyzer "https://github.com/hrishikeshchandi/patchops/blob/main/lambdas/code_analyzer/handler.py"
click node_exploit "https://github.com/hrishikeshchandi/patchops/blob/main/lambdas/exploit_crafter/handler.py"
click node_patch "https://github.com/hrishikeshchandi/patchops/blob/main/lambdas/patch_writer/handler.py"
click node_component "https://github.com/hrishikeshchandi/patchops/blob/main/lambdas/component_tester/handler.py"
click node_neighbor "https://github.com/hrishikeshchandi/patchops/blob/main/lambdas/neighbor_resolver/handler.py"
click node_security "https://github.com/hrishikeshchandi/patchops/blob/main/lambdas/security_reviewer/handler.py"
click node_requirements "https://github.com/hrishikeshchandi/patchops/blob/main/lambdas/requirements_checker/handler.py"
click node_system "https://github.com/hrishikeshchandi/patchops/blob/main/lambdas/system_tester/handler.py"
click node_pr "https://github.com/hrishikeshchandi/patchops/blob/main/lambdas/pr_generator/handler.py"
click node_template "https://github.com/hrishikeshchandi/patchops/blob/main/lambdas/pr_generator/template.py"
click node_llm "https://github.com/hrishikeshchandi/patchops/blob/main/lambdas/shared/utils.py"
click node_app "https://github.com/hrishikeshchandi/patchops/blob/main/PatchOps-Target/app.py"
click node_auth "https://github.com/hrishikeshchandi/patchops/blob/main/PatchOps-Target/auth.py"
click node_config "https://github.com/hrishikeshchandi/patchops/blob/main/PatchOps-Target/config.py"
click node_db "https://github.com/hrishikeshchandi/patchops/blob/main/PatchOps-Target/db_utils.py"
click node_initdb "https://github.com/hrishikeshchandi/patchops/blob/main/PatchOps-Target/init_db.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_frontend,node_api,node_user toneBlue
class node_orchestrator,node_graph,node_patch,node_component,node_neighbor,node_system,node_pr,node_template toneAmber
class node_analyzer,node_exploit,node_security,node_requirements,node_llm toneMint
class node_app,node_auth,node_config,node_db,node_initdb toneRose
class node_github toneIndigo
```

## Components

### Run Interface

- [Security Terminal](https://github.com/hrishikeshchandi/patchops/blob/main/frontend/script.js): `frontend/script.js`
- [Pipeline API](https://github.com/hrishikeshchandi/patchops/blob/main/pipeline_api.py): `pipeline_api.py`

### Remediation Pipeline

- [Orchestrator](https://github.com/hrishikeshchandi/patchops/blob/main/lambdas/orchestrator/handler.py): `lambdas/orchestrator/handler.py`
- [Graph Builder](https://github.com/hrishikeshchandi/patchops/blob/main/lambdas/graph_builder/handler.py): `lambdas/graph_builder/handler.py`
- [Patch Writer](https://github.com/hrishikeshchandi/patchops/blob/main/lambdas/patch_writer/handler.py): `lambdas/patch_writer/handler.py`
- [Component Tester](https://github.com/hrishikeshchandi/patchops/blob/main/lambdas/component_tester/handler.py): `lambdas/component_tester/handler.py`
- [Neighbor Resolver](https://github.com/hrishikeshchandi/patchops/blob/main/lambdas/neighbor_resolver/handler.py): `lambdas/neighbor_resolver/handler.py`
- [System Tester](https://github.com/hrishikeshchandi/patchops/blob/main/lambdas/system_tester/handler.py): `lambdas/system_tester/handler.py`
- [PR Generator](https://github.com/hrishikeshchandi/patchops/blob/main/lambdas/pr_generator/handler.py): `lambdas/pr_generator/handler.py`
- [PR Body Template](https://github.com/hrishikeshchandi/patchops/blob/main/lambdas/pr_generator/template.py): `lambdas/pr_generator/template.py`

### Analysis Agents

- [Code Analyzer](https://github.com/hrishikeshchandi/patchops/blob/main/lambdas/code_analyzer/handler.py): `lambdas/code_analyzer/handler.py`
- [Exploit Crafter](https://github.com/hrishikeshchandi/patchops/blob/main/lambdas/exploit_crafter/handler.py): `lambdas/exploit_crafter/handler.py`
- [Security Reviewer](https://github.com/hrishikeshchandi/patchops/blob/main/lambdas/security_reviewer/handler.py): `lambdas/security_reviewer/handler.py`
- [Requirements Checker](https://github.com/hrishikeshchandi/patchops/blob/main/lambdas/requirements_checker/handler.py): `lambdas/requirements_checker/handler.py`
- [LLM Utilities](https://github.com/hrishikeshchandi/patchops/blob/main/lambdas/shared/utils.py): `lambdas/shared/utils.py`

### Target Application

- [Target Flask App](https://github.com/hrishikeshchandi/patchops/blob/main/PatchOps-Target/app.py): `PatchOps-Target/app.py`
- [Authentication](https://github.com/hrishikeshchandi/patchops/blob/main/PatchOps-Target/auth.py): `PatchOps-Target/auth.py`
- [Configuration](https://github.com/hrishikeshchandi/patchops/blob/main/PatchOps-Target/config.py): `PatchOps-Target/config.py`
- [Database Utilities](https://github.com/hrishikeshchandi/patchops/blob/main/PatchOps-Target/db_utils.py): `PatchOps-Target/db_utils.py`
- [Database Initialization](https://github.com/hrishikeshchandi/patchops/blob/main/PatchOps-Target/init_db.py): `PatchOps-Target/init_db.py`

### Other components

- **User**
- **GitHub**

## Connections

- User → Security Terminal: uses
- Security Terminal → Pipeline API: starts runs
- Pipeline API → Orchestrator: runs workflow
- Pipeline API → Graph Builder: builds graph (evidence: `pipeline_api.py`)
- Pipeline API → Code Analyzer: scans code (evidence: `pipeline_api.py`)
- Pipeline API → Patch Writer: generates patch (evidence: `pipeline_api.py`)
- Pipeline API → Component Tester: checks compatibility (evidence: `pipeline_api.py`)
- Pipeline API → Neighbor Resolver: resolves neighbors (evidence: `pipeline_api.py`)
- Pipeline API → Exploit Crafter: crafts exploits (evidence: `pipeline_api.py`)
- Pipeline API → Security Reviewer: reviews security (evidence: `pipeline_api.py`)
- Pipeline API → Requirements Checker: checks dependencies (evidence: `pipeline_api.py`)
- Pipeline API → System Tester: tests patch (evidence: `pipeline_api.py`)
- Pipeline API → PR Generator: opens pull requests (evidence: `pipeline_api.py`)
- Code Analyzer → LLM Utilities: calls (evidence: `lambdas/code_analyzer/handler.py`)
- Exploit Crafter → LLM Utilities: calls (evidence: `lambdas/exploit_crafter/handler.py`)
- Requirements Checker → LLM Utilities: calls (evidence: `lambdas/requirements_checker/handler.py`)
- PR Generator → PR Body Template: generates body (evidence: `lambdas/pr_generator/handler.py`)
- PR Generator → GitHub: creates pull request (evidence: `lambdas/pr_generator/handler.py`)
- System Tester → Target Flask App: launches and probes (evidence: `lambdas/system_tester/handler.py`)
- Target Flask App → Authentication: gets profile (evidence: `PatchOps-Target/app.py`)
- Target Flask App → Database Utilities: queries database (evidence: `PatchOps-Target/app.py`)
- Target Flask App → Configuration: imports (evidence: `PatchOps-Target/app.py`)
- Target Flask App → Database Initialization: initializes database (evidence: `PatchOps-Target/app.py`)
