# shraman-c/codecanon architecture

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

- Interactive diagram: https://gitdiagram.com/shraman-c/codecanon
- Repository: https://github.com/shraman-c/codecanon

## Overview

codeCanon is a documentation-drift scanner for JavaScript/TypeScript repositories, exposed as a CLI, a local GUI, and an Agent Skill. Its main workflow scans a target repository for code facts and documentation claims, compares them deterministically, escalates ambiguous findings to an AI judge, optionally checks referenced images, and generates verified patch suggestions and reports. The CLI pipeline order and major capabilities are documented; some wiring is supported only by the SOURCE INDEX, so unsampled GUI and Skill internals are not expanded.

Main entry points: [`scripts/drift.py`](https://github.com/shraman-c/codecanon/blob/main/scripts/drift.py) (Scan CLI), [`drift/extract_images.py`](https://github.com/shraman-c/codecanon/blob/main/drift/extract_images.py) (Screenshot Claims), [`drift/judge.py`](https://github.com/shraman-c/codecanon/blob/main/drift/judge.py) (AI Judge), [`drift/vision.py`](https://github.com/shraman-c/codecanon/blob/main/drift/vision.py) (Image Vision)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["User Interfaces"]
  node_cli["Scan CLI<br/>[drift.py]"]
  node_gui["Desktop GUI<br/>[gui.py]"]
  node_skill["Agent Skill<br/>[SKILL.md]"]
end

subgraph group_extract["Fact and Claim Extraction"]
  node_detect["Stack Detection<br/>[detect.py]"]
  node_fact_routes["Route Facts<br/>[extract_routes.py]"]
  node_fact_env["Environment Facts<br/>[extract_env.py]"]
  node_fact_pkg["Package Facts<br/>[extract_pkg.py]"]
  node_fact_ports["Port Facts<br/>[extract_ports.py]"]
  node_doc_claims["Text Claims<br/>[extract_docs.py]"]
  node_image_claims["Screenshot Claims<br/>[extract_images.py]"]
  node_models["Fact Claim Models<br/>[models.py]"]
end

subgraph group_evaluate["Drift Evaluation"]
  node_matcher["Deterministic Matcher<br/>[match.py]"]
  node_judge["AI Judge<br/>[judge.py]"]
  node_vision["Image Vision<br/>[vision.py]"]
  node_llm["Gemma Client<br/>[llm.py]"]
end

subgraph group_remediate["Remediation and Reporting"]
  node_patch["Patch Generator<br/>[patch.py]"]
  node_report["Drift Reports<br/>[report.py]"]
end

node_developer(("Developer"))
node_target["Target Repository"]

node_developer -->|"runs scan"| node_cli
node_cli -->|"scans"| node_target
node_developer -->|"launches"| node_gui
node_developer -->|"uses"| node_skill
node_cli -->|"detects stack"| node_detect
node_cli -->|"extracts routes"| node_fact_routes
node_cli -->|"extracts variables"| node_fact_env
node_cli -->|"extracts package facts"| node_fact_pkg
node_cli -->|"extracts ports"| node_fact_ports
node_cli -->|"extracts claims"| node_doc_claims
node_cli -->|"extracts images"| node_image_claims
node_cli -->|"matches claims"| node_matcher
node_cli -->|"judges findings"| node_judge
node_cli -->|"generates patches"| node_patch
node_cli -->|"writes reports"| node_report
node_image_claims -->|"extracts image text"| node_vision
node_vision -->|"uses model client"| node_llm
node_judge -->|"requests verdicts"| node_llm

click node_cli "https://github.com/shraman-c/codecanon/blob/main/scripts/drift.py"
click node_gui "https://github.com/shraman-c/codecanon/blob/main/scripts/gui.py"
click node_skill "https://github.com/shraman-c/codecanon/blob/main/SKILL.md"
click node_detect "https://github.com/shraman-c/codecanon/blob/main/drift/detect.py"
click node_fact_routes "https://github.com/shraman-c/codecanon/blob/main/drift/extract_routes.py"
click node_fact_env "https://github.com/shraman-c/codecanon/blob/main/drift/extract_env.py"
click node_fact_pkg "https://github.com/shraman-c/codecanon/blob/main/drift/extract_pkg.py"
click node_fact_ports "https://github.com/shraman-c/codecanon/blob/main/drift/extract_ports.py"
click node_doc_claims "https://github.com/shraman-c/codecanon/blob/main/drift/extract_docs.py"
click node_image_claims "https://github.com/shraman-c/codecanon/blob/main/drift/extract_images.py"
click node_models "https://github.com/shraman-c/codecanon/blob/main/drift/models.py"
click node_matcher "https://github.com/shraman-c/codecanon/blob/main/drift/match.py"
click node_judge "https://github.com/shraman-c/codecanon/blob/main/drift/judge.py"
click node_vision "https://github.com/shraman-c/codecanon/blob/main/drift/vision.py"
click node_llm "https://github.com/shraman-c/codecanon/blob/main/drift/llm.py"
click node_patch "https://github.com/shraman-c/codecanon/blob/main/drift/patch.py"
click node_report "https://github.com/shraman-c/codecanon/blob/main/drift/report.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_cli,node_gui,node_skill toneBlue
class node_detect,node_fact_routes,node_fact_env,node_fact_pkg,node_fact_ports,node_doc_claims,node_image_claims,node_models toneAmber
class node_matcher,node_judge,node_vision,node_llm toneMint
class node_patch,node_report toneRose
class node_developer,node_target toneIndigo
```

## Components

### User Interfaces

- [Scan CLI](https://github.com/shraman-c/codecanon/blob/main/scripts/drift.py): `scripts/drift.py`
- [Desktop GUI](https://github.com/shraman-c/codecanon/blob/main/scripts/gui.py): `scripts/gui.py`
- [Agent Skill](https://github.com/shraman-c/codecanon/blob/main/SKILL.md): `SKILL.md`

### Fact and Claim Extraction

- [Stack Detection](https://github.com/shraman-c/codecanon/blob/main/drift/detect.py): `drift/detect.py`
- [Route Facts](https://github.com/shraman-c/codecanon/blob/main/drift/extract_routes.py): `drift/extract_routes.py`
- [Environment Facts](https://github.com/shraman-c/codecanon/blob/main/drift/extract_env.py): `drift/extract_env.py`
- [Package Facts](https://github.com/shraman-c/codecanon/blob/main/drift/extract_pkg.py): `drift/extract_pkg.py`
- [Port Facts](https://github.com/shraman-c/codecanon/blob/main/drift/extract_ports.py): `drift/extract_ports.py`
- [Text Claims](https://github.com/shraman-c/codecanon/blob/main/drift/extract_docs.py): `drift/extract_docs.py`
- [Screenshot Claims](https://github.com/shraman-c/codecanon/blob/main/drift/extract_images.py): `drift/extract_images.py`
- [Fact Claim Models](https://github.com/shraman-c/codecanon/blob/main/drift/models.py): `drift/models.py`

### Drift Evaluation

- [Deterministic Matcher](https://github.com/shraman-c/codecanon/blob/main/drift/match.py): `drift/match.py`
- [AI Judge](https://github.com/shraman-c/codecanon/blob/main/drift/judge.py): `drift/judge.py`
- [Image Vision](https://github.com/shraman-c/codecanon/blob/main/drift/vision.py): `drift/vision.py`
- [Gemma Client](https://github.com/shraman-c/codecanon/blob/main/drift/llm.py): `drift/llm.py`

### Remediation and Reporting

- [Patch Generator](https://github.com/shraman-c/codecanon/blob/main/drift/patch.py): `drift/patch.py`
- [Drift Reports](https://github.com/shraman-c/codecanon/blob/main/drift/report.py): `drift/report.py`

### Other components

- **Developer**
- **Target Repository**

## Connections

- Developer → Scan CLI: runs scan (evidence: `README.md`)
- Scan CLI → Target Repository: scans (evidence: `README.md`)
- Developer → Desktop GUI: launches (evidence: `README.md`)
- Developer → Agent Skill: uses (evidence: `README.md`)
- Scan CLI → Stack Detection: detects stack (evidence: `scripts/drift.py`)
- Scan CLI → Route Facts: extracts routes (evidence: `scripts/drift.py`)
- Scan CLI → Environment Facts: extracts variables (evidence: `scripts/drift.py`)
- Scan CLI → Package Facts: extracts package facts (evidence: `scripts/drift.py`)
- Scan CLI → Port Facts: extracts ports (evidence: `scripts/drift.py`)
- Scan CLI → Text Claims: extracts claims (evidence: `scripts/drift.py`)
- Scan CLI → Screenshot Claims: extracts images (evidence: `scripts/drift.py`)
- Scan CLI → Deterministic Matcher: matches claims (evidence: `scripts/drift.py`)
- Scan CLI → AI Judge: judges findings (evidence: `scripts/drift.py`)
- Scan CLI → Patch Generator: generates patches (evidence: `scripts/drift.py`)
- Scan CLI → Drift Reports: writes reports (evidence: `scripts/drift.py`)
- Screenshot Claims → Image Vision: extracts image text (evidence: `drift/extract_images.py`)
- Image Vision → Gemma Client: uses model client (evidence: `drift/vision.py`)
- AI Judge → Gemma Client: requests verdicts (evidence: `drift/judge.py`)
