# ishaanman7898/api_autopilot architecture

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

- Interactive diagram: https://gitdiagram.com/ishaanman7898/api_autopilot
- Repository: https://github.com/ishaanman7898/api_autopilot

## Overview

API Autopilot lets providers publish signed migration rules and consumers apply them to JavaScript/TypeScript repositories. The main workflow validates and verifies a rule, reads configured source files, applies deterministic rewrites, gates the result, and records evidence for later replay. Providers can also draft rules from OpenAPI spec differences; unresolved call sites are fenced for agent handling. The graph includes README-documented key discovery and draft-PR behavior, but does not infer unsampled implementation details for those integrations.

Main entry points: [`src/cli.js`](https://github.com/ishaanman7898/api_autopilot/blob/main/src/cli.js) (CLI commands), [`src/engine.js`](https://github.com/ishaanman7898/api_autopilot/blob/main/src/engine.js) (Deterministic migration), [`src/evidence.js`](https://github.com/ishaanman7898/api_autopilot/blob/main/src/evidence.js) (Evidence bundle), [`src/diff.js`](https://github.com/ishaanman7898/api_autopilot/blob/main/src/diff.js) (Spec diff and drafts)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_authoring["Rule authoring"]
  node_diff["Spec diff and drafts<br/>[diff.js]"]
  node_rulefile["Signed rule file"]
end

subgraph group_apply["Consumer migration"]
  node_cli["CLI commands<br/>[cli.js]"]
  node_config["Consumer settings<br/>[config.js]"]
  node_workspace["Consumer code"]
  node_engine["Deterministic migration<br/>[engine.js]"]
  node_agent["Fallback agent"]
end

subgraph group_trust["Trust and safety"]
  node_rules["Rule validation and signatures<br/>[rule.js]"]
  node_sanitize["Untrusted text handling<br/>[sanitize.js]"]
  node_keys[("Published signing keys")]
end

subgraph group_verification["Verification"]
  node_gate["Migration gate<br/>[gate.js]"]
  node_tests["Consumer test command"]
  node_evidence["Evidence bundle<br/>[evidence.js]"]
  node_pr["Draft pull request<br/>[action.yml]"]
end

node_provider(("API provider"))
node_specs["OpenAPI specs"]
node_consumer(("API consumer"))

node_provider -->|"supplies"| node_specs
node_specs -->|"drafts from"| node_cli
node_cli -->|"diffs specs"| node_diff
node_diff -->|"drafts rules"| node_rulefile
node_provider -->|"signs rules"| node_rules
node_rules -->|"signs and validates"| node_rulefile
node_consumer -->|"runs commands"| node_cli
node_cli -->|"loads settings"| node_config
node_cli -->|"loads and checks"| node_rulefile
node_cli -->|"fetches keys"| node_keys
node_cli -->|"reads and writes"| node_workspace
node_cli -->|"applies rules"| node_engine
node_engine -->|"fences fallback context"| node_sanitize
node_engine -->|"flags unresolved calls"| node_agent
node_cli -->|"gates changes"| node_gate
node_gate -->|"scans added lines"| node_sanitize
node_cli -->|"runs test command"| node_tests
node_cli -->|"builds evidence"| node_evidence
node_evidence -->|"replays migration"| node_engine
node_cli -->|"verifies replay"| node_evidence
node_cli -->|"opens draft PR"| node_pr

click node_cli "https://github.com/ishaanman7898/api_autopilot/blob/main/src/cli.js"
click node_diff "https://github.com/ishaanman7898/api_autopilot/blob/main/src/diff.js"
click node_rules "https://github.com/ishaanman7898/api_autopilot/blob/main/src/rule.js"
click node_config "https://github.com/ishaanman7898/api_autopilot/blob/main/src/config.js"
click node_engine "https://github.com/ishaanman7898/api_autopilot/blob/main/src/engine.js"
click node_sanitize "https://github.com/ishaanman7898/api_autopilot/blob/main/src/sanitize.js"
click node_gate "https://github.com/ishaanman7898/api_autopilot/blob/main/src/gate.js"
click node_evidence "https://github.com/ishaanman7898/api_autopilot/blob/main/src/evidence.js"
click node_pr "https://github.com/ishaanman7898/api_autopilot/blob/main/action.yml"

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_diff,node_rulefile toneBlue
class node_cli,node_config,node_workspace,node_engine,node_agent toneAmber
class node_rules,node_sanitize,node_keys,node_provider,node_specs,node_consumer toneMint
class node_gate,node_tests,node_evidence,node_pr toneRose
```

## Components

### Rule authoring

- [Spec diff and drafts](https://github.com/ishaanman7898/api_autopilot/blob/main/src/diff.js): `src/diff.js`
- **Signed rule file**

### Consumer migration

- [CLI commands](https://github.com/ishaanman7898/api_autopilot/blob/main/src/cli.js): `src/cli.js`
- [Consumer settings](https://github.com/ishaanman7898/api_autopilot/blob/main/src/config.js): `src/config.js`
- **Consumer code**
- [Deterministic migration](https://github.com/ishaanman7898/api_autopilot/blob/main/src/engine.js): `src/engine.js`
- **Fallback agent**

### Trust and safety

- [Rule validation and signatures](https://github.com/ishaanman7898/api_autopilot/blob/main/src/rule.js): `src/rule.js`
- [Untrusted text handling](https://github.com/ishaanman7898/api_autopilot/blob/main/src/sanitize.js): `src/sanitize.js`
- **Published signing keys**

### Verification

- [Migration gate](https://github.com/ishaanman7898/api_autopilot/blob/main/src/gate.js): `src/gate.js`
- **Consumer test command**
- [Evidence bundle](https://github.com/ishaanman7898/api_autopilot/blob/main/src/evidence.js): `src/evidence.js`
- [Draft pull request](https://github.com/ishaanman7898/api_autopilot/blob/main/action.yml): `action.yml`

### Other components

- **API provider**
- **OpenAPI specs**
- **API consumer**

## Connections

- API provider → OpenAPI specs: supplies (evidence: `README.md`)
- OpenAPI specs → CLI commands: drafts from (evidence: `README.md`)
- CLI commands → Spec diff and drafts: diffs specs (evidence: `src/cli.js`)
- Spec diff and drafts → Signed rule file: drafts rules (evidence: `README.md`)
- API provider → Rule validation and signatures: signs rules (evidence: `README.md`)
- Rule validation and signatures → Signed rule file: signs and validates (evidence: `src/rule.js`)
- API consumer → CLI commands: runs commands (evidence: `README.md`)
- CLI commands → Consumer settings: loads settings (evidence: `src/cli.js`)
- CLI commands → Signed rule file: loads and checks (evidence: `src/cli.js`)
- CLI commands → Published signing keys: fetches keys (evidence: `src/cli.js`)
- CLI commands → Consumer code: reads and writes (evidence: `src/cli.js`)
- CLI commands → Deterministic migration: applies rules (evidence: `src/cli.js`)
- Deterministic migration → Untrusted text handling: fences fallback context (evidence: `src/engine.js`)
- Deterministic migration → Fallback agent: flags unresolved calls (evidence: `README.md`)
- CLI commands → Migration gate: gates changes (evidence: `src/cli.js`)
- Migration gate → Untrusted text handling: scans added lines (evidence: `src/gate.js`)
- CLI commands → Consumer test command: runs test command (evidence: `src/cli.js`)
- CLI commands → Evidence bundle: builds evidence (evidence: `src/cli.js`)
- Evidence bundle → Deterministic migration: replays migration (evidence: `src/evidence.js`)
- CLI commands → Evidence bundle: verifies replay (evidence: `src/cli.js`)
- CLI commands → Draft pull request: opens draft PR (evidence: `README.md`)
