# nxfu/binthere architecture

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

- Interactive diagram: https://gitdiagram.com/nxfu/binthere
- Repository: https://github.com/nxfu/binthere

## Overview

binthere is a zero-knowledge, one-time note-sharing service with both browser and CLI clients. In the main workflow, a writer encrypts locally, uploads ciphertext, and shares a URL whose fragment retains the key; a recipient fetches and decrypts, while the Worker atomically consumes burn-after-read notes. The graph also preserves CLI operations, rendering/sharing, storage, and rate limiting. Edges reflect shown calls or README-described behavior; unsampled subsystems are included only where documented, with evidence limits represented by omitted links.

Main entry points: [`src/index.js`](https://github.com/nxfu/binthere/blob/main/src/index.js) (API Worker), [`public/js/app.js`](https://github.com/nxfu/binthere/blob/main/public/js/app.js) (Web workflow), [`cli/src/cli.js`](https://github.com/nxfu/binthere/blob/main/cli/src/cli.js) (CLI dispatch), [`cli/src/wizard.js`](https://github.com/nxfu/binthere/blob/main/cli/src/wizard.js) (Interactive wizard)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web["Browser client"]
  node_webapp["Web workflow<br/>[app.js]"]
  node_webcrypto["Browser crypto<br/>[crypto.js]"]
  node_webapi["Browser API<br/>[api.js]"]
  node_render["Safe rendering<br/>[markdown.js]"]
  node_highlight["Syntax highlighting<br/>[highlight.js]"]
  node_webui["Sharing UI<br/>[ui.js]"]
end

subgraph group_cli["Command-line client"]
  node_cliapp["CLI dispatch<br/>[cli.js]"]
  node_wizard["Interactive wizard<br/>[wizard.js]"]
  node_create["Create command<br/>[create.js]"]
  node_get["Read command<br/>[get.js]"]
  node_delete["Delete command<br/>[delete.js]"]
  node_update["Self-update<br/>[update.js]"]
  node_client["HTTP client<br/>[client.js]"]
  node_tui["Terminal interface<br/>[screen.js]"]
end

subgraph group_worker["Worker service"]
  node_worker["API Worker<br/>[index.js]"]
  node_burn["Atomic burn<br/>[burn-do.js]"]
  node_kv[("Paste storage<br/>[store.js]")]
  node_ratelimit["Create rate limit<br/>[ratelimit.js]"]
  node_stars["Public star count<br/>[stars.js]"]
end

subgraph group_runtime["Shared protocol"]
  node_ids["IDs and tokens<br/>[ids.js]"]
  node_format["Wire validation<br/>[format.js]"]
  node_bytes["Byte primitives<br/>[bytes.js]"]
end

node_writer(("Note writer"))
node_recipient(("Note recipient"))
node_server[("Cloudflare services")]

node_writer -->|"writes note"| node_webapp
node_webapp -->|"encrypts locally"| node_webcrypto
node_webapp -->|"uploads ciphertext"| node_webapi
node_webapp -->|"fetches ciphertext"| node_webapi
node_webapp -->|"decrypts locally"| node_webcrypto
node_webapp -->|"renders Markdown"| node_render
node_webapp -->|"offers sharing"| node_webui
node_webapp -.->|"highlights code"| node_highlight
node_recipient -->|"opens share link"| node_webapp
node_webapp -->|"requests note"| node_worker
node_cliapp -->|"dispatches create"| node_create
node_cliapp -->|"dispatches read"| node_get
node_cliapp -->|"dispatches delete"| node_delete
node_cliapp -->|"dispatches update"| node_update
node_cliapp -->|"opens menu"| node_wizard
node_wizard -->|"creates note"| node_create
node_wizard -->|"views note"| node_get
node_wizard -->|"deletes note"| node_delete
node_wizard -->|"draws screens"| node_tui
node_create -->|"uploads ciphertext"| node_client
node_get -->|"fetches and consumes"| node_client
node_delete -->|"deletes paste"| node_client
node_create -.->|"creates paste"| node_worker
node_get -.->|"reads paste"| node_worker
node_delete -.->|"requests deletion"| node_worker
node_client -.->|"calls API"| node_worker
node_worker -->|"checks create rate"| node_ratelimit
node_worker -->|"validates IDs"| node_ids
node_worker -->|"creates token hash"| node_ids
node_worker -->|"validates payload"| node_format
node_worker -->|"creates or consumes"| node_burn
node_worker -->|"reads and writes"| node_kv
node_worker -->|"fetches star count"| node_stars
node_burn -->|"parses IDs"| node_ids
node_ids -->|"uses byte helpers"| node_bytes
node_format -->|"decodes bytes"| node_bytes
node_server -->|"hosts API"| node_worker
node_server -->|"provides KV"| node_kv
node_server -->|"runs Durable Object"| node_burn

click node_webapp "https://github.com/nxfu/binthere/blob/main/public/js/app.js"
click node_webcrypto "https://github.com/nxfu/binthere/blob/main/public/js/crypto.js"
click node_webapi "https://github.com/nxfu/binthere/blob/main/public/js/api.js"
click node_render "https://github.com/nxfu/binthere/blob/main/public/js/markdown.js"
click node_highlight "https://github.com/nxfu/binthere/blob/main/public/js/highlight.js"
click node_webui "https://github.com/nxfu/binthere/blob/main/public/js/ui.js"
click node_cliapp "https://github.com/nxfu/binthere/blob/main/cli/src/cli.js"
click node_wizard "https://github.com/nxfu/binthere/blob/main/cli/src/wizard.js"
click node_create "https://github.com/nxfu/binthere/blob/main/cli/src/commands/create.js"
click node_get "https://github.com/nxfu/binthere/blob/main/cli/src/commands/get.js"
click node_delete "https://github.com/nxfu/binthere/blob/main/cli/src/commands/delete.js"
click node_update "https://github.com/nxfu/binthere/blob/main/cli/src/commands/update.js"
click node_client "https://github.com/nxfu/binthere/blob/main/cli/src/client.js"
click node_tui "https://github.com/nxfu/binthere/blob/main/cli/src/tui/screen.js"
click node_worker "https://github.com/nxfu/binthere/blob/main/src/index.js"
click node_burn "https://github.com/nxfu/binthere/blob/main/src/burn-do.js"
click node_kv "https://github.com/nxfu/binthere/blob/main/src/lib/store.js"
click node_ratelimit "https://github.com/nxfu/binthere/blob/main/src/lib/ratelimit.js"
click node_stars "https://github.com/nxfu/binthere/blob/main/src/lib/stars.js"
click node_ids "https://github.com/nxfu/binthere/blob/main/src/lib/ids.js"
click node_format "https://github.com/nxfu/binthere/blob/main/public/js/format.js"
click node_bytes "https://github.com/nxfu/binthere/blob/main/public/js/bytes.js"

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_webapp,node_webcrypto,node_webapi,node_render,node_highlight,node_webui toneBlue
class node_cliapp,node_wizard,node_create,node_get,node_delete,node_update,node_client,node_tui,node_server toneAmber
class node_worker,node_burn,node_kv,node_ratelimit,node_stars toneMint
class node_ids,node_format,node_bytes toneRose
class node_writer,node_recipient toneIndigo
```

## Components

### Browser client

- [Web workflow](https://github.com/nxfu/binthere/blob/main/public/js/app.js): `public/js/app.js`
- [Browser crypto](https://github.com/nxfu/binthere/blob/main/public/js/crypto.js): `public/js/crypto.js`
- [Browser API](https://github.com/nxfu/binthere/blob/main/public/js/api.js): `public/js/api.js`
- [Safe rendering](https://github.com/nxfu/binthere/blob/main/public/js/markdown.js): `public/js/markdown.js`
- [Syntax highlighting](https://github.com/nxfu/binthere/blob/main/public/js/highlight.js): `public/js/highlight.js`
- [Sharing UI](https://github.com/nxfu/binthere/blob/main/public/js/ui.js): `public/js/ui.js`

### Command-line client

- [CLI dispatch](https://github.com/nxfu/binthere/blob/main/cli/src/cli.js): `cli/src/cli.js`
- [Interactive wizard](https://github.com/nxfu/binthere/blob/main/cli/src/wizard.js): `cli/src/wizard.js`
- [Create command](https://github.com/nxfu/binthere/blob/main/cli/src/commands/create.js): `cli/src/commands/create.js`
- [Read command](https://github.com/nxfu/binthere/blob/main/cli/src/commands/get.js): `cli/src/commands/get.js`
- [Delete command](https://github.com/nxfu/binthere/blob/main/cli/src/commands/delete.js): `cli/src/commands/delete.js`
- [Self-update](https://github.com/nxfu/binthere/blob/main/cli/src/commands/update.js): `cli/src/commands/update.js`
- [HTTP client](https://github.com/nxfu/binthere/blob/main/cli/src/client.js): `cli/src/client.js`
- [Terminal interface](https://github.com/nxfu/binthere/blob/main/cli/src/tui/screen.js): `cli/src/tui/screen.js`

### Worker service

- [API Worker](https://github.com/nxfu/binthere/blob/main/src/index.js): `src/index.js`
- [Atomic burn](https://github.com/nxfu/binthere/blob/main/src/burn-do.js): `src/burn-do.js`
- [Paste storage](https://github.com/nxfu/binthere/blob/main/src/lib/store.js): `src/lib/store.js`
- [Create rate limit](https://github.com/nxfu/binthere/blob/main/src/lib/ratelimit.js): `src/lib/ratelimit.js`
- [Public star count](https://github.com/nxfu/binthere/blob/main/src/lib/stars.js): `src/lib/stars.js`

### Shared protocol

- [IDs and tokens](https://github.com/nxfu/binthere/blob/main/src/lib/ids.js): `src/lib/ids.js`
- [Wire validation](https://github.com/nxfu/binthere/blob/main/public/js/format.js): `public/js/format.js`
- [Byte primitives](https://github.com/nxfu/binthere/blob/main/public/js/bytes.js): `public/js/bytes.js`

### Other components

- **Note writer**
- **Note recipient**
- **Cloudflare services**

## Connections

- Note writer → Web workflow: writes note (evidence: `README.md`)
- Web workflow → Browser crypto: encrypts locally (evidence: `public/js/app.js`)
- Web workflow → Browser API: uploads ciphertext (evidence: `public/js/app.js`)
- Web workflow → Browser API: fetches ciphertext (evidence: `public/js/app.js`)
- Web workflow → Browser crypto: decrypts locally (evidence: `public/js/app.js`)
- Web workflow → Safe rendering: renders Markdown (evidence: `public/js/app.js`)
- Web workflow → Sharing UI: offers sharing (evidence: `public/js/app.js`)
- Web workflow → Syntax highlighting: highlights code (evidence: `public/js/app.js`)
- Note recipient → Web workflow: opens share link (evidence: `README.md`)
- Web workflow → API Worker: requests note (evidence: `README.md`)
- CLI dispatch → Create command: dispatches create (evidence: `cli/src/cli.js`)
- CLI dispatch → Read command: dispatches read (evidence: `cli/src/cli.js`)
- CLI dispatch → Delete command: dispatches delete (evidence: `cli/src/cli.js`)
- CLI dispatch → Self-update: dispatches update (evidence: `cli/src/cli.js`)
- CLI dispatch → Interactive wizard: opens menu (evidence: `cli/src/cli.js`)
- Interactive wizard → Create command: creates note (evidence: `cli/src/wizard.js`)
- Interactive wizard → Read command: views note (evidence: `cli/src/wizard.js`)
- Interactive wizard → Delete command: deletes note (evidence: `cli/src/wizard.js`)
- Interactive wizard → Terminal interface: draws screens (evidence: `cli/src/wizard.js`)
- Create command → HTTP client: uploads ciphertext (evidence: `cli/src/commands/create.js`)
- Read command → HTTP client: fetches and consumes (evidence: `cli/src/commands/get.js`)
- Delete command → HTTP client: deletes paste (evidence: `cli/src/commands/delete.js`)
- Create command → API Worker: creates paste
- Read command → API Worker: reads paste
- Delete command → API Worker: requests deletion
- HTTP client → API Worker: calls API
- API Worker → Create rate limit: checks create rate (evidence: `src/index.js`)
- API Worker → IDs and tokens: validates IDs (evidence: `src/index.js`)
- API Worker → IDs and tokens: creates token hash (evidence: `src/index.js`)
- API Worker → Wire validation: validates payload (evidence: `src/index.js`)
- API Worker → Atomic burn: creates or consumes (evidence: `src/index.js`)
- API Worker → Paste storage: reads and writes (evidence: `src/index.js`)
- API Worker → Public star count: fetches star count (evidence: `src/index.js`)
- Atomic burn → IDs and tokens: parses IDs (evidence: `src/burn-do.js`)
- IDs and tokens → Byte primitives: uses byte helpers (evidence: `src/lib/ids.js`)
- Wire validation → Byte primitives: decodes bytes (evidence: `public/js/format.js`)
- Cloudflare services → API Worker: hosts API (evidence: `README.md`)
- Cloudflare services → Paste storage: provides KV (evidence: `README.md`)
- Cloudflare services → Atomic burn: runs Durable Object (evidence: `README.md`)
