# stormforgeventures/pifang architecture

> Architecture diagram of the GitHub repository stormforgeventures/pifang, 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/stormforgeventures/pifang
- Repository: https://github.com/stormforgeventures/pifang

## Overview

Pifang is a local-first media-processing CLI, also usable as a Python library. The main workflow is a user command entering the CLI, which dispatches a domain operation and returns files plus text or structured JSON results. Image, document, video, and transcription commands are distinct product stages; recipes, pipes, and batch runs provide alternate ways to orchestrate operations. Edges use README documentation and the supplied source index or excerpts; unsampled document and metadata implementations are represented at their existing directories, with relationships omitted where evidence is limited.

Main entry points: [`src/pifang/cli/main.py`](https://github.com/stormforgeventures/pifang/blob/main/src/pifang/cli/main.py) (Command interface), [`src/pifang/domains/image/ops.py`](https://github.com/stormforgeventures/pifang/blob/main/src/pifang/domains/image/ops.py) (Image operations), [`src/pifang/core/batch.py`](https://github.com/stormforgeventures/pifang/blob/main/src/pifang/core/batch.py) (Batch processing), [`src/pifang/domains/video/ops.py`](https://github.com/stormforgeventures/pifang/blob/main/src/pifang/domains/video/ops.py) (Video operations)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_interface["CLI and results"]
  node_cli["Command interface<br/>[main.py]"]
  node_results["Results and errors<br/>[result.py]"]
end

subgraph group_orchestration["Workflow tools"]
  node_recipes["Recipe runner<br/>[recipe.py]"]
  node_pipes["Image pipe runner<br/>[pipe.py]"]
  node_video_pipes["Video pipe runner<br/>[video_pipe.py]"]
  node_batch["Batch processing<br/>[batch.py]"]
  node_manifest["Batch manifest<br/>[manifest.py]"]
end

subgraph group_image["Image processing"]
  node_image_ops["Image operations<br/>[ops.py]"]
  node_image_analysis["Image analysis<br/>[analyze.py]"]
  node_image_background["Background tools<br/>[bg.py]"]
  node_image_recolor["Recoloring<br/>[recolor.py]"]
  node_image_packs["Image packs<br/>[packs.py]"]
  node_image_platforms["Platform presets<br/>[platforms.py]"]
end

subgraph group_documents["Documents and text"]
  node_doc_tools["Document conversion"]
  node_text_tools["Text utilities"]
  node_metadata["Metadata indexing<br/>[index.py]"]
end

subgraph group_media["Video and transcription"]
  node_video_ops["Video operations<br/>[ops.py]"]
  node_video_info["Video information<br/>[info.py]"]
  node_ffmpeg["ffmpeg tools<br/>[ffmpeg.py]"]
  node_transcribe_ops["Transcription workflow<br/>[ops.py]"]
  node_whisper["Whisper engine<br/>[engine.py]"]
  node_transcript_formats["Transcript formats<br/>[formats.py]"]
end

node_user(("Local user"))
node_local_files["Local files"]

node_user -->|"runs commands"| node_cli
node_cli -->|"formats results"| node_results
node_cli -->|"dispatches image"| node_image_ops
node_cli -->|"dispatches analysis"| node_image_analysis
node_cli -->|"dispatches background"| node_image_background
node_cli -->|"dispatches documents"| node_doc_tools
node_cli -->|"dispatches text"| node_text_tools
node_cli -->|"dispatches metadata"| node_metadata
node_cli -->|"dispatches video"| node_video_ops
node_cli -->|"dispatches transcription"| node_transcribe_ops
node_cli -->|"runs recipes"| node_recipes
node_cli -->|"runs image pipes"| node_pipes
node_cli -->|"runs video pipes"| node_video_pipes
node_cli -->|"runs batches"| node_batch
node_cli -->|"reads and writes"| node_local_files
node_recipes -->|"calls image operations"| node_image_ops
node_recipes -->|"calls video operations"| node_video_ops
node_pipes -->|"runs stages"| node_image_ops
node_video_pipes -->|"runs stages"| node_video_ops
node_batch -->|"runs image jobs"| node_image_ops
node_batch -->|"runs video jobs"| node_video_ops
node_batch -->|"runs recipes"| node_recipes
node_batch -->|"runs image pipes"| node_pipes
node_batch -->|"runs video pipes"| node_video_pipes
node_batch -->|"writes entries"| node_manifest
node_image_packs -->|"creates variants"| node_image_ops
node_image_packs -->|"uses presets"| node_image_platforms
node_image_analysis -->|"uses operations"| node_image_ops
node_image_background -->|"uses image helpers"| node_image_ops
node_image_recolor -->|"uses background tools"| node_image_background
node_image_recolor -->|"uses image operations"| node_image_ops
node_video_ops -->|"runs media commands"| node_ffmpeg
node_video_ops -->|"probes media"| node_video_info
node_video_info -->|"calls ffprobe"| node_ffmpeg
node_transcribe_ops -->|"transcribes audio"| node_whisper
node_transcribe_ops -->|"writes subtitles"| node_transcript_formats
node_transcribe_ops -->|"extracts video audio"| node_ffmpeg
node_transcribe_ops -->|"writes transcripts"| node_local_files
node_video_ops -->|"writes media"| node_local_files
node_image_ops -->|"writes images"| node_local_files
node_doc_tools -->|"writes documents"| node_local_files

click node_cli "https://github.com/stormforgeventures/pifang/blob/main/src/pifang/cli/main.py"
click node_results "https://github.com/stormforgeventures/pifang/blob/main/src/pifang/core/result.py"
click node_image_ops "https://github.com/stormforgeventures/pifang/blob/main/src/pifang/domains/image/ops.py"
click node_image_analysis "https://github.com/stormforgeventures/pifang/blob/main/src/pifang/domains/image/analyze.py"
click node_image_background "https://github.com/stormforgeventures/pifang/blob/main/src/pifang/domains/image/bg.py"
click node_image_recolor "https://github.com/stormforgeventures/pifang/blob/main/src/pifang/domains/image/recolor.py"
click node_image_packs "https://github.com/stormforgeventures/pifang/blob/main/src/pifang/domains/image/packs.py"
click node_image_platforms "https://github.com/stormforgeventures/pifang/blob/main/src/pifang/domains/image/platforms.py"
click node_recipes "https://github.com/stormforgeventures/pifang/blob/main/src/pifang/core/recipe.py"
click node_pipes "https://github.com/stormforgeventures/pifang/blob/main/src/pifang/core/pipe.py"
click node_video_pipes "https://github.com/stormforgeventures/pifang/blob/main/src/pifang/core/video_pipe.py"
click node_batch "https://github.com/stormforgeventures/pifang/blob/main/src/pifang/core/batch.py"
click node_manifest "https://github.com/stormforgeventures/pifang/blob/main/src/pifang/core/manifest.py"
click node_doc_tools "https://github.com/stormforgeventures/pifang/tree/main/src/pifang/domains/doc"
click node_text_tools "https://github.com/stormforgeventures/pifang/tree/main/src/pifang/domains/text"
click node_metadata "https://github.com/stormforgeventures/pifang/blob/main/src/pifang/domains/meta/index.py"
click node_video_ops "https://github.com/stormforgeventures/pifang/blob/main/src/pifang/domains/video/ops.py"
click node_video_info "https://github.com/stormforgeventures/pifang/blob/main/src/pifang/domains/video/info.py"
click node_ffmpeg "https://github.com/stormforgeventures/pifang/blob/main/src/pifang/domains/video/ffmpeg.py"
click node_transcribe_ops "https://github.com/stormforgeventures/pifang/blob/main/src/pifang/domains/transcribe/ops.py"
click node_whisper "https://github.com/stormforgeventures/pifang/blob/main/src/pifang/domains/transcribe/engine.py"
click node_transcript_formats "https://github.com/stormforgeventures/pifang/blob/main/src/pifang/domains/transcribe/formats.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_results,node_user toneBlue
class node_recipes,node_pipes,node_video_pipes,node_batch,node_manifest toneAmber
class node_image_ops,node_image_analysis,node_image_background,node_image_recolor,node_image_packs,node_image_platforms toneMint
class node_doc_tools,node_text_tools,node_metadata toneRose
class node_video_ops,node_video_info,node_ffmpeg,node_transcribe_ops,node_whisper,node_transcript_formats,node_local_files toneIndigo
```

## Components

### CLI and results

- [Command interface](https://github.com/stormforgeventures/pifang/blob/main/src/pifang/cli/main.py): `src/pifang/cli/main.py`
- [Results and errors](https://github.com/stormforgeventures/pifang/blob/main/src/pifang/core/result.py): `src/pifang/core/result.py`

### Workflow tools

- [Recipe runner](https://github.com/stormforgeventures/pifang/blob/main/src/pifang/core/recipe.py): `src/pifang/core/recipe.py`
- [Image pipe runner](https://github.com/stormforgeventures/pifang/blob/main/src/pifang/core/pipe.py): `src/pifang/core/pipe.py`
- [Video pipe runner](https://github.com/stormforgeventures/pifang/blob/main/src/pifang/core/video_pipe.py): `src/pifang/core/video_pipe.py`
- [Batch processing](https://github.com/stormforgeventures/pifang/blob/main/src/pifang/core/batch.py): `src/pifang/core/batch.py`
- [Batch manifest](https://github.com/stormforgeventures/pifang/blob/main/src/pifang/core/manifest.py): `src/pifang/core/manifest.py`

### Image processing

- [Image operations](https://github.com/stormforgeventures/pifang/blob/main/src/pifang/domains/image/ops.py): `src/pifang/domains/image/ops.py`
- [Image analysis](https://github.com/stormforgeventures/pifang/blob/main/src/pifang/domains/image/analyze.py): `src/pifang/domains/image/analyze.py`
- [Background tools](https://github.com/stormforgeventures/pifang/blob/main/src/pifang/domains/image/bg.py): `src/pifang/domains/image/bg.py`
- [Recoloring](https://github.com/stormforgeventures/pifang/blob/main/src/pifang/domains/image/recolor.py): `src/pifang/domains/image/recolor.py`
- [Image packs](https://github.com/stormforgeventures/pifang/blob/main/src/pifang/domains/image/packs.py): `src/pifang/domains/image/packs.py`
- [Platform presets](https://github.com/stormforgeventures/pifang/blob/main/src/pifang/domains/image/platforms.py): `src/pifang/domains/image/platforms.py`

### Documents and text

- [Document conversion](https://github.com/stormforgeventures/pifang/tree/main/src/pifang/domains/doc): `src/pifang/domains/doc`
- [Text utilities](https://github.com/stormforgeventures/pifang/tree/main/src/pifang/domains/text): `src/pifang/domains/text`
- [Metadata indexing](https://github.com/stormforgeventures/pifang/blob/main/src/pifang/domains/meta/index.py): `src/pifang/domains/meta/index.py`

### Video and transcription

- [Video operations](https://github.com/stormforgeventures/pifang/blob/main/src/pifang/domains/video/ops.py): `src/pifang/domains/video/ops.py`
- [Video information](https://github.com/stormforgeventures/pifang/blob/main/src/pifang/domains/video/info.py): `src/pifang/domains/video/info.py`
- [ffmpeg tools](https://github.com/stormforgeventures/pifang/blob/main/src/pifang/domains/video/ffmpeg.py): `src/pifang/domains/video/ffmpeg.py`
- [Transcription workflow](https://github.com/stormforgeventures/pifang/blob/main/src/pifang/domains/transcribe/ops.py): `src/pifang/domains/transcribe/ops.py`
- [Whisper engine](https://github.com/stormforgeventures/pifang/blob/main/src/pifang/domains/transcribe/engine.py): `src/pifang/domains/transcribe/engine.py`
- [Transcript formats](https://github.com/stormforgeventures/pifang/blob/main/src/pifang/domains/transcribe/formats.py): `src/pifang/domains/transcribe/formats.py`

### Other components

- **Local user**
- **Local files**

## Connections

- Local user → Command interface: runs commands (evidence: `README.md`)
- Command interface → Results and errors: formats results (evidence: `src/pifang/cli/main.py`)
- Command interface → Image operations: dispatches image (evidence: `src/pifang/cli/main.py`)
- Command interface → Image analysis: dispatches analysis (evidence: `src/pifang/cli/main.py`)
- Command interface → Background tools: dispatches background (evidence: `src/pifang/cli/main.py`)
- Command interface → Document conversion: dispatches documents (evidence: `src/pifang/cli/main.py`)
- Command interface → Text utilities: dispatches text (evidence: `src/pifang/cli/main.py`)
- Command interface → Metadata indexing: dispatches metadata (evidence: `src/pifang/cli/main.py`)
- Command interface → Video operations: dispatches video (evidence: `README.md`)
- Command interface → Transcription workflow: dispatches transcription (evidence: `README.md`)
- Command interface → Recipe runner: runs recipes (evidence: `src/pifang/cli/main.py`)
- Command interface → Image pipe runner: runs image pipes (evidence: `README.md`)
- Command interface → Video pipe runner: runs video pipes (evidence: `src/pifang/cli/main.py`)
- Command interface → Batch processing: runs batches (evidence: `src/pifang/cli/main.py`)
- Command interface → Local files: reads and writes (evidence: `README.md`)
- Recipe runner → Image operations: calls image operations (evidence: `src/pifang/core/recipe.py`)
- Recipe runner → Video operations: calls video operations (evidence: `src/pifang/core/recipe.py`)
- Image pipe runner → Image operations: runs stages (evidence: `src/pifang/core/pipe.py`)
- Video pipe runner → Video operations: runs stages (evidence: `src/pifang/core/video_pipe.py`)
- Batch processing → Image operations: runs image jobs (evidence: `src/pifang/core/batch.py`)
- Batch processing → Video operations: runs video jobs (evidence: `src/pifang/core/batch.py`)
- Batch processing → Recipe runner: runs recipes (evidence: `src/pifang/core/batch.py`)
- Batch processing → Image pipe runner: runs image pipes (evidence: `src/pifang/core/batch.py`)
- Batch processing → Video pipe runner: runs video pipes (evidence: `src/pifang/core/batch.py`)
- Batch processing → Batch manifest: writes entries (evidence: `src/pifang/core/batch.py`)
- Image packs → Image operations: creates variants (evidence: `src/pifang/domains/image/packs.py`)
- Image packs → Platform presets: uses presets (evidence: `src/pifang/domains/image/packs.py`)
- Image analysis → Image operations: uses operations (evidence: `src/pifang/domains/image/analyze.py`)
- Background tools → Image operations: uses image helpers (evidence: `src/pifang/domains/image/bg.py`)
- Recoloring → Background tools: uses background tools (evidence: `src/pifang/domains/image/recolor.py`)
- Recoloring → Image operations: uses image operations (evidence: `src/pifang/domains/image/recolor.py`)
- Video operations → ffmpeg tools: runs media commands (evidence: `src/pifang/domains/video/ops.py`)
- Video operations → Video information: probes media (evidence: `src/pifang/domains/video/ops.py`)
- Video information → ffmpeg tools: calls ffprobe (evidence: `src/pifang/domains/video/info.py`)
- Transcription workflow → Whisper engine: transcribes audio (evidence: `src/pifang/domains/transcribe/ops.py`)
- Transcription workflow → Transcript formats: writes subtitles (evidence: `src/pifang/domains/transcribe/ops.py`)
- Transcription workflow → ffmpeg tools: extracts video audio (evidence: `src/pifang/domains/transcribe/ops.py`)
- Transcription workflow → Local files: writes transcripts (evidence: `README.md`)
- Video operations → Local files: writes media (evidence: `README.md`)
- Image operations → Local files: writes images (evidence: `README.md`)
- Document conversion → Local files: writes documents (evidence: `README.md`)
