# encrize/bad-apple-in-100kb architecture

> Architecture diagram of the GitHub repository encrize/bad-apple-in-100kb, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-14). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/encrize/bad-apple-in-100kb
- Repository: https://github.com/encrize/bad-apple-in-100kb

## Overview

bad-apple-tiny is a self-contained terminal video player: launching it decodes an embedded raw LZMA1 stream, converts each packed monochrome frame to ASCII, presents frames to the terminal, and paces playback. Separate authoring tools can create the embedded header from a video or lower an existing header’s frame rate. The runtime connections are visible in main.c and the SOURCE INDEX; authoring-tool outputs and the standalone-player behavior are documented in the README.

Main entry points: [`src/main.c`](https://github.com/encrize/bad-apple-in-100kb/blob/main/src/main.c) (Player loop), [`src/video_data.h`](https://github.com/encrize/bad-apple-in-100kb/blob/main/src/video_data.h) (Compressed frames), [`src/lzma_dec.h`](https://github.com/encrize/bad-apple-in-100kb/blob/main/src/lzma_dec.h) (Decoder API), [`tools/convert.py`](https://github.com/encrize/bad-apple-in-100kb/blob/main/tools/convert.py) (Video converter)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["Playback runtime"]
  node_player["Player loop<br/>[main.c]"]
  node_decoder_api["Decoder API<br/>[lzma_dec.h]"]
  node_decoder["Raw LZMA decoder<br/>[lzma_dec.c]"]
  node_console["Platform console<br/>[main.c]"]
  node_clock["Playback timing<br/>[main.c]"]
end

subgraph group_content["Embedded video"]
  node_payload["Compressed frames<br/>[video_data.h]"]
end

subgraph group_authoring["Content authoring"]
  node_convert["Video converter<br/>[convert.py]"]
  node_reencode["FPS re-encoder<br/>[reencode.py]"]
end

node_viewer(("Viewer"))
node_terminal(("Terminal"))
node_video_source["Source video"]

node_viewer -->|"runs"| node_player
node_player -->|"reads stream"| node_payload
node_player -->|"calls decode"| node_decoder_api
node_decoder_api -->|"implemented by"| node_decoder
node_player -->|"presents frames"| node_console
node_console -->|"writes output"| node_terminal
node_player -->|"paces playback"| node_clock
node_video_source -->|"converts video"| node_convert
node_convert -->|"generates header"| node_payload
node_payload -->|"resamples frames"| node_reencode
node_reencode -->|"rewrites header"| node_payload

click node_player "https://github.com/encrize/bad-apple-in-100kb/blob/main/src/main.c"
click node_decoder_api "https://github.com/encrize/bad-apple-in-100kb/blob/main/src/lzma_dec.h"
click node_decoder "https://github.com/encrize/bad-apple-in-100kb/blob/main/src/lzma_dec.c"
click node_console "https://github.com/encrize/bad-apple-in-100kb/blob/main/src/main.c"
click node_clock "https://github.com/encrize/bad-apple-in-100kb/blob/main/src/main.c"
click node_payload "https://github.com/encrize/bad-apple-in-100kb/blob/main/src/video_data.h"
click node_convert "https://github.com/encrize/bad-apple-in-100kb/blob/main/tools/convert.py"
click node_reencode "https://github.com/encrize/bad-apple-in-100kb/blob/main/tools/reencode.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_player,node_decoder_api,node_decoder,node_console,node_clock,node_viewer toneBlue
class node_payload toneAmber
class node_convert,node_reencode toneMint
class node_terminal,node_video_source toneIndigo
```

## Components

### Playback runtime

- [Player loop](https://github.com/encrize/bad-apple-in-100kb/blob/main/src/main.c): `src/main.c`
- [Decoder API](https://github.com/encrize/bad-apple-in-100kb/blob/main/src/lzma_dec.h): `src/lzma_dec.h`
- [Raw LZMA decoder](https://github.com/encrize/bad-apple-in-100kb/blob/main/src/lzma_dec.c): `src/lzma_dec.c`
- [Platform console](https://github.com/encrize/bad-apple-in-100kb/blob/main/src/main.c): `src/main.c`
- [Playback timing](https://github.com/encrize/bad-apple-in-100kb/blob/main/src/main.c): `src/main.c`

### Embedded video

- [Compressed frames](https://github.com/encrize/bad-apple-in-100kb/blob/main/src/video_data.h): `src/video_data.h`

### Content authoring

- [Video converter](https://github.com/encrize/bad-apple-in-100kb/blob/main/tools/convert.py): `tools/convert.py`
- [FPS re-encoder](https://github.com/encrize/bad-apple-in-100kb/blob/main/tools/reencode.py): `tools/reencode.py`

### Other components

- **Viewer**
- **Terminal**
- **Source video**

## Connections

- Viewer → Player loop: runs (evidence: `README.md`)
- Player loop → Compressed frames: reads stream (evidence: `src/main.c`)
- Player loop → Decoder API: calls decode (evidence: `src/main.c`)
- Decoder API → Raw LZMA decoder: implemented by (evidence: `src/lzma_dec.c`)
- Player loop → Platform console: presents frames (evidence: `src/main.c`)
- Platform console → Terminal: writes output (evidence: `src/main.c`)
- Player loop → Playback timing: paces playback (evidence: `src/main.c`)
- Source video → Video converter: converts video (evidence: `README.md`)
- Video converter → Compressed frames: generates header (evidence: `README.md`)
- Compressed frames → FPS re-encoder: resamples frames (evidence: `README.md`)
- FPS re-encoder → Compressed frames: rewrites header (evidence: `README.md`)
