# watchcodes/codefoundry architecture

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

- Interactive diagram: https://gitdiagram.com/watchcodes/codefoundry
- Repository: https://github.com/watchcodes/codefoundry

## Overview

CodeFoundry is the WatchCodes migration executor: it accepts a RepoAtlas MigrationRequest and aims to produce a verified destination repository plus one MigrationReport. The principal flow validates the request, scans the pinned source snapshot for licence and structure, clones it, applies branding and attribution, ships privately, verifies gates, then records the report and receipt. The graph also shows contract validation, durable records, and approval-dependent publication. Edges follow the pipeline excerpt or explicit README statements; some implementation details, especially final verification and publication, were not sampled.

Main entry points: [`codefoundry/pipeline.py`](https://github.com/watchcodes/codefoundry/blob/main/codefoundry/pipeline.py) (Migration pipeline), [`codefoundry/ship.py`](https://github.com/watchcodes/codefoundry/blob/main/codefoundry/ship.py) (Private repository shipping), [`codefoundry/cli.py`](https://github.com/watchcodes/codefoundry/blob/main/codefoundry/cli.py) (CLI), [`codefoundry/intake.py`](https://github.com/watchcodes/codefoundry/blob/main/codefoundry/intake.py) (Request intake)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["Request entry"]
  node_cli["CLI<br/>[cli.py]"]
end

subgraph group_migration["Migration execution"]
  node_pipeline["Migration pipeline<br/>[pipeline.py]"]
  node_intake["Request intake<br/>[intake.py]"]
  node_scan["Licence and structure scan<br/>[scan.py]"]
  node_clone["Pinned snapshot clone<br/>[clone.py]"]
  node_brand["Brand cleanup and gate<br/>[brand.py]"]
  node_credits["Attribution artifacts<br/>[credits.py]"]
  node_ship["Private repository shipping<br/>[ship.py]"]
  node_verify["Destination verification<br/>[pipeline.py]"]
end

subgraph group_records["Contracts and records"]
  node_contracts["Contract validation<br/>[contracts.py]"]
  node_reportbuild["Report construction<br/>[report.py]"]
  node_receipts[("Resume receipts<br/>[receipts.py]")]
  node_reportstore[("Append-only reports<br/>[reports.py]")]
end

subgraph group_external["External systems"]
  node_sourcehost(("Upstream Git source"))
  node_destination[("Destination Git hosting")]
end

node_repoatlas(("RepoAtlas"))
node_approver(("Human approver"))

node_repoatlas -->|"submits request"| node_cli
node_cli -->|"runs migration"| node_pipeline
node_pipeline -->|"validates request"| node_intake
node_intake -->|"checks schema"| node_contracts
node_pipeline -->|"scans source"| node_scan
node_pipeline -->|"clones pinned SHA"| node_clone
node_pipeline -->|"applies branding"| node_brand
node_pipeline -->|"adds attribution"| node_credits
node_pipeline -->|"ships privately"| node_ship
node_pipeline -->|"checks destination"| node_verify
node_pipeline -->|"builds report"| node_reportbuild
node_reportbuild -->|"validates report"| node_contracts
node_pipeline -->|"loads and saves"| node_receipts
node_pipeline -->|"persists report"| node_reportstore
node_sourcehost -->|"provides snapshot"| node_clone
node_ship -->|"creates private repo"| node_destination
node_approver -.->|"approves publication"| node_ship
node_ship -.->|"publishes after approval"| node_destination

click node_cli "https://github.com/watchcodes/codefoundry/blob/main/codefoundry/cli.py"
click node_pipeline "https://github.com/watchcodes/codefoundry/blob/main/codefoundry/pipeline.py"
click node_intake "https://github.com/watchcodes/codefoundry/blob/main/codefoundry/intake.py"
click node_contracts "https://github.com/watchcodes/codefoundry/blob/main/codefoundry/contracts.py"
click node_scan "https://github.com/watchcodes/codefoundry/blob/main/codefoundry/scan.py"
click node_clone "https://github.com/watchcodes/codefoundry/blob/main/codefoundry/clone.py"
click node_brand "https://github.com/watchcodes/codefoundry/blob/main/codefoundry/brand.py"
click node_credits "https://github.com/watchcodes/codefoundry/blob/main/codefoundry/credits.py"
click node_ship "https://github.com/watchcodes/codefoundry/blob/main/codefoundry/ship.py"
click node_verify "https://github.com/watchcodes/codefoundry/blob/main/codefoundry/pipeline.py"
click node_reportbuild "https://github.com/watchcodes/codefoundry/blob/main/codefoundry/report.py"
click node_receipts "https://github.com/watchcodes/codefoundry/blob/main/codefoundry/receipts.py"
click node_reportstore "https://github.com/watchcodes/codefoundry/blob/main/codefoundry/reports.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 toneBlue
class node_pipeline,node_intake,node_scan,node_clone,node_brand,node_credits,node_ship,node_verify toneAmber
class node_contracts,node_reportbuild,node_receipts,node_reportstore toneMint
class node_sourcehost,node_destination toneRose
class node_repoatlas,node_approver toneIndigo
```

## Components

### Request entry

- [CLI](https://github.com/watchcodes/codefoundry/blob/main/codefoundry/cli.py): `codefoundry/cli.py`

### Migration execution

- [Migration pipeline](https://github.com/watchcodes/codefoundry/blob/main/codefoundry/pipeline.py): `codefoundry/pipeline.py`
- [Request intake](https://github.com/watchcodes/codefoundry/blob/main/codefoundry/intake.py): `codefoundry/intake.py`
- [Licence and structure scan](https://github.com/watchcodes/codefoundry/blob/main/codefoundry/scan.py): `codefoundry/scan.py`
- [Pinned snapshot clone](https://github.com/watchcodes/codefoundry/blob/main/codefoundry/clone.py): `codefoundry/clone.py`
- [Brand cleanup and gate](https://github.com/watchcodes/codefoundry/blob/main/codefoundry/brand.py): `codefoundry/brand.py`
- [Attribution artifacts](https://github.com/watchcodes/codefoundry/blob/main/codefoundry/credits.py): `codefoundry/credits.py`
- [Private repository shipping](https://github.com/watchcodes/codefoundry/blob/main/codefoundry/ship.py): `codefoundry/ship.py`
- [Destination verification](https://github.com/watchcodes/codefoundry/blob/main/codefoundry/pipeline.py): `codefoundry/pipeline.py`

### Contracts and records

- [Contract validation](https://github.com/watchcodes/codefoundry/blob/main/codefoundry/contracts.py): `codefoundry/contracts.py`
- [Report construction](https://github.com/watchcodes/codefoundry/blob/main/codefoundry/report.py): `codefoundry/report.py`
- [Resume receipts](https://github.com/watchcodes/codefoundry/blob/main/codefoundry/receipts.py): `codefoundry/receipts.py`
- [Append-only reports](https://github.com/watchcodes/codefoundry/blob/main/codefoundry/reports.py): `codefoundry/reports.py`

### External systems

- **Upstream Git source**
- **Destination Git hosting**

### Other components

- **RepoAtlas**
- **Human approver**

## Connections

- RepoAtlas → CLI: submits request (evidence: `README.md`)
- CLI → Migration pipeline: runs migration (evidence: `codefoundry/cli.py`)
- Migration pipeline → Request intake: validates request (evidence: `codefoundry/pipeline.py`)
- Request intake → Contract validation: checks schema (evidence: `codefoundry/intake.py`)
- Migration pipeline → Licence and structure scan: scans source (evidence: `codefoundry/pipeline.py`)
- Migration pipeline → Pinned snapshot clone: clones pinned SHA (evidence: `codefoundry/pipeline.py`)
- Migration pipeline → Brand cleanup and gate: applies branding (evidence: `codefoundry/pipeline.py`)
- Migration pipeline → Attribution artifacts: adds attribution (evidence: `codefoundry/pipeline.py`)
- Migration pipeline → Private repository shipping: ships privately (evidence: `codefoundry/pipeline.py`)
- Migration pipeline → Destination verification: checks destination (evidence: `README.md`)
- Migration pipeline → Report construction: builds report (evidence: `codefoundry/pipeline.py`)
- Report construction → Contract validation: validates report (evidence: `codefoundry/report.py`)
- Migration pipeline → Resume receipts: loads and saves (evidence: `codefoundry/pipeline.py`)
- Migration pipeline → Append-only reports: persists report (evidence: `codefoundry/pipeline.py`)
- Upstream Git source → Pinned snapshot clone: provides snapshot (evidence: `README.md`)
- Private repository shipping → Destination Git hosting: creates private repo (evidence: `README.md`)
- Human approver → Private repository shipping: approves publication (evidence: `README.md`)
- Private repository shipping → Destination Git hosting: publishes after approval (evidence: `README.md`)
