# sevinatenine/backwash architecture

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

- Interactive diagram: https://gitdiagram.com/sevinatenine/backwash
- Repository: https://github.com/sevinatenine/backwash

## Overview

Backwash is a compact esoteric-language interpreter. The main workflow is to select a .bw program, read it and optional input, execute its instructions, then emit characters to stdout or a file. The interpreter builds a label table before executing lines and maintains the language’s byte variables and stack. The README also documents a browser playground; its implementation was not sampled, so its wiring is shown only at the level the documentation supports.

Main entry points: [`src/main.js`](https://github.com/sevinatenine/backwash/blob/main/src/main.js) (CLI entry point), [`src/code.js`](https://github.com/sevinatenine/backwash/blob/main/src/code.js) (Instruction execution), [`playground/index.html`](https://github.com/sevinatenine/backwash/blob/main/playground/index.html) (Browser playground)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_cli["Command-line runner"]
  node_cli["CLI entry point<br/>[main.js]"]
  node_io["Character I/O callbacks<br/>[main.js]"]
end

subgraph group_runtime["Language runtime"]
  node_prepare["Line and label scan<br/>[code.js]"]
  node_execute["Instruction execution<br/>[code.js]"]
  node_state["Variables and stack<br/>[code.js]"]
end

subgraph group_web["Browser playground"]
  node_browser["Browser playground<br/>[index.html]"]
end

node_user(("Program user"))
node_programfile["Program file"]
node_inputfile["Input file"]
node_outputfile["Output file"]
node_stdin(("Standard input"))
node_stdout(("Standard output"))
node_monaco["Monaco editor"]
node_xterm["Xterm I/O"]
node_webuser(("Browser user"))

node_user -->|"runs program"| node_cli
node_cli -->|"reads source"| node_programfile
node_cli -.->|"reads optional input"| node_inputfile
node_cli -.->|"writes optional output"| node_outputfile
node_stdin -->|"provides bytes"| node_io
node_io -->|"writes characters"| node_stdout
node_cli -->|"calls run"| node_execute
node_cli -->|"supplies callbacks"| node_io
node_execute -->|"splits lines; scans labels"| node_prepare
node_execute -->|"updates state"| node_state
node_execute -->|"invokes I/O callbacks"| node_io
node_webuser -->|"uses playground"| node_browser
node_browser -.->|"uses editor"| node_monaco
node_browser -.->|"uses terminal I/O"| node_xterm
node_browser -->|"runs language"| node_execute

click node_cli "https://github.com/sevinatenine/backwash/blob/main/src/main.js"
click node_prepare "https://github.com/sevinatenine/backwash/blob/main/src/code.js"
click node_execute "https://github.com/sevinatenine/backwash/blob/main/src/code.js"
click node_state "https://github.com/sevinatenine/backwash/blob/main/src/code.js"
click node_io "https://github.com/sevinatenine/backwash/blob/main/src/main.js"
click node_browser "https://github.com/sevinatenine/backwash/blob/main/playground/index.html"

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_io,node_user,node_webuser toneBlue
class node_prepare,node_execute,node_state toneAmber
class node_browser toneMint
class node_programfile,node_inputfile,node_outputfile,node_stdin,node_stdout,node_monaco,node_xterm toneIndigo
```

## Components

### Command-line runner

- [CLI entry point](https://github.com/sevinatenine/backwash/blob/main/src/main.js): `src/main.js`
- [Character I/O callbacks](https://github.com/sevinatenine/backwash/blob/main/src/main.js): `src/main.js`

### Language runtime

- [Line and label scan](https://github.com/sevinatenine/backwash/blob/main/src/code.js): `src/code.js`
- [Instruction execution](https://github.com/sevinatenine/backwash/blob/main/src/code.js): `src/code.js`
- [Variables and stack](https://github.com/sevinatenine/backwash/blob/main/src/code.js): `src/code.js`

### Browser playground

- [Browser playground](https://github.com/sevinatenine/backwash/blob/main/playground/index.html): `playground/index.html`

### Other components

- **Program user**
- **Program file**
- **Input file**
- **Output file**
- **Standard input**
- **Standard output**
- **Monaco editor**
- **Xterm I/O**
- **Browser user**

## Connections

- Program user → CLI entry point: runs program
- CLI entry point → Program file: reads source
- CLI entry point → Input file: reads optional input
- CLI entry point → Output file: writes optional output
- Standard input → Character I/O callbacks: provides bytes
- Character I/O callbacks → Standard output: writes characters
- CLI entry point → Instruction execution: calls run
- CLI entry point → Character I/O callbacks: supplies callbacks
- Instruction execution → Line and label scan: splits lines; scans labels
- Instruction execution → Variables and stack: updates state
- Instruction execution → Character I/O callbacks: invokes I/O callbacks
- Browser user → Browser playground: uses playground
- Browser playground → Monaco editor: uses editor
- Browser playground → Xterm I/O: uses terminal I/O
- Browser playground → Instruction execution: runs language
