# cpaczek/any-buddy architecture

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

## Overview

any-buddy is a Claude Code companion-pet customizer and binary patching tool. Users enter through the CLI, choose or configure a pet in the TUI or with flags, search for a matching salt, and apply it to Claude Code; they can also preview, restore, rename, manage personalities, and switch saved profiles. The graph includes the documented builder, presets, and saved-buddy experiences alongside sampled generation, patching, and configuration modules. Some command implementations were not excerpted, so those documented paths and relationships are represented only where README or index evidence supports them.

Main entry points: [`src/tui/apply/index.ts`](https://github.com/cpaczek/any-buddy/blob/main/src/tui/apply/index.ts) (Apply flow), [`src/tui/commands/interactive.ts`](https://github.com/cpaczek/any-buddy/blob/main/src/tui/commands/interactive.ts) (Interactive flow), [`src/patcher/preflight.ts`](https://github.com/cpaczek/any-buddy/blob/main/src/patcher/preflight.ts) (Preflight checks), [`src/tui/index.ts`](https://github.com/cpaczek/any-buddy/blob/main/src/tui/index.ts) (Command router)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["CLI and TUI"]
  node_cli["CLI entry<br/>[cli.ts]"]
  node_commands["Command router<br/>[index.ts]"]
  node_interactive["Interactive flow<br/>[interactive.ts]"]
  node_applyflow["Apply flow<br/>[index.ts]"]
  node_restore["Restore command<br/>[restore.ts]"]
end

subgraph group_customize["Pet Customization"]
  node_builder["Pet builder<br/>[index.ts]"]
  node_builderstate["Builder state<br/>[state.ts]"]
  node_presets["Curated presets<br/>[presets.ts]"]
  node_personality["Personality options<br/>[personalities.ts]"]
end

subgraph group_engine["Generation and Search"]
  node_generation["Pet generation<br/>[roll.ts]"]
  node_hash["Hash computation<br/>[hash.ts]"]
  node_finder["Salt search<br/>[orchestrator.ts]"]
  node_worker["Search workers<br/>[worker.ts]"]
end

subgraph group_binary["Binary and Configuration"]
  node_patcher["Binary patching<br/>[patch.ts]"]
  node_binaryfind["Binary discovery<br/>[binary-finder.ts]"]
  node_preflight["Preflight checks<br/>[preflight.ts]"]
  node_petconfig[("Pet profiles<br/>[pet-config.ts]")]
  node_claudeconfig[("Claude settings<br/>[claude-config.ts]")]
  node_hooks["Auto-patch hooks<br/>[hooks.ts]"]
end

subgraph group_views["Preview and Profiles"]
  node_presetui["Preset browser<br/>[index.ts]"]
  node_gallery["Saved buddies<br/>[index.ts]"]
  node_preview["Sprite rendering<br/>[render.ts]"]
end

node_user(("Pet owner"))

node_user -->|"runs"| node_cli
node_cli -->|"dispatches"| node_commands
node_commands -->|"routes to"| node_interactive
node_commands -->|"routes to"| node_restore
node_interactive -->|"opens builder"| node_builder
node_builder -->|"updates"| node_builderstate
node_interactive -->|"reads"| node_presets
node_interactive -->|"starts apply"| node_applyflow
node_presetui -->|"browses"| node_presets
node_builder -->|"renders preview"| node_preview
node_applyflow -->|"generates pet"| node_generation
node_generation -->|"computes hash"| node_hash
node_applyflow -->|"searches salt"| node_finder
node_finder -->|"locates binary"| node_binaryfind
node_applyflow -->|"patches binary"| node_patcher
node_preflight -->|"checks binary"| node_binaryfind
node_preflight -->|"restores if needed"| node_patcher
node_preflight -->|"loads config"| node_petconfig
node_applyflow -->|"saves profile"| node_petconfig
node_applyflow -->|"updates companion"| node_claudeconfig
node_applyflow -->|"sets up hook"| node_hooks
node_gallery -->|"switches profiles"| node_petconfig
node_restore -->|"restores binary"| node_patcher
node_restore -->|"removes hook"| node_hooks
node_interactive -->|"offers personality"| node_personality
node_finder -.->|"delegates search"| node_worker

click node_cli "https://github.com/cpaczek/any-buddy/blob/main/src/cli.ts"
click node_commands "https://github.com/cpaczek/any-buddy/blob/main/src/tui/index.ts"
click node_interactive "https://github.com/cpaczek/any-buddy/blob/main/src/tui/commands/interactive.ts"
click node_builder "https://github.com/cpaczek/any-buddy/blob/main/src/tui/builder/index.ts"
click node_builderstate "https://github.com/cpaczek/any-buddy/blob/main/src/tui/builder/state.ts"
click node_presets "https://github.com/cpaczek/any-buddy/blob/main/src/presets.ts"
click node_presetui "https://github.com/cpaczek/any-buddy/blob/main/src/tui/presets/index.ts"
click node_gallery "https://github.com/cpaczek/any-buddy/blob/main/src/tui/gallery/index.ts"
click node_preview "https://github.com/cpaczek/any-buddy/blob/main/src/sprites/render.ts"
click node_applyflow "https://github.com/cpaczek/any-buddy/blob/main/src/tui/apply/index.ts"
click node_generation "https://github.com/cpaczek/any-buddy/blob/main/src/generation/roll.ts"
click node_hash "https://github.com/cpaczek/any-buddy/blob/main/src/generation/hash.ts"
click node_finder "https://github.com/cpaczek/any-buddy/blob/main/src/finder/orchestrator.ts"
click node_worker "https://github.com/cpaczek/any-buddy/blob/main/src/finder/worker.ts"
click node_patcher "https://github.com/cpaczek/any-buddy/blob/main/src/patcher/patch.ts"
click node_binaryfind "https://github.com/cpaczek/any-buddy/blob/main/src/patcher/binary-finder.ts"
click node_preflight "https://github.com/cpaczek/any-buddy/blob/main/src/patcher/preflight.ts"
click node_petconfig "https://github.com/cpaczek/any-buddy/blob/main/src/config/pet-config.ts"
click node_claudeconfig "https://github.com/cpaczek/any-buddy/blob/main/src/config/claude-config.ts"
click node_hooks "https://github.com/cpaczek/any-buddy/blob/main/src/config/hooks.ts"
click node_personality "https://github.com/cpaczek/any-buddy/blob/main/src/personalities.ts"
click node_restore "https://github.com/cpaczek/any-buddy/blob/main/src/tui/commands/restore.ts"

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_commands,node_interactive,node_applyflow,node_restore toneBlue
class node_builder,node_builderstate,node_presets,node_personality toneAmber
class node_generation,node_hash,node_finder,node_worker toneMint
class node_patcher,node_binaryfind,node_preflight,node_petconfig,node_claudeconfig,node_hooks toneRose
class node_presetui,node_gallery,node_preview,node_user toneIndigo
```

## Components

### CLI and TUI

- [CLI entry](https://github.com/cpaczek/any-buddy/blob/main/src/cli.ts): `src/cli.ts`
- [Command router](https://github.com/cpaczek/any-buddy/blob/main/src/tui/index.ts): `src/tui/index.ts`
- [Interactive flow](https://github.com/cpaczek/any-buddy/blob/main/src/tui/commands/interactive.ts): `src/tui/commands/interactive.ts`
- [Apply flow](https://github.com/cpaczek/any-buddy/blob/main/src/tui/apply/index.ts): `src/tui/apply/index.ts`
- [Restore command](https://github.com/cpaczek/any-buddy/blob/main/src/tui/commands/restore.ts): `src/tui/commands/restore.ts`

### Pet Customization

- [Pet builder](https://github.com/cpaczek/any-buddy/blob/main/src/tui/builder/index.ts): `src/tui/builder/index.ts`
- [Builder state](https://github.com/cpaczek/any-buddy/blob/main/src/tui/builder/state.ts): `src/tui/builder/state.ts`
- [Curated presets](https://github.com/cpaczek/any-buddy/blob/main/src/presets.ts): `src/presets.ts`
- [Personality options](https://github.com/cpaczek/any-buddy/blob/main/src/personalities.ts): `src/personalities.ts`

### Generation and Search

- [Pet generation](https://github.com/cpaczek/any-buddy/blob/main/src/generation/roll.ts): `src/generation/roll.ts`
- [Hash computation](https://github.com/cpaczek/any-buddy/blob/main/src/generation/hash.ts): `src/generation/hash.ts`
- [Salt search](https://github.com/cpaczek/any-buddy/blob/main/src/finder/orchestrator.ts): `src/finder/orchestrator.ts`
- [Search workers](https://github.com/cpaczek/any-buddy/blob/main/src/finder/worker.ts): `src/finder/worker.ts`

### Binary and Configuration

- [Binary patching](https://github.com/cpaczek/any-buddy/blob/main/src/patcher/patch.ts): `src/patcher/patch.ts`
- [Binary discovery](https://github.com/cpaczek/any-buddy/blob/main/src/patcher/binary-finder.ts): `src/patcher/binary-finder.ts`
- [Preflight checks](https://github.com/cpaczek/any-buddy/blob/main/src/patcher/preflight.ts): `src/patcher/preflight.ts`
- [Pet profiles](https://github.com/cpaczek/any-buddy/blob/main/src/config/pet-config.ts): `src/config/pet-config.ts`
- [Claude settings](https://github.com/cpaczek/any-buddy/blob/main/src/config/claude-config.ts): `src/config/claude-config.ts`
- [Auto-patch hooks](https://github.com/cpaczek/any-buddy/blob/main/src/config/hooks.ts): `src/config/hooks.ts`

### Preview and Profiles

- [Preset browser](https://github.com/cpaczek/any-buddy/blob/main/src/tui/presets/index.ts): `src/tui/presets/index.ts`
- [Saved buddies](https://github.com/cpaczek/any-buddy/blob/main/src/tui/gallery/index.ts): `src/tui/gallery/index.ts`
- [Sprite rendering](https://github.com/cpaczek/any-buddy/blob/main/src/sprites/render.ts): `src/sprites/render.ts`

### Other components

- **Pet owner**

## Connections

- Pet owner → CLI entry: runs (evidence: `README.md`)
- CLI entry → Command router: dispatches (evidence: `src/cli.ts`)
- Command router → Interactive flow: routes to (evidence: `src/tui/index.ts`)
- Command router → Restore command: routes to (evidence: `src/tui/index.ts`)
- Interactive flow → Pet builder: opens builder (evidence: `src/tui/commands/interactive.ts`)
- Pet builder → Builder state: updates (evidence: `src/tui/builder/index.ts`)
- Interactive flow → Curated presets: reads (evidence: `src/tui/commands/interactive.ts`)
- Interactive flow → Apply flow: starts apply (evidence: `src/tui/commands/interactive.ts`)
- Preset browser → Curated presets: browses (evidence: `src/tui/presets/index.ts`)
- Pet builder → Sprite rendering: renders preview
- Apply flow → Pet generation: generates pet (evidence: `src/tui/apply/index.ts`)
- Pet generation → Hash computation: computes hash (evidence: `src/generation/roll.ts`)
- Apply flow → Salt search: searches salt (evidence: `src/tui/apply/index.ts`)
- Salt search → Binary discovery: locates binary (evidence: `src/finder/orchestrator.ts`)
- Apply flow → Binary patching: patches binary (evidence: `src/tui/apply/index.ts`)
- Preflight checks → Binary discovery: checks binary (evidence: `src/patcher/preflight.ts`)
- Preflight checks → Binary patching: restores if needed (evidence: `src/patcher/preflight.ts`)
- Preflight checks → Pet profiles: loads config (evidence: `src/patcher/preflight.ts`)
- Apply flow → Pet profiles: saves profile (evidence: `src/tui/apply/index.ts`)
- Apply flow → Claude settings: updates companion (evidence: `src/tui/apply/index.ts`)
- Apply flow → Auto-patch hooks: sets up hook (evidence: `README.md`)
- Saved buddies → Pet profiles: switches profiles (evidence: `README.md`)
- Restore command → Binary patching: restores binary (evidence: `README.md`)
- Restore command → Auto-patch hooks: removes hook (evidence: `README.md`)
- Interactive flow → Personality options: offers personality (evidence: `src/tui/commands/interactive.ts`)
- Salt search → Search workers: delegates search
