# sussyback99/rish architecture

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

- Interactive diagram: https://gitdiagram.com/sussyback99/rish
- Repository: https://github.com/sussyback99/rish

## Overview

rish is a small interactive Unix shell. Its main loop loads history, repeatedly renders a prompt and reads a line, parses it, then handles built-in commands; on exit it saves history. The single source file contains the prompt, raw terminal input and history-based suggestions, parsing, and inline command handling. The README documents these capabilities, while the sampled source confirms their implementation. Components share that file; edges cite it where the caller or interaction is visible.

Main entry points: [`rish.cpp`](https://github.com/sussyback99/rish/blob/main/rish.cpp) (Shell loop)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_interaction["Interactive shell"]
  node_shell["Shell loop<br/>[rish.cpp]"]
  node_prompt["Dynamic prompt<br/>[rish.cpp]"]
  node_input["Raw input<br/>[rish.cpp]"]
  node_suggestions["History suggestions<br/>[rish.cpp]"]
  node_parser["Command parser<br/>[rish.cpp]"]
end

subgraph group_commands["Built-in commands"]
  node_print["print command<br/>[rish.cpp]"]
  node_cwd["CWD output<br/>[rish.cpp]"]
  node_who["who command<br/>[rish.cpp]"]
  node_cd["cd command<br/>[rish.cpp]"]
  node_exit["exit command<br/>[rish.cpp]"]
end

subgraph group_state["Command history"]
  node_history[("History file<br/>[rish.cpp]")]
end

node_user(("User"))
node_terminal(("Terminal"))

node_user -->|"enters commands"| node_terminal
node_terminal -->|"provides keystrokes"| node_input
node_input -->|"echoes input"| node_terminal
node_shell -->|"renders"| node_prompt
node_shell -->|"reads line"| node_input
node_input -->|"finds matches"| node_suggestions
node_suggestions -->|"searches entries"| node_history
node_shell -->|"loads and saves"| node_history
node_shell -->|"parses line"| node_parser
node_shell -->|"dispatches print"| node_print
node_shell -->|"dispatches who"| node_who
node_shell -->|"dispatches cd"| node_cd
node_shell -->|"dispatches exit"| node_exit
node_print -->|"prints directory"| node_cwd
node_print -->|"writes output"| node_terminal
node_who -->|"writes UID"| node_terminal
node_cd -->|"changes working directory"| node_shell
node_exit -->|"triggers save"| node_history

click node_shell "https://github.com/sussyback99/rish/blob/main/rish.cpp"
click node_prompt "https://github.com/sussyback99/rish/blob/main/rish.cpp"
click node_input "https://github.com/sussyback99/rish/blob/main/rish.cpp"
click node_suggestions "https://github.com/sussyback99/rish/blob/main/rish.cpp"
click node_parser "https://github.com/sussyback99/rish/blob/main/rish.cpp"
click node_history "https://github.com/sussyback99/rish/blob/main/rish.cpp"
click node_print "https://github.com/sussyback99/rish/blob/main/rish.cpp"
click node_cwd "https://github.com/sussyback99/rish/blob/main/rish.cpp"
click node_who "https://github.com/sussyback99/rish/blob/main/rish.cpp"
click node_cd "https://github.com/sussyback99/rish/blob/main/rish.cpp"
click node_exit "https://github.com/sussyback99/rish/blob/main/rish.cpp"

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_shell,node_prompt,node_input,node_suggestions,node_parser,node_user toneBlue
class node_print,node_cwd,node_who,node_cd,node_exit toneAmber
class node_history toneMint
class node_terminal toneIndigo
```

## Components

### Interactive shell

- [Shell loop](https://github.com/sussyback99/rish/blob/main/rish.cpp): `rish.cpp`
- [Dynamic prompt](https://github.com/sussyback99/rish/blob/main/rish.cpp): `rish.cpp`
- [Raw input](https://github.com/sussyback99/rish/blob/main/rish.cpp): `rish.cpp`
- [History suggestions](https://github.com/sussyback99/rish/blob/main/rish.cpp): `rish.cpp`
- [Command parser](https://github.com/sussyback99/rish/blob/main/rish.cpp): `rish.cpp`

### Built-in commands

- [print command](https://github.com/sussyback99/rish/blob/main/rish.cpp): `rish.cpp`
- [CWD output](https://github.com/sussyback99/rish/blob/main/rish.cpp): `rish.cpp`
- [who command](https://github.com/sussyback99/rish/blob/main/rish.cpp): `rish.cpp`
- [cd command](https://github.com/sussyback99/rish/blob/main/rish.cpp): `rish.cpp`
- [exit command](https://github.com/sussyback99/rish/blob/main/rish.cpp): `rish.cpp`

### Command history

- [History file](https://github.com/sussyback99/rish/blob/main/rish.cpp): `rish.cpp`

### Other components

- **User**
- **Terminal**

## Connections

- User → Terminal: enters commands (evidence: `README.md`)
- Terminal → Raw input: provides keystrokes (evidence: `rish.cpp`)
- Raw input → Terminal: echoes input (evidence: `rish.cpp`)
- Shell loop → Dynamic prompt: renders (evidence: `rish.cpp`)
- Shell loop → Raw input: reads line (evidence: `rish.cpp`)
- Raw input → History suggestions: finds matches (evidence: `rish.cpp`)
- History suggestions → History file: searches entries (evidence: `rish.cpp`)
- Shell loop → History file: loads and saves (evidence: `rish.cpp`)
- Shell loop → Command parser: parses line (evidence: `rish.cpp`)
- Shell loop → print command: dispatches print (evidence: `rish.cpp`)
- Shell loop → who command: dispatches who (evidence: `rish.cpp`)
- Shell loop → cd command: dispatches cd (evidence: `rish.cpp`)
- Shell loop → exit command: dispatches exit (evidence: `rish.cpp`)
- print command → CWD output: prints directory (evidence: `rish.cpp`)
- print command → Terminal: writes output (evidence: `rish.cpp`)
- who command → Terminal: writes UID (evidence: `rish.cpp`)
- cd command → Shell loop: changes working directory (evidence: `rish.cpp`)
- exit command → History file: triggers save (evidence: `rish.cpp`)
