# encrize/bytefall architecture

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

## Overview

Bytefall is a C/SDL2 binary-file visualizer and raw-byte audio player. Its main workflow is to load a file from the command line or a drop event, interpret bytes in a selected pixel mode, then render a scrolling waterfall and navigation aids while audio playback and UI controls operate on the same application state. The graph reflects sampled call sites and README capabilities; file-loading internals are unsampled, so their details are omitted.

Main entry points: [`main.c`](https://github.com/encrize/bytefall/blob/main/main.c) (Event loop), [`render.c`](https://github.com/encrize/bytefall/blob/main/render.c) (Frame rendering), [`app.h`](https://github.com/encrize/bytefall/blob/main/app.h) (App state), [`audio.c`](https://github.com/encrize/bytefall/blob/main/audio.c) (Byte audio)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_app["Application"]
  node_main["Event loop<br/>[main.c]"]
  node_state["App state<br/>[app.h]"]
  node_file_load["File loading<br/>[fileio.c]"]
end

subgraph group_interaction["Input and playback"]
  node_input["Input handling<br/>[input.c]"]
  node_audio["Byte audio<br/>[audio.c]"]
end

subgraph group_visualization["Byte visualization"]
  node_pixel_decode["Pixel decoding<br/>[viewport.c]"]
  node_waterfall["Waterfall rendering<br/>[viewport.c]"]
  node_minimap["Minimap<br/>[viewport.c]"]
  node_navigation["Scroll and tooltip<br/>[viewport.c]"]
end

subgraph group_presentation["Interface rendering"]
  node_render_flow["Frame rendering<br/>[render.c]"]
  node_ui["Controls and help<br/>[ui.c]"]
  node_draw["Drawing primitives<br/>[draw.c]"]
end

node_user(("User"))
node_sdl["SDL2 runtime"]

node_user -->|"starts app"| node_main
node_main -->|"polls events"| node_sdl
node_main -->|"loads files"| node_file_load
node_main -->|"dispatches input"| node_input
node_main -->|"renders frames"| node_render_flow
node_main -->|"initializes audio"| node_audio
node_main -->|"initializes state"| node_state
node_input -->|"seeks and restarts"| node_audio
node_input -->|"updates controls"| node_state
node_audio -->|"reads playback state"| node_state
node_audio -->|"registers callback"| node_sdl
node_render_flow -->|"reads app state"| node_state
node_render_flow -->|"renders waterfall"| node_waterfall
node_render_flow -->|"renders minimap"| node_minimap
node_render_flow -->|"updates navigation"| node_navigation
node_render_flow -->|"draws controls"| node_ui
node_render_flow -->|"draws frame elements"| node_draw
node_waterfall -->|"decodes bytes"| node_pixel_decode
node_minimap -->|"decodes bytes"| node_pixel_decode
node_navigation -->|"reads file position"| node_state
node_ui -->|"draws widgets"| node_draw

click node_main "https://github.com/encrize/bytefall/blob/main/main.c"
click node_state "https://github.com/encrize/bytefall/blob/main/app.h"
click node_file_load "https://github.com/encrize/bytefall/blob/main/fileio.c"
click node_input "https://github.com/encrize/bytefall/blob/main/input.c"
click node_audio "https://github.com/encrize/bytefall/blob/main/audio.c"
click node_pixel_decode "https://github.com/encrize/bytefall/blob/main/viewport.c"
click node_waterfall "https://github.com/encrize/bytefall/blob/main/viewport.c"
click node_minimap "https://github.com/encrize/bytefall/blob/main/viewport.c"
click node_navigation "https://github.com/encrize/bytefall/blob/main/viewport.c"
click node_render_flow "https://github.com/encrize/bytefall/blob/main/render.c"
click node_ui "https://github.com/encrize/bytefall/blob/main/ui.c"
click node_draw "https://github.com/encrize/bytefall/blob/main/draw.c"

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_main,node_state,node_file_load,node_user toneBlue
class node_input,node_audio toneAmber
class node_pixel_decode,node_waterfall,node_minimap,node_navigation toneMint
class node_render_flow,node_ui,node_draw toneRose
class node_sdl toneIndigo
```

## Components

### Application

- [Event loop](https://github.com/encrize/bytefall/blob/main/main.c): `main.c`
- [App state](https://github.com/encrize/bytefall/blob/main/app.h): `app.h`
- [File loading](https://github.com/encrize/bytefall/blob/main/fileio.c): `fileio.c`

### Input and playback

- [Input handling](https://github.com/encrize/bytefall/blob/main/input.c): `input.c`
- [Byte audio](https://github.com/encrize/bytefall/blob/main/audio.c): `audio.c`

### Byte visualization

- [Pixel decoding](https://github.com/encrize/bytefall/blob/main/viewport.c): `viewport.c`
- [Waterfall rendering](https://github.com/encrize/bytefall/blob/main/viewport.c): `viewport.c`
- [Minimap](https://github.com/encrize/bytefall/blob/main/viewport.c): `viewport.c`
- [Scroll and tooltip](https://github.com/encrize/bytefall/blob/main/viewport.c): `viewport.c`

### Interface rendering

- [Frame rendering](https://github.com/encrize/bytefall/blob/main/render.c): `render.c`
- [Controls and help](https://github.com/encrize/bytefall/blob/main/ui.c): `ui.c`
- [Drawing primitives](https://github.com/encrize/bytefall/blob/main/draw.c): `draw.c`

### Other components

- **User**
- **SDL2 runtime**

## Connections

- User → Event loop: starts app (evidence: `README.md`)
- Event loop → SDL2 runtime: polls events (evidence: `main.c`)
- Event loop → File loading: loads files (evidence: `main.c`)
- Event loop → Input handling: dispatches input (evidence: `main.c`)
- Event loop → Frame rendering: renders frames (evidence: `main.c`)
- Event loop → Byte audio: initializes audio (evidence: `main.c`)
- Event loop → App state: initializes state (evidence: `main.c`)
- Input handling → Byte audio: seeks and restarts (evidence: `input.c`)
- Input handling → App state: updates controls (evidence: `input.c`)
- Byte audio → App state: reads playback state (evidence: `audio.c`)
- Byte audio → SDL2 runtime: registers callback (evidence: `audio.c`)
- Frame rendering → App state: reads app state (evidence: `render.c`)
- Frame rendering → Waterfall rendering: renders waterfall (evidence: `render.c`)
- Frame rendering → Minimap: renders minimap (evidence: `render.c`)
- Frame rendering → Scroll and tooltip: updates navigation (evidence: `render.c`)
- Frame rendering → Controls and help: draws controls (evidence: `render.c`)
- Frame rendering → Drawing primitives: draws frame elements (evidence: `render.c`)
- Waterfall rendering → Pixel decoding: decodes bytes (evidence: `viewport.c`)
- Minimap → Pixel decoding: decodes bytes (evidence: `viewport.c`)
- Scroll and tooltip → App state: reads file position (evidence: `viewport.c`)
- Controls and help → Drawing primitives: draws widgets (evidence: `ui.c`)
