# sk3y04/provenance-engine architecture

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

- Interactive diagram: https://gitdiagram.com/sk3y04/provenance-engine
- Repository: https://github.com/sk3y04/provenance-engine

## Overview

Provenance is a single-binary media collector and knowledge vault. Its principal workflow accepts a URL, discovers source items, downloads media, and can archive the result as a searchable, citable revision. Named collections add incremental sync; direct web, PDF, Git, and documentation imports provide alternate vault-ingest routes, while encoding and the terminal UI are separate product capabilities. The graph follows the documented workflow and sampled call sites; some subsystem links rely on README descriptions or source-index references rather than fully inspected implementations.

Main entry points: [`cmd/provenance/main.go`](https://github.com/sk3y04/provenance-engine/blob/master/cmd/provenance/main.go) (CLI commands), [`internal/archive/ingest.go`](https://github.com/sk3y04/provenance-engine/blob/master/internal/archive/ingest.go) (Revision ingest), [`internal/app/app.go`](https://github.com/sk3y04/provenance-engine/blob/master/internal/app/app.go) (Download coordinator), [`internal/collection/sync.go`](https://github.com/sk3y04/provenance-engine/blob/master/internal/collection/sync.go) (Collection sync)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_capture["Collection and capture"]
  node_collection["Collection sync<br/>[sync.go]"]
  node_dispatcher["URL dispatcher<br/>[dispatcher.go]"]
  node_extractors["Source extractors"]
  node_downloader["Media downloader<br/>[downloader.go]"]
end

subgraph group_vault["Archive and vault"]
  node_direct_import["Direct importers"]
  node_archive_ingest["Revision ingest<br/>[ingest.go]"]
  node_blobstore[("Content-addressed blobs<br/>[blobstore.go]")]
  node_catalog[("Vault catalog<br/>[pg.go]")]
  node_citation["Citations<br/>[citation.go]"]
end

subgraph group_operations["Tools and interface"]
  node_cli["CLI commands<br/>[main.go]"]
  node_encode["Media encoding<br/>[run.go]"]
  node_tui["Terminal interface<br/>[views.go]"]
  node_sessions[("Download sessions<br/>[store.go]")]
  node_history[("Run history<br/>[store.go]")]
end

subgraph group_foundation["Runtime foundation"]
  node_public_engine["Engine facade<br/>[engine.go]"]
  node_app["Download coordinator<br/>[app.go]"]
  node_manifest["Capture manifests"]
end

node_user(("User"))
node_external_sources(("Media platforms"))

node_user -->|"runs commands"| node_cli
node_cli -->|"routes grabs"| node_public_engine
node_public_engine -->|"dispatches downloads"| node_app
node_cli -->|"coordinates downloads"| node_app
node_cli -->|"starts sync"| node_collection
node_collection -->|"downloads new items"| node_app
node_app -->|"dispatches URLs"| node_dispatcher
node_dispatcher -->|"routes extraction"| node_extractors
node_dispatcher -->|"downloads media"| node_downloader
node_extractors -.->|"fetches source items"| node_external_sources
node_cli -->|"starts imports"| node_direct_import
node_direct_import -->|"submits captures"| node_archive_ingest
node_cli -->|"archives downloads"| node_archive_ingest
node_archive_ingest -->|"writes blobs"| node_blobstore
node_cli -->|"manages vault"| node_catalog
node_catalog -.->|"stores revisions"| node_archive_ingest
node_cli -->|"produces citations"| node_citation
node_cli -->|"runs encoding"| node_encode
node_user -->|"uses terminal UI"| node_tui
node_tui -->|"loads sessions"| node_sessions
node_tui -->|"reads history"| node_history
node_collection -->|"records captures"| node_manifest

click node_cli "https://github.com/sk3y04/provenance-engine/blob/master/cmd/provenance/main.go"
click node_public_engine "https://github.com/sk3y04/provenance-engine/blob/master/engine/engine.go"
click node_app "https://github.com/sk3y04/provenance-engine/blob/master/internal/app/app.go"
click node_collection "https://github.com/sk3y04/provenance-engine/blob/master/internal/collection/sync.go"
click node_dispatcher "https://github.com/sk3y04/provenance-engine/blob/master/internal/dispatcher/dispatcher.go"
click node_extractors "https://github.com/sk3y04/provenance-engine/tree/master/internal/extractor"
click node_downloader "https://github.com/sk3y04/provenance-engine/blob/master/internal/downloader/downloader.go"
click node_manifest "https://github.com/sk3y04/provenance-engine/tree/master/internal/manifest"
click node_direct_import "https://github.com/sk3y04/provenance-engine/tree/master/internal/importers"
click node_archive_ingest "https://github.com/sk3y04/provenance-engine/blob/master/internal/archive/ingest.go"
click node_blobstore "https://github.com/sk3y04/provenance-engine/blob/master/internal/blobstore/blobstore.go"
click node_catalog "https://github.com/sk3y04/provenance-engine/blob/master/internal/catalog/pg.go"
click node_citation "https://github.com/sk3y04/provenance-engine/blob/master/internal/citation/citation.go"
click node_encode "https://github.com/sk3y04/provenance-engine/blob/master/internal/encode/run.go"
click node_tui "https://github.com/sk3y04/provenance-engine/blob/master/internal/tui/views.go"
click node_sessions "https://github.com/sk3y04/provenance-engine/blob/master/internal/session/store.go"
click node_history "https://github.com/sk3y04/provenance-engine/blob/master/internal/history/store.go"

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_collection,node_dispatcher,node_extractors,node_downloader,node_user toneBlue
class node_direct_import,node_archive_ingest,node_blobstore,node_catalog,node_citation toneAmber
class node_cli,node_encode,node_tui,node_sessions,node_history toneMint
class node_public_engine,node_app,node_manifest toneRose
class node_external_sources toneIndigo
```

## Components

### Collection and capture

- [Collection sync](https://github.com/sk3y04/provenance-engine/blob/master/internal/collection/sync.go): `internal/collection/sync.go`
- [URL dispatcher](https://github.com/sk3y04/provenance-engine/blob/master/internal/dispatcher/dispatcher.go): `internal/dispatcher/dispatcher.go`
- [Source extractors](https://github.com/sk3y04/provenance-engine/tree/master/internal/extractor): `internal/extractor`
- [Media downloader](https://github.com/sk3y04/provenance-engine/blob/master/internal/downloader/downloader.go): `internal/downloader/downloader.go`

### Archive and vault

- [Direct importers](https://github.com/sk3y04/provenance-engine/tree/master/internal/importers): `internal/importers`
- [Revision ingest](https://github.com/sk3y04/provenance-engine/blob/master/internal/archive/ingest.go): `internal/archive/ingest.go`
- [Content-addressed blobs](https://github.com/sk3y04/provenance-engine/blob/master/internal/blobstore/blobstore.go): `internal/blobstore/blobstore.go`
- [Vault catalog](https://github.com/sk3y04/provenance-engine/blob/master/internal/catalog/pg.go): `internal/catalog/pg.go`
- [Citations](https://github.com/sk3y04/provenance-engine/blob/master/internal/citation/citation.go): `internal/citation/citation.go`

### Tools and interface

- [CLI commands](https://github.com/sk3y04/provenance-engine/blob/master/cmd/provenance/main.go): `cmd/provenance/main.go`
- [Media encoding](https://github.com/sk3y04/provenance-engine/blob/master/internal/encode/run.go): `internal/encode/run.go`
- [Terminal interface](https://github.com/sk3y04/provenance-engine/blob/master/internal/tui/views.go): `internal/tui/views.go`
- [Download sessions](https://github.com/sk3y04/provenance-engine/blob/master/internal/session/store.go): `internal/session/store.go`
- [Run history](https://github.com/sk3y04/provenance-engine/blob/master/internal/history/store.go): `internal/history/store.go`

### Runtime foundation

- [Engine facade](https://github.com/sk3y04/provenance-engine/blob/master/engine/engine.go): `engine/engine.go`
- [Download coordinator](https://github.com/sk3y04/provenance-engine/blob/master/internal/app/app.go): `internal/app/app.go`
- [Capture manifests](https://github.com/sk3y04/provenance-engine/tree/master/internal/manifest): `internal/manifest`

### Other components

- **User**
- **Media platforms**

## Connections

- User → CLI commands: runs commands
- CLI commands → Engine facade: routes grabs
- Engine facade → Download coordinator: dispatches downloads (evidence: `engine/engine.go`)
- CLI commands → Download coordinator: coordinates downloads (evidence: `internal/app/app.go`)
- CLI commands → Collection sync: starts sync (evidence: `cmd/provenance/main.go`)
- Collection sync → Download coordinator: downloads new items (evidence: `internal/collection/sync.go`)
- Download coordinator → URL dispatcher: dispatches URLs (evidence: `internal/app/app.go`)
- URL dispatcher → Source extractors: routes extraction (evidence: `internal/dispatcher/dispatcher.go`)
- URL dispatcher → Media downloader: downloads media (evidence: `internal/dispatcher/dispatcher.go`)
- Source extractors → Media platforms: fetches source items
- CLI commands → Direct importers: starts imports (evidence: `cmd/provenance/main.go`)
- Direct importers → Revision ingest: submits captures (evidence: `internal/importers/web.go`)
- CLI commands → Revision ingest: archives downloads (evidence: `cmd/provenance/main.go`)
- Revision ingest → Content-addressed blobs: writes blobs (evidence: `internal/archive/ingest.go`)
- CLI commands → Vault catalog: manages vault (evidence: `cmd/provenance/main.go`)
- Vault catalog → Revision ingest: stores revisions (evidence: `internal/catalog/pg.go`)
- CLI commands → Citations: produces citations (evidence: `cmd/provenance/main.go`)
- CLI commands → Media encoding: runs encoding (evidence: `cmd/provenance/main.go`)
- User → Terminal interface: uses terminal UI
- Terminal interface → Download sessions: loads sessions
- Terminal interface → Run history: reads history (evidence: `internal/tui/views.go`)
- Collection sync → Capture manifests: records captures (evidence: `internal/collection/sync.go`)
