# cod-e-codes/ascii-colorizer architecture

> Architecture diagram of the GitHub repository cod-e-codes/ascii-colorizer, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-07-21). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/cod-e-codes/ascii-colorizer
- Repository: https://github.com/cod-e-codes/ascii-colorizer

## Overview

#### Purpose and Entry Points
`ascii-colorizer` is a Rust CLI that renders image files or video frames as ANSI-colored ASCII art. The executable entry point is `src/main.rs`; reusable conversion and playback logic is exposed from `src/lib.rs`. Cargo package/build metadata is in `Cargo.toml`.

#### CLI Orchestration
The CLI accepts an input path, dimensions, character-detail mode, color mode, output destination, media type override, and video FPS. It selects image or video processing based on explicit `--type` or automatic detection, then routes output either to the terminal or a saved text file. Primary paths: `src/main.rs`, `src/lib.rs`.

#### Image Conversion Pipeline
For images, the application loads a supported raster format, resizes it to the requested character dimensions (respecting optional height limits), converts pixels to luminance/ASCII glyphs, and emits either TrueColor ANSI sequences or uncolored text. This is the direct single-render path implemented in `src/lib.rs`.

#### Video Streaming and Playback
Video input is decoded externally through `ffmpeg`, with metadata or probing supplied by `ffprobe`. Frames are processed incrementally rather than loaded as a full video; pixel and ASCII buffers are reused to reduce allocation during live playback. Each frame follows the same resize/color/ASCII conversion path as images. Core integration boundary: `src/lib.rs`.

#### Terminal and File Output Boundary
Live video rendering writes frames to an alternate terminal screen, controls timing at the chosen FPS, and restores terminal state on completion or Ctrl+C. Saved video output is serialized as text frames separated by form-feed characters. Image rendering can similarly target stdout or a file. Terminal ANSI support is a runtime requirement; TrueColor is preferred. Paths: `src/main.rs`, `src/lib.rs`.

#### Runtime Dependencies and Distribution
The binary runs on Rust-supported Windows, Linux, and macOS targets. Video processing requires `ffmpeg` and `ffprobe` available on `PATH`; image decoding is handled by Rust dependencies declared in `Cargo.toml`. CI validates builds/tests on pushes and pull requests through `.github/workflows/ci.yml`; tagged releases build platform archives and publish GitHub Release assets via `.github/workflows/release.yml`.

