# zanostro/shell architecture

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

- Interactive diagram: https://gitdiagram.com/zanostro/shell
- Repository: https://github.com/zanostro/shell

## Overview

This repository is a small, single-file command shell. Its principal workflow is user input, command parsing and execution, then output or side effects. The excerpt shows built-in commands for files and directories, system information, and shell utilities, as well as pipelines and process waiting. Because the excerpts omit much of the main loop and command-dispatch code, the input-to-dispatch relationships are shown as unverified rather than asserted as source-backed calls.

Main entry points: [`shell.cpp`](https://github.com/zanostro/shell/blob/main/shell.cpp) (Command execution)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_shell["Shell runtime"]
  node_loop["Interactive loop<br/>[shell.cpp]"]
  node_parser["Command tokenizer<br/>[shell.cpp]"]
  node_dispatcher["Command execution<br/>[shell.cpp]"]
end

subgraph group_commands["Built-in commands"]
  node_file_commands["File commands<br/>[shell.cpp]"]
  node_directory_commands["Directory commands<br/>[shell.cpp]"]
  node_system_commands["System commands<br/>[shell.cpp]"]
  node_utility_commands["Shell utilities<br/>[shell.cpp]"]
end

subgraph group_processes["Process execution"]
  node_pipeline["Pipeline runner<br/>[shell.cpp]"]
  node_child_process["Child processes"]
end

node_user(("Shell user"))
node_os_resources[("OS and filesystem")]

node_user -.->|"enters commands"| node_loop
node_loop -.->|"parses input"| node_parser
node_parser -.->|"dispatches command"| node_dispatcher
node_dispatcher -.->|"runs builtin"| node_file_commands
node_dispatcher -.->|"runs builtin"| node_directory_commands
node_dispatcher -.->|"runs builtin"| node_system_commands
node_dispatcher -.->|"runs builtin"| node_utility_commands
node_dispatcher -.->|"runs pipeline"| node_pipeline
node_pipeline -->|"forks processes"| node_child_process
node_pipeline -->|"executes commands"| node_child_process
node_pipeline -->|"connects pipes"| node_os_resources
node_file_commands -->|"changes files"| node_os_resources
node_directory_commands -->|"changes directories"| node_os_resources
node_system_commands -->|"reads system info"| node_os_resources
node_utility_commands -->|"reads and writes"| node_os_resources

click node_loop "https://github.com/zanostro/shell/blob/main/shell.cpp"
click node_parser "https://github.com/zanostro/shell/blob/main/shell.cpp"
click node_dispatcher "https://github.com/zanostro/shell/blob/main/shell.cpp"
click node_file_commands "https://github.com/zanostro/shell/blob/main/shell.cpp"
click node_directory_commands "https://github.com/zanostro/shell/blob/main/shell.cpp"
click node_system_commands "https://github.com/zanostro/shell/blob/main/shell.cpp"
click node_utility_commands "https://github.com/zanostro/shell/blob/main/shell.cpp"
click node_pipeline "https://github.com/zanostro/shell/blob/main/shell.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_loop,node_parser,node_dispatcher,node_user toneBlue
class node_file_commands,node_directory_commands,node_system_commands,node_utility_commands,node_os_resources toneAmber
class node_pipeline,node_child_process toneMint
```

## Components

### Shell runtime

- [Interactive loop](https://github.com/zanostro/shell/blob/main/shell.cpp): `shell.cpp`
- [Command tokenizer](https://github.com/zanostro/shell/blob/main/shell.cpp): `shell.cpp`
- [Command execution](https://github.com/zanostro/shell/blob/main/shell.cpp): `shell.cpp`

### Built-in commands

- [File commands](https://github.com/zanostro/shell/blob/main/shell.cpp): `shell.cpp`
- [Directory commands](https://github.com/zanostro/shell/blob/main/shell.cpp): `shell.cpp`
- [System commands](https://github.com/zanostro/shell/blob/main/shell.cpp): `shell.cpp`
- [Shell utilities](https://github.com/zanostro/shell/blob/main/shell.cpp): `shell.cpp`

### Process execution

- [Pipeline runner](https://github.com/zanostro/shell/blob/main/shell.cpp): `shell.cpp`
- **Child processes**

### Other components

- **Shell user**
- **OS and filesystem**

## Connections

- Shell user → Interactive loop: enters commands
- Interactive loop → Command tokenizer: parses input (evidence: `shell.cpp`)
- Command tokenizer → Command execution: dispatches command (evidence: `shell.cpp`)
- Command execution → File commands: runs builtin (evidence: `shell.cpp`)
- Command execution → Directory commands: runs builtin (evidence: `shell.cpp`)
- Command execution → System commands: runs builtin (evidence: `shell.cpp`)
- Command execution → Shell utilities: runs builtin (evidence: `shell.cpp`)
- Command execution → Pipeline runner: runs pipeline (evidence: `shell.cpp`)
- Pipeline runner → Child processes: forks processes (evidence: `shell.cpp`)
- Pipeline runner → Child processes: executes commands (evidence: `shell.cpp`)
- Pipeline runner → OS and filesystem: connects pipes (evidence: `shell.cpp`)
- File commands → OS and filesystem: changes files (evidence: `shell.cpp`)
- Directory commands → OS and filesystem: changes directories (evidence: `shell.cpp`)
- System commands → OS and filesystem: reads system info (evidence: `shell.cpp`)
- Shell utilities → OS and filesystem: reads and writes (evidence: `shell.cpp`)
