# joireve/clipbank architecture

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

- Interactive diagram: https://gitdiagram.com/joireve/clipbank
- Repository: https://github.com/joireve/clipbank

## Overview

ClipBank is a command-line video preparation library: users initialize a library, add or retry videos, then inspect, verify, or export a manifest for downstream detection. The add workflow probes and identifies inputs, normalizes them to the detect profile, segments and thumbnails them, hashes outputs, and records metadata for resumable runs. The graph includes documented capabilities whose implementation excerpts were not shown; those links cite the README where applicable.

Main entry points: [`src/pipeline.cpp`](https://github.com/joireve/clipbank/blob/main/src/pipeline.cpp) (Add and retry), [`src/main.cpp`](https://github.com/joireve/clipbank/blob/main/src/main.cpp) (Command router), [`src/subprocess.cpp`](https://github.com/joireve/clipbank/blob/main/src/subprocess.cpp) (Process runner), [`src/manifest.cpp`](https://github.com/joireve/clipbank/blob/main/src/manifest.cpp) (Manifest export)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_cli["CLI workflows"]
  node_cli["Command router<br/>[main.cpp]"]
  node_manifest["Manifest export<br/>[manifest.cpp]"]
  node_verify["Library verification<br/>[verify.cpp]"]
  node_listing["Run listing<br/>[db.cpp]"]
end

subgraph group_media["Media processing"]
  node_pipeline["Add and retry<br/>[pipeline.cpp]"]
  node_probe["Media probe<br/>[probe.cpp]"]
  node_profile["Detect profile<br/>[profile.cpp]"]
  node_normalize["Normalize video<br/>[pipeline.cpp]"]
  node_segment["Segment clips<br/>[pipeline.cpp]"]
  node_thumbnail["Thumbnail<br/>[pipeline.cpp]"]
  node_hash["Content hashes<br/>[sha256.cpp]"]
end

subgraph group_catalog["Library catalog"]
  node_library["Library setup<br/>[library.cpp]"]
  node_db[("SQLite index<br/>[db.cpp]")]
  node_paths["Library paths<br/>[library.cpp]"]
end

subgraph group_support["Runtime support"]
  node_subprocess["Process runner<br/>[subprocess.cpp]"]
  node_util["File utilities<br/>[util.cpp]"]
end

node_operator(("Operator"))
node_ffmpeg["ffmpeg / ffprobe"]
node_consumer(("Detection project"))

node_operator -->|"runs commands"| node_cli
node_cli -->|"initializes library"| node_library
node_cli -->|"adds or retries"| node_pipeline
node_cli -->|"exports manifest"| node_manifest
node_cli -->|"verifies runs"| node_verify
node_cli -->|"lists runs"| node_listing
node_library -->|"creates schema"| node_db
node_pipeline -->|"probes input"| node_probe
node_pipeline -->|"uses profile"| node_profile
node_pipeline -->|"runs stage"| node_normalize
node_pipeline -->|"runs stage"| node_segment
node_pipeline -->|"runs stage"| node_thumbnail
node_pipeline -->|"hashes outputs"| node_hash
node_pipeline -->|"records run state"| node_db
node_pipeline -->|"uses library paths"| node_paths
node_manifest -->|"reads run records"| node_db
node_manifest -->|"uses library paths"| node_paths
node_verify -->|"checks records"| node_db
node_verify -->|"checks media"| node_probe
node_normalize -->|"runs process"| node_subprocess
node_segment -->|"runs process"| node_subprocess
node_thumbnail -->|"runs process"| node_subprocess
node_probe -->|"runs probe tools"| node_subprocess
node_subprocess -->|"executes tools"| node_ffmpeg
node_consumer -.->|"consumes exported data"| node_manifest

click node_cli "https://github.com/joireve/clipbank/blob/main/src/main.cpp"
click node_library "https://github.com/joireve/clipbank/blob/main/src/library.cpp"
click node_pipeline "https://github.com/joireve/clipbank/blob/main/src/pipeline.cpp"
click node_probe "https://github.com/joireve/clipbank/blob/main/src/probe.cpp"
click node_profile "https://github.com/joireve/clipbank/blob/main/src/profile.cpp"
click node_normalize "https://github.com/joireve/clipbank/blob/main/src/pipeline.cpp"
click node_segment "https://github.com/joireve/clipbank/blob/main/src/pipeline.cpp"
click node_thumbnail "https://github.com/joireve/clipbank/blob/main/src/pipeline.cpp"
click node_hash "https://github.com/joireve/clipbank/blob/main/src/sha256.cpp"
click node_manifest "https://github.com/joireve/clipbank/blob/main/src/manifest.cpp"
click node_verify "https://github.com/joireve/clipbank/blob/main/src/verify.cpp"
click node_listing "https://github.com/joireve/clipbank/blob/main/src/db.cpp"
click node_db "https://github.com/joireve/clipbank/blob/main/src/db.cpp"
click node_paths "https://github.com/joireve/clipbank/blob/main/src/library.cpp"
click node_subprocess "https://github.com/joireve/clipbank/blob/main/src/subprocess.cpp"
click node_util "https://github.com/joireve/clipbank/blob/main/src/util.cpp"

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_manifest,node_verify,node_listing toneBlue
class node_pipeline,node_probe,node_profile,node_normalize,node_segment,node_thumbnail,node_hash toneAmber
class node_library,node_db,node_paths toneMint
class node_subprocess,node_util toneRose
class node_operator,node_ffmpeg,node_consumer toneIndigo
```

## Components

### CLI workflows

- [Command router](https://github.com/joireve/clipbank/blob/main/src/main.cpp): `src/main.cpp`
- [Manifest export](https://github.com/joireve/clipbank/blob/main/src/manifest.cpp): `src/manifest.cpp`
- [Library verification](https://github.com/joireve/clipbank/blob/main/src/verify.cpp): `src/verify.cpp`
- [Run listing](https://github.com/joireve/clipbank/blob/main/src/db.cpp): `src/db.cpp`

### Media processing

- [Add and retry](https://github.com/joireve/clipbank/blob/main/src/pipeline.cpp): `src/pipeline.cpp`
- [Media probe](https://github.com/joireve/clipbank/blob/main/src/probe.cpp): `src/probe.cpp`
- [Detect profile](https://github.com/joireve/clipbank/blob/main/src/profile.cpp): `src/profile.cpp`
- [Normalize video](https://github.com/joireve/clipbank/blob/main/src/pipeline.cpp): `src/pipeline.cpp`
- [Segment clips](https://github.com/joireve/clipbank/blob/main/src/pipeline.cpp): `src/pipeline.cpp`
- [Thumbnail](https://github.com/joireve/clipbank/blob/main/src/pipeline.cpp): `src/pipeline.cpp`
- [Content hashes](https://github.com/joireve/clipbank/blob/main/src/sha256.cpp): `src/sha256.cpp`

### Library catalog

- [Library setup](https://github.com/joireve/clipbank/blob/main/src/library.cpp): `src/library.cpp`
- [SQLite index](https://github.com/joireve/clipbank/blob/main/src/db.cpp): `src/db.cpp`
- [Library paths](https://github.com/joireve/clipbank/blob/main/src/library.cpp): `src/library.cpp`

### Runtime support

- [Process runner](https://github.com/joireve/clipbank/blob/main/src/subprocess.cpp): `src/subprocess.cpp`
- [File utilities](https://github.com/joireve/clipbank/blob/main/src/util.cpp): `src/util.cpp`

### Other components

- **Operator**
- **ffmpeg / ffprobe**
- **Detection project**

## Connections

- Operator → Command router: runs commands (evidence: `README.md`)
- Command router → Library setup: initializes library (evidence: `src/main.cpp`)
- Command router → Add and retry: adds or retries (evidence: `src/main.cpp`)
- Command router → Manifest export: exports manifest (evidence: `src/main.cpp`)
- Command router → Library verification: verifies runs (evidence: `src/main.cpp`)
- Command router → Run listing: lists runs (evidence: `README.md`)
- Library setup → SQLite index: creates schema (evidence: `src/library.cpp`)
- Add and retry → Media probe: probes input (evidence: `README.md`)
- Add and retry → Detect profile: uses profile (evidence: `src/pipeline.cpp`)
- Add and retry → Normalize video: runs stage (evidence: `src/pipeline.cpp`)
- Add and retry → Segment clips: runs stage (evidence: `src/pipeline.cpp`)
- Add and retry → Thumbnail: runs stage (evidence: `src/pipeline.cpp`)
- Add and retry → Content hashes: hashes outputs (evidence: `README.md`)
- Add and retry → SQLite index: records run state (evidence: `src/pipeline.cpp`)
- Add and retry → Library paths: uses library paths
- Manifest export → SQLite index: reads run records (evidence: `src/manifest.cpp`)
- Manifest export → Library paths: uses library paths (evidence: `src/manifest.cpp`)
- Library verification → SQLite index: checks records
- Library verification → Media probe: checks media (evidence: `src/verify.cpp`)
- Normalize video → Process runner: runs process (evidence: `src/pipeline.cpp`)
- Segment clips → Process runner: runs process (evidence: `src/pipeline.cpp`)
- Thumbnail → Process runner: runs process (evidence: `src/pipeline.cpp`)
- Media probe → Process runner: runs probe tools (evidence: `src/probe.cpp`)
- Process runner → ffmpeg / ffprobe: executes tools (evidence: `README.md`)
- Detection project → Manifest export: consumes exported data (evidence: `README.md`)
