# storytold/autocraft architecture

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

- Interactive diagram: https://gitdiagram.com/storytold/autocraft
- Repository: https://github.com/storytold/autocraft

## Overview

AutoCraft mirrors GitHub repositories into a local database, processes items through a staged model-assisted maintenance pipeline, and exposes decisions, approvals, and item status through a dashboard. The principal workflow runs from repository sync through classification and maintainer decisions to reviewed fixes, verification, and safe merging; actions that need human judgment stop for operator input. The README documents the stage order and capabilities. Source-index references support selected internal links; relationships involving unsampled modules are omitted where the evidence does not establish a call.

Main entry points: [`src/runner/index.ts`](https://github.com/storytold/autocraft/blob/main/src/runner/index.ts) (Pipeline runner), [`src/decisions.ts`](https://github.com/storytold/autocraft/blob/main/src/decisions.ts) (Maintainer decisions), [`src/dash/api/pipeline.ts`](https://github.com/storytold/autocraft/blob/main/src/dash/api/pipeline.ts) (Dashboard API), [`src/db/open.ts`](https://github.com/storytold/autocraft/blob/main/src/db/open.ts) (Local database)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_orchestration["Pipeline control"]
  node_runner["Pipeline runner<br/>[index.ts]"]
  node_sync["GitHub sync<br/>[mirror.ts]"]
end

subgraph group_analysis["Item analysis"]
  node_duplicates["Duplicate detection<br/>[index.ts]"]
  node_classify["Classify items<br/>[run.ts]"]
  node_priority["Prioritize items<br/>[index.ts]"]
  node_decide["Maintainer decisions<br/>[decisions.ts]"]
end

subgraph group_maintenance["Repository actions"]
  node_labels["Apply labels<br/>[index.ts]"]
  node_review["PR review<br/>[index.ts]"]
  node_implement["Issue implementation<br/>[session.ts]"]
  node_fixup["PR fix-up<br/>[index.ts]"]
  node_verify["Build and verify<br/>[index.ts]"]
  node_merge["Merge queue<br/>[index.ts]"]
  node_act["Decision actions<br/>[index.ts]"]
  node_postmerge["Post-merge review<br/>[index.ts]"]
end

subgraph group_interface["Operator interface"]
  node_dashboard["Dashboard API<br/>[pipeline.ts]"]
  node_web["Dashboard UI<br/>[main.tsx]"]
end

subgraph group_storage["Data and safeguards"]
  node_database[("Local database<br/>[open.ts]")]
  node_guard["Write guard<br/>[guard.ts]"]
  node_github["GitHub writes<br/>[write.ts]"]
  node_prompts["Model prompts<br/>[index.ts]"]
end

node_operator(("Maintainer / operator"))

node_operator -->|"uses dashboard"| node_web
node_web -.->|"requests pipeline"| node_dashboard
node_dashboard -->|"controls jobs"| node_runner
node_runner -->|"runs sync"| node_sync
node_sync -->|"feeds items"| node_duplicates
node_duplicates -->|"then classifies"| node_classify
node_classify -->|"then prioritizes"| node_priority
node_priority -->|"then prepares decisions"| node_decide
node_decide -->|"then labels"| node_labels
node_labels -->|"then reviews"| node_review
node_review -->|"then implements"| node_implement
node_implement -->|"then fixes up"| node_fixup
node_fixup -->|"then verifies"| node_verify
node_verify -->|"then merges"| node_merge
node_merge -->|"then acts"| node_act
node_act -->|"then reviews landed changes"| node_postmerge
node_operator -->|"answers questions"| node_decide
node_operator -->|"sets approvals"| node_dashboard
node_runner -.->|"uses database"| node_database
node_runner -->|"selects prompts"| node_prompts
node_github -->|"checks writes"| node_guard
node_guard -->|"reads facts and approvals"| node_database
node_github -.->|"records audit"| node_database

click node_runner "https://github.com/storytold/autocraft/blob/main/src/runner/index.ts"
click node_sync "https://github.com/storytold/autocraft/blob/main/src/mirror.ts"
click node_duplicates "https://github.com/storytold/autocraft/blob/main/src/dupes/index.ts"
click node_classify "https://github.com/storytold/autocraft/blob/main/src/classify/run.ts"
click node_priority "https://github.com/storytold/autocraft/blob/main/src/priority/index.ts"
click node_decide "https://github.com/storytold/autocraft/blob/main/src/decisions.ts"
click node_labels "https://github.com/storytold/autocraft/blob/main/src/labels/index.ts"
click node_review "https://github.com/storytold/autocraft/blob/main/src/review/index.ts"
click node_implement "https://github.com/storytold/autocraft/blob/main/src/implement/session.ts"
click node_fixup "https://github.com/storytold/autocraft/blob/main/src/fixup/index.ts"
click node_verify "https://github.com/storytold/autocraft/blob/main/src/verify/index.ts"
click node_merge "https://github.com/storytold/autocraft/blob/main/src/merge/index.ts"
click node_act "https://github.com/storytold/autocraft/blob/main/src/act/index.ts"
click node_postmerge "https://github.com/storytold/autocraft/blob/main/src/postmerge/index.ts"
click node_dashboard "https://github.com/storytold/autocraft/blob/main/src/dash/api/pipeline.ts"
click node_web "https://github.com/storytold/autocraft/blob/main/web/src/main.tsx"
click node_database "https://github.com/storytold/autocraft/blob/main/src/db/open.ts"
click node_guard "https://github.com/storytold/autocraft/blob/main/src/core/guard.ts"
click node_github "https://github.com/storytold/autocraft/blob/main/src/github/write.ts"
click node_prompts "https://github.com/storytold/autocraft/blob/main/src/prompts/index.ts"

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_runner,node_sync toneBlue
class node_duplicates,node_classify,node_priority,node_decide toneAmber
class node_labels,node_review,node_implement,node_fixup,node_verify,node_merge,node_act,node_postmerge toneMint
class node_dashboard,node_web toneRose
class node_database,node_guard,node_github,node_prompts,node_operator toneIndigo
```

## Components

### Pipeline control

- [Pipeline runner](https://github.com/storytold/autocraft/blob/main/src/runner/index.ts): `src/runner/index.ts`
- [GitHub sync](https://github.com/storytold/autocraft/blob/main/src/mirror.ts): `src/mirror.ts`

### Item analysis

- [Duplicate detection](https://github.com/storytold/autocraft/blob/main/src/dupes/index.ts): `src/dupes/index.ts`
- [Classify items](https://github.com/storytold/autocraft/blob/main/src/classify/run.ts): `src/classify/run.ts`
- [Prioritize items](https://github.com/storytold/autocraft/blob/main/src/priority/index.ts): `src/priority/index.ts`
- [Maintainer decisions](https://github.com/storytold/autocraft/blob/main/src/decisions.ts): `src/decisions.ts`

### Repository actions

- [Apply labels](https://github.com/storytold/autocraft/blob/main/src/labels/index.ts): `src/labels/index.ts`
- [PR review](https://github.com/storytold/autocraft/blob/main/src/review/index.ts): `src/review/index.ts`
- [Issue implementation](https://github.com/storytold/autocraft/blob/main/src/implement/session.ts): `src/implement/session.ts`
- [PR fix-up](https://github.com/storytold/autocraft/blob/main/src/fixup/index.ts): `src/fixup/index.ts`
- [Build and verify](https://github.com/storytold/autocraft/blob/main/src/verify/index.ts): `src/verify/index.ts`
- [Merge queue](https://github.com/storytold/autocraft/blob/main/src/merge/index.ts): `src/merge/index.ts`
- [Decision actions](https://github.com/storytold/autocraft/blob/main/src/act/index.ts): `src/act/index.ts`
- [Post-merge review](https://github.com/storytold/autocraft/blob/main/src/postmerge/index.ts): `src/postmerge/index.ts`

### Operator interface

- [Dashboard API](https://github.com/storytold/autocraft/blob/main/src/dash/api/pipeline.ts): `src/dash/api/pipeline.ts`
- [Dashboard UI](https://github.com/storytold/autocraft/blob/main/web/src/main.tsx): `web/src/main.tsx`

### Data and safeguards

- [Local database](https://github.com/storytold/autocraft/blob/main/src/db/open.ts): `src/db/open.ts`
- [Write guard](https://github.com/storytold/autocraft/blob/main/src/core/guard.ts): `src/core/guard.ts`
- [GitHub writes](https://github.com/storytold/autocraft/blob/main/src/github/write.ts): `src/github/write.ts`
- [Model prompts](https://github.com/storytold/autocraft/blob/main/src/prompts/index.ts): `src/prompts/index.ts`

### Other components

- **Maintainer / operator**

## Connections

- Maintainer / operator → Dashboard UI: uses dashboard (evidence: `README.md`)
- Dashboard UI → Dashboard API: requests pipeline
- Dashboard API → Pipeline runner: controls jobs (evidence: `src/dash/api/pipeline.ts`)
- Pipeline runner → GitHub sync: runs sync (evidence: `README.md`)
- GitHub sync → Duplicate detection: feeds items (evidence: `README.md`)
- Duplicate detection → Classify items: then classifies (evidence: `README.md`)
- Classify items → Prioritize items: then prioritizes (evidence: `README.md`)
- Prioritize items → Maintainer decisions: then prepares decisions (evidence: `README.md`)
- Maintainer decisions → Apply labels: then labels (evidence: `README.md`)
- Apply labels → PR review: then reviews (evidence: `README.md`)
- PR review → Issue implementation: then implements (evidence: `README.md`)
- Issue implementation → PR fix-up: then fixes up (evidence: `README.md`)
- PR fix-up → Build and verify: then verifies (evidence: `README.md`)
- Build and verify → Merge queue: then merges (evidence: `README.md`)
- Merge queue → Decision actions: then acts (evidence: `README.md`)
- Decision actions → Post-merge review: then reviews landed changes (evidence: `README.md`)
- Maintainer / operator → Maintainer decisions: answers questions (evidence: `README.md`)
- Maintainer / operator → Dashboard API: sets approvals (evidence: `README.md`)
- Pipeline runner → Local database: uses database (evidence: `src/runner/index.ts`)
- Pipeline runner → Model prompts: selects prompts (evidence: `src/prompts/index.ts`)
- GitHub writes → Write guard: checks writes (evidence: `src/github/write.ts`)
- Write guard → Local database: reads facts and approvals (evidence: `src/core/guard.ts`)
- GitHub writes → Local database: records audit (evidence: `src/github/write.ts`)
