# clainstone/cbirds architecture

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

- Interactive diagram: https://gitdiagram.com/clainstone/cbirds
- Repository: https://github.com/clainstone/cbirds

## Overview

cbirds is a standalone terminal flock animation. The main workflow is to accept command-line options (and optionally piped text), simulate a flock, then render frames as terminal cells or Kitty graphics. Documented branches include text and clock signs, PNG pictures, 3D flight, and sharing a sky across terminals. The source index identifies the principal modules, but most runtime calls are unsampled; uncertain connections are therefore omitted or shown as unverified.

Main entry points: [`boids.c`](https://github.com/clainstone/cbirds/blob/master/boids.c) (Application loop), [`letters.c`](https://github.com/clainstone/cbirds/blob/master/letters.c) (Flying letters), [`png.c`](https://github.com/clainstone/cbirds/blob/master/png.c) (PNG image library), [`sign.c`](https://github.com/clainstone/cbirds/blob/master/sign.c) (Sign and clock)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["Runtime and flight"]
  node_app["Application loop<br/>[boids.c]"]
  node_options["Option parsing<br/>[options.c]"]
  node_flock3d["3D flock<br/>[sky3d.c]"]
  node_spatial["Spatial index<br/>[spatial_grid.c]"]
end

subgraph group_content["Text and imagery"]
  node_letterflock["Flying letters<br/>[letters.c]"]
  node_sign["Sign and clock<br/>[sign.c]"]
  node_font["Bitmap font<br/>[font.c]"]
  node_terminalinput["Terminal text parser<br/>[vt.c]"]
  node_picture["PNG pictures<br/>[picture.c]"]
  node_png["PNG image library<br/>[png.c]"]
end

subgraph group_display["Terminal rendering"]
  node_cells["Cell renderer<br/>[cells.c]"]
  node_kitty["Kitty graphics<br/>[kitty_graphics.c]"]
  node_sprite["Embedded sprite<br/>[sprite_png.h]"]
end

subgraph group_integration["Sharing and output"]
  node_link["Shared sky<br/>[link.c]"]
  node_gif["GIF recording<br/>[gif.c]"]
end

node_user(("Terminal user"))
node_pipe(("Piped text"))

node_user -->|"runs"| node_app
node_pipe -->|"provides text"| node_app
node_app -->|"reads options"| node_options
node_app -.->|"uses for 3D"| node_flock3d
node_app -.->|"uses index"| node_spatial
node_app -.->|"supports text flight"| node_letterflock
node_app -.->|"supports signs"| node_sign
node_app -.->|"supports pictures"| node_picture
node_app -.->|"renders cells"| node_cells
node_app -.->|"renders sprites"| node_kitty
node_app -.->|"shares sky"| node_link
node_app -.->|"records animation"| node_gif
node_letterflock -.->|"uses layout"| node_terminalinput
node_letterflock -.->|"uses glyphs"| node_font
node_sign -->|"uses glyphs"| node_font
node_picture -->|"decodes images"| node_png
node_cells -->|"reads canvas"| node_png
node_kitty -.->|"uses embedded image"| node_sprite
node_app -.->|"uses image library"| node_png

click node_app "https://github.com/clainstone/cbirds/blob/master/boids.c"
click node_options "https://github.com/clainstone/cbirds/blob/master/options.c"
click node_flock3d "https://github.com/clainstone/cbirds/blob/master/sky3d.c"
click node_spatial "https://github.com/clainstone/cbirds/blob/master/spatial_grid.c"
click node_letterflock "https://github.com/clainstone/cbirds/blob/master/letters.c"
click node_sign "https://github.com/clainstone/cbirds/blob/master/sign.c"
click node_font "https://github.com/clainstone/cbirds/blob/master/font.c"
click node_terminalinput "https://github.com/clainstone/cbirds/blob/master/vt.c"
click node_picture "https://github.com/clainstone/cbirds/blob/master/picture.c"
click node_png "https://github.com/clainstone/cbirds/blob/master/png.c"
click node_cells "https://github.com/clainstone/cbirds/blob/master/cells.c"
click node_kitty "https://github.com/clainstone/cbirds/blob/master/kitty_graphics.c"
click node_sprite "https://github.com/clainstone/cbirds/blob/master/sprite_png.h"
click node_link "https://github.com/clainstone/cbirds/blob/master/link.c"
click node_gif "https://github.com/clainstone/cbirds/blob/master/gif.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_app,node_options,node_flock3d,node_spatial,node_user toneBlue
class node_letterflock,node_sign,node_font,node_terminalinput,node_picture,node_png toneAmber
class node_cells,node_kitty,node_sprite toneMint
class node_link,node_gif toneRose
class node_pipe toneIndigo
```

## Components

### Runtime and flight

- [Application loop](https://github.com/clainstone/cbirds/blob/master/boids.c): `boids.c`
- [Option parsing](https://github.com/clainstone/cbirds/blob/master/options.c): `options.c`
- [3D flock](https://github.com/clainstone/cbirds/blob/master/sky3d.c): `sky3d.c`
- [Spatial index](https://github.com/clainstone/cbirds/blob/master/spatial_grid.c): `spatial_grid.c`

### Text and imagery

- [Flying letters](https://github.com/clainstone/cbirds/blob/master/letters.c): `letters.c`
- [Sign and clock](https://github.com/clainstone/cbirds/blob/master/sign.c): `sign.c`
- [Bitmap font](https://github.com/clainstone/cbirds/blob/master/font.c): `font.c`
- [Terminal text parser](https://github.com/clainstone/cbirds/blob/master/vt.c): `vt.c`
- [PNG pictures](https://github.com/clainstone/cbirds/blob/master/picture.c): `picture.c`
- [PNG image library](https://github.com/clainstone/cbirds/blob/master/png.c): `png.c`

### Terminal rendering

- [Cell renderer](https://github.com/clainstone/cbirds/blob/master/cells.c): `cells.c`
- [Kitty graphics](https://github.com/clainstone/cbirds/blob/master/kitty_graphics.c): `kitty_graphics.c`
- [Embedded sprite](https://github.com/clainstone/cbirds/blob/master/sprite_png.h): `sprite_png.h`

### Sharing and output

- [Shared sky](https://github.com/clainstone/cbirds/blob/master/link.c): `link.c`
- [GIF recording](https://github.com/clainstone/cbirds/blob/master/gif.c): `gif.c`

### Other components

- **Terminal user**
- **Piped text**

## Connections

- Terminal user → Application loop: runs (evidence: `README.md`)
- Piped text → Application loop: provides text (evidence: `README.md`)
- Application loop → Option parsing: reads options (evidence: `boids.c`)
- Application loop → 3D flock: uses for 3D
- Application loop → Spatial index: uses index
- Application loop → Flying letters: supports text flight
- Application loop → Sign and clock: supports signs
- Application loop → PNG pictures: supports pictures
- Application loop → Cell renderer: renders cells
- Application loop → Kitty graphics: renders sprites
- Application loop → Shared sky: shares sky
- Application loop → GIF recording: records animation
- Flying letters → Terminal text parser: uses layout
- Flying letters → Bitmap font: uses glyphs
- Sign and clock → Bitmap font: uses glyphs (evidence: `sign.c`)
- PNG pictures → PNG image library: decodes images (evidence: `picture.c`)
- Cell renderer → PNG image library: reads canvas (evidence: `cells.c`)
- Kitty graphics → Embedded sprite: uses embedded image
- Application loop → PNG image library: uses image library