Main entry points: [`src/lib.rs`](https://github.com/cod-e-codes/ascii-colorizer/blob/main/src/lib.rs) (Frame playback processing), [`Cargo.toml`](https://github.com/cod-e-codes/ascii-colorizer/blob/main/Cargo.toml) (Cargo package), [`src/main.rs`](https://github.com/cod-e-codes/ascii-colorizer/blob/main/src/main.rs) (CLI entry point), [`.github/workflows/ci.yml`](https://github.com/cod-e-codes/ascii-colorizer/blob/main/.github/workflows/ci.yml) (Build and test CI)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_app["Rust application"]
  node_cargo["Cargo package<br/>build metadata<br/>[Cargo.toml]"]
  node_cli["CLI entry point<br/>Rust binary<br/>[main.rs]"]
  node_library["Conversion library<br/>Rust library<br/>[lib.rs]"]
  node_media_router{{"Media type routing<br/>processing selection<br/>[main.rs]"}}
end

subgraph group_media["Media processing"]
  node_image_load["Raster image load<br/>image decoder<br/>[lib.rs]"]
  node_render_pipeline["Resize and ASCII render<br/>conversion pipeline<br/>[lib.rs]"]
  node_video_probe{{"Video metadata probe<br/>external process<br/>[lib.rs]"}}
  node_video_decode{{"Incremental frame decode<br/>external process<br/>[lib.rs]"}}
  node_frame_reuse["Frame playback processing<br/>stream processor<br/>[lib.rs]"]
end

subgraph group_output["Output targets"]
  node_terminal["Terminal playback<br/>ANSI terminal<br/>[lib.rs]"]
  node_text_file["Text file output<br/>file writer<br/>[lib.rs]"]
end

subgraph group_delivery["Build and release"]
  node_ci["Build and test CI<br/>GitHub Actions<br/>[ci.yml]"]
  node_release["Release publishing<br/>GitHub Actions<br/>[release.yml]"]
end

node_cargo -->|"builds"| node_cli
node_cargo -->|"links"| node_library
node_cli -->|"input and options"| node_media_router
node_cli -->|"invokes"| node_library
node_media_router -->|"image input"| node_image_load
node_media_router -->|"video input"| node_video_probe
node_image_load -->|"pixels"| node_render_pipeline
node_video_probe -->|"metadata"| node_video_decode
node_video_decode -->|"decoded frames"| node_frame_reuse
node_frame_reuse -->|"frame pixels"| node_render_pipeline
node_render_pipeline -->|"ANSI or text"| node_terminal
node_render_pipeline -->|"single image text"| node_text_file
node_frame_reuse -->|"timed frame output"| node_terminal
node_frame_reuse -->|"form-feed frames"| node_text_file
node_ci -->|"builds and tests"| node_cargo
node_release -->|"builds archives"| node_cargo

click node_cargo "https://github.com/cod-e-codes/ascii-colorizer/blob/main/Cargo.toml"
click node_cli "https://github.com/cod-e-codes/ascii-colorizer/blob/main/src/main.rs"
click node_library "https://github.com/cod-e-codes/ascii-colorizer/blob/main/src/lib.rs"
click node_media_router "https://github.com/cod-e-codes/ascii-colorizer/blob/main/src/main.rs"
click node_image_load "https://github.com/cod-e-codes/ascii-colorizer/blob/main/src/lib.rs"
click node_render_pipeline "https://github.com/cod-e-codes/ascii-colorizer/blob/main/src/lib.rs"
click node_video_probe "https://github.com/cod-e-codes/ascii-colorizer/blob/main/src/lib.rs"
click node_video_decode "https://github.com/cod-e-codes/ascii-colorizer/blob/main/src/lib.rs"
click node_frame_reuse "https://github.com/cod-e-codes/ascii-colorizer/blob/main/src/lib.rs"
click node_terminal "https://github.com/cod-e-codes/ascii-colorizer/blob/main/src/lib.rs"
click node_text_file "https://github.com/cod-e-codes/ascii-colorizer/blob/main/src/lib.rs"
click node_ci "https://github.com/cod-e-codes/ascii-colorizer/blob/main/.github/workflows/ci.yml"
click node_release "https://github.com/cod-e-codes/ascii-colorizer/blob/main/.github/workflows/release.yml"

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_cargo,node_cli,node_library,node_media_router toneBlue
class node_image_load,node_render_pipeline,node_video_probe,node_video_decode,node_frame_reuse toneAmber
class node_terminal,node_text_file toneMint
class node_ci,node_release toneRose
```

## Components

### Rust application

- [Cargo package](https://github.com/cod-e-codes/ascii-colorizer/blob/main/Cargo.toml): build metadata · Declares Rust image dependencies and the CLI package. · `Cargo.toml`
- [CLI entry point](https://github.com/cod-e-codes/ascii-colorizer/blob/main/src/main.rs): Rust binary · Parses options and selects media processing and destination. · `src/main.rs`
- [Conversion library](https://github.com/cod-e-codes/ascii-colorizer/blob/main/src/lib.rs): Rust library · Exposes reusable rendering and playback logic. · `src/lib.rs`
- [Media type routing](https://github.com/cod-e-codes/ascii-colorizer/blob/main/src/main.rs): processing selection · Uses an override or automatic detection to choose image or video flow. · `src/main.rs`

### Media processing

- [Raster image load](https://github.com/cod-e-codes/ascii-colorizer/blob/main/src/lib.rs): image decoder · Loads supported image formats through Rust dependencies. · `src/lib.rs`
- [Resize and ASCII render](https://github.com/cod-e-codes/ascii-colorizer/blob/main/src/lib.rs): conversion pipeline · Resizes pixels, maps luminance to glyphs, and optionally adds TrueColor ANSI. · `src/lib.rs`
- [Video metadata probe](https://github.com/cod-e-codes/ascii-colorizer/blob/main/src/lib.rs): external process · Uses ffprobe from PATH to inspect video input. · `src/lib.rs`
- [Incremental frame decode](https://github.com/cod-e-codes/ascii-colorizer/blob/main/src/lib.rs): external process · Streams frames from ffmpeg rather than loading the full video. · `src/lib.rs`
- [Frame playback processing](https://github.com/cod-e-codes/ascii-colorizer/blob/main/src/lib.rs): stream processor · Reuses pixel and ASCII buffers while rendering each decoded frame. · `src/lib.rs`

### Output targets

- [Terminal playback](https://github.com/cod-e-codes/ascii-colorizer/blob/main/src/lib.rs): ANSI terminal · Uses an alternate screen, FPS timing, and cleanup on completion or Ctrl+C. · `src/lib.rs`
- [Text file output](https://github.com/cod-e-codes/ascii-colorizer/blob/main/src/lib.rs): file writer · Writes images as text or video frames separated by form feeds. · `src/lib.rs`

### Build and release

- [Build and test CI](https://github.com/cod-e-codes/ascii-colorizer/blob/main/.github/workflows/ci.yml): GitHub Actions · Validates pushes and pull requests on supported targets. · `.github/workflows/ci.yml`
- [Release publishing](https://github.com/cod-e-codes/ascii-colorizer/blob/main/.github/workflows/release.yml): GitHub Actions · Builds platform archives and publishes tagged release assets. · `.github/workflows/release.yml`

## Connections

- Cargo package → CLI entry point: builds
- Cargo package → Conversion library: links
- CLI entry point → Media type routing: input and options
- CLI entry point → Conversion library: invokes
- Media type routing → Raster image load: image input
- Media type routing → Video metadata probe: video input
- Raster image load → Resize and ASCII render: pixels
- Video metadata probe → Incremental frame decode: metadata
- Incremental frame decode → Frame playback processing: decoded frames
- Frame playback processing → Resize and ASCII render: frame pixels
- Resize and ASCII render → Terminal playback: ANSI or text
- Resize and ASCII render → Text file output: single image text
- Frame playback processing → Terminal playback: timed frame output
- Frame playback processing → Text file output: form-feed frames
- Build and test CI → Cargo package: builds and tests
- Release publishing → Cargo package: builds archives
