# luca-python/rust-shell architecture

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

- Interactive diagram: https://gitdiagram.com/luca-python/rust-shell
- Repository: https://github.com/luca-python/rust-shell

## Overview

Rust Shell is an interactive terminal shell. Its main workflow reads a line, tokenizes it, expands variables, identifies the command, and dispatches to a builtin or the file manager. The main documented capabilities are represented, including environment-variable management and the terminal editor. Evidence is limited to the README and the source excerpts; filesystem and terminal interactions are shown where the excerpts directly implement them.

Main entry points: [`src/main.rs`](https://github.com/luca-python/rust-shell/blob/main/src/main.rs) (Shell loop), [`src/fm.rs`](https://github.com/luca-python/rust-shell/blob/main/src/fm.rs) (File editor), [`src/state.rs`](https://github.com/luca-python/rust-shell/blob/main/src/state.rs) (Shell state), [`src/builtins.rs`](https://github.com/luca-python/rust-shell/blob/main/src/builtins.rs) (Builtins)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_interaction["Shell interaction"]
  node_loop["Shell loop<br/>[main.rs]"]
end

subgraph group_processing["Command processing"]
  node_parser["Line parser<br/>[parser.rs]"]
  node_classifier["Command classifier<br/>[parser.rs]"]
end

subgraph group_facilities["Shell facilities"]
  node_state[("Shell state<br/>[state.rs]")]
  node_builtins["Builtins<br/>[builtins.rs]"]
end

subgraph group_editor["File editor"]
  node_fm["File editor<br/>[fm.rs]"]
end

node_user(("Shell user"))
node_terminal["Terminal I/O"]
node_filesystem["Filesystem"]
node_process_env["Process environment"]

node_user -->|"enters commands"| node_loop
node_loop -->|"parses line"| node_parser
node_loop -->|"expands variables"| node_state
node_loop -->|"identifies command"| node_classifier
node_loop -->|"dispatches builtins"| node_builtins
node_loop -->|"dispatches editor"| node_fm
node_builtins -->|"reads and updates"| node_state
node_state -->|"loads variables"| node_process_env
node_fm -->|"reads and writes"| node_filesystem
node_fm -->|"draws and reads keys"| node_terminal
node_loop -->|"reads and prints"| node_terminal

click node_loop "https://github.com/luca-python/rust-shell/blob/main/src/main.rs"
click node_parser "https://github.com/luca-python/rust-shell/blob/main/src/parser.rs"
click node_classifier "https://github.com/luca-python/rust-shell/blob/main/src/parser.rs"
click node_state "https://github.com/luca-python/rust-shell/blob/main/src/state.rs"
click node_builtins "https://github.com/luca-python/rust-shell/blob/main/src/builtins.rs"
click node_fm "https://github.com/luca-python/rust-shell/blob/main/src/fm.rs"

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_user toneBlue
class node_parser,node_classifier toneAmber
class node_state,node_builtins toneMint
class node_fm toneRose
class node_terminal,node_filesystem,node_process_env toneIndigo
```

## Components

### Shell interaction

- [Shell loop](https://github.com/luca-python/rust-shell/blob/main/src/main.rs): `src/main.rs`

### Command processing

- [Line parser](https://github.com/luca-python/rust-shell/blob/main/src/parser.rs): `src/parser.rs`
- [Command classifier](https://github.com/luca-python/rust-shell/blob/main/src/parser.rs): `src/parser.rs`

### Shell facilities

- [Shell state](https://github.com/luca-python/rust-shell/blob/main/src/state.rs): `src/state.rs`
- [Builtins](https://github.com/luca-python/rust-shell/blob/main/src/builtins.rs): `src/builtins.rs`

### File editor

- [File editor](https://github.com/luca-python/rust-shell/blob/main/src/fm.rs): `src/fm.rs`

### Other components

- **Shell user**
- **Terminal I/O**
- **Filesystem**
- **Process environment**

## Connections

- Shell user → Shell loop: enters commands (evidence: `src/main.rs`)
- Shell loop → Line parser: parses line (evidence: `src/main.rs`)
- Shell loop → Shell state: expands variables (evidence: `src/main.rs`)
- Shell loop → Command classifier: identifies command (evidence: `src/main.rs`)
- Shell loop → Builtins: dispatches builtins (evidence: `src/main.rs`)
- Shell loop → File editor: dispatches editor (evidence: `src/main.rs`)
- Builtins → Shell state: reads and updates (evidence: `src/builtins.rs`)
- Shell state → Process environment: loads variables (evidence: `src/state.rs`)
- File editor → Filesystem: reads and writes (evidence: `src/fm.rs`)
- File editor → Terminal I/O: draws and reads keys (evidence: `src/fm.rs`)
- Shell loop → Terminal I/O: reads and prints (evidence: `src/main.rs`)
