# abdullahmahfouz/shell architecture

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

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

## Overview

My Shell is an interactive C# command-line shell. The main workflow reads a line from the terminal, parses it into commands, dispatches built-ins or external programs, and returns output to the terminal; pipelines and redirects extend execution. Separate user-facing capabilities include history navigation and tab completion. The sampled files support the parser, dispatch, history, PATH search, and parts of pipeline execution; the main loop, navigation, and redirection implementation are represented by their paths and documented behavior, but their internal wiring is not assumed beyond the evident workflow.

Main entry points: [`src/Builtins/Builtins.cs`](https://github.com/abdullahmahfouz/shell/blob/main/src/Builtins/Builtins.cs) (Built-in commands), [`src/Shell/ProcessCommands.cs`](https://github.com/abdullahmahfouz/shell/blob/main/src/Shell/ProcessCommands.cs) (Command dispatch), [`src/Shell/Shell.cs`](https://github.com/abdullahmahfouz/shell/blob/main/src/Shell/Shell.cs) (Shell loop), [`src/Shell/AutoCompletion.cs`](https://github.com/abdullahmahfouz/shell/blob/main/src/Shell/AutoCompletion.cs) (Tab completion)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_interaction["Shell interaction"]
  node_shell["Shell loop<br/>[Shell.cs]"]
  node_completion["Tab completion<br/>[AutoCompletion.cs]"]
  node_historynav["History navigation"]
end

subgraph group_parsing["Command parsing"]
  node_parser["Command parser"]
  node_command["Command model<br/>[Command.cs]"]
  node_pipeline["Pipeline model<br/>[Pipeline.cs]"]
end

subgraph group_execution["Command execution"]
  node_dispatcher["Command dispatch<br/>[ProcessCommands.cs]"]
  node_pipeline_runner["Pipeline runner<br/>[PipelineRunner.cs]"]
  node_redirection["Output redirection"]
  node_process_runner["External process runner<br/>[ProcessRunner.cs]"]
end

subgraph group_builtins["Built-in features"]
  node_builtins["Built-in commands<br/>[Builtins.cs]"]
  node_navigation["Directory navigation<br/>[Navigation.cs]"]
  node_history["Command history<br/>[History.cs]"]
end

subgraph group_environment["System environment"]
  node_path_search["Executable search<br/>[SearchPath.cs]"]
  node_prefix["Prefix matching<br/>[LongestPrefix.cs]"]
  node_terminal(("Terminal"))
  node_filesystem[("Filesystem")]
  node_os_processes["External programs"]
end

node_user(("Shell user"))

node_user -->|"enters commands"| node_shell
node_shell -->|"reads input"| node_completion
node_completion -->|"searches PATH"| node_path_search
node_completion -->|"matches built-ins"| node_builtins
node_completion -->|"finds common prefix"| node_prefix
node_completion -->|"handles arrows"| node_historynav
node_historynav -->|"reads history"| node_history
node_shell -->|"submits line"| node_parser
node_parser -->|"creates commands"| node_command
node_parser -->|"creates pipeline"| node_pipeline
node_shell -->|"dispatches input"| node_dispatcher
node_dispatcher -->|"parses input"| node_parser
node_dispatcher -->|"runs pipeline"| node_pipeline_runner
node_dispatcher -->|"runs built-ins"| node_builtins
node_dispatcher -->|"runs external command"| node_process_runner
node_dispatcher -->|"applies redirects"| node_redirection
node_pipeline_runner -->|"runs pipeline built-ins"| node_builtins
node_pipeline_runner -->|"starts processes"| node_os_processes
node_process_runner -->|"locates executable"| node_path_search
node_process_runner -->|"starts program"| node_os_processes
node_builtins -->|"resolves type"| node_path_search
node_builtins -->|"changes directory"| node_navigation
node_builtins -->|"manages history"| node_history
node_history -->|"reads and writes"| node_filesystem
node_redirection -->|"writes output"| node_filesystem
node_builtins -->|"reads cat files"| node_filesystem
node_shell -->|"reads and prints"| node_terminal
node_os_processes -->|"produces output"| node_terminal

click node_shell "https://github.com/abdullahmahfouz/shell/blob/main/src/Shell/Shell.cs"
click node_completion "https://github.com/abdullahmahfouz/shell/blob/main/src/Shell/AutoCompletion.cs"
click node_historynav "https://github.com/abdullahmahfouz/shell/blob/main/src/Shell/HistoryNavigation.cs"
click node_parser "https://github.com/abdullahmahfouz/shell/blob/main/src/Parsing/CommandLineParser.cs"
click node_command "https://github.com/abdullahmahfouz/shell/blob/main/src/Parsing/Command.cs"
click node_pipeline "https://github.com/abdullahmahfouz/shell/blob/main/src/Parsing/Pipeline.cs"
click node_dispatcher "https://github.com/abdullahmahfouz/shell/blob/main/src/Shell/ProcessCommands.cs"
click node_pipeline_runner "https://github.com/abdullahmahfouz/shell/blob/main/src/Execution/PipelineRunner.cs"
click node_redirection "https://github.com/abdullahmahfouz/shell/blob/main/src/Execution/OutputRedirection.cs"
click node_process_runner "https://github.com/abdullahmahfouz/shell/blob/main/src/Execution/ProcessRunner.cs"
click node_builtins "https://github.com/abdullahmahfouz/shell/blob/main/src/Builtins/Builtins.cs"
click node_navigation "https://github.com/abdullahmahfouz/shell/blob/main/src/Builtins/Navigation.cs"
click node_history "https://github.com/abdullahmahfouz/shell/blob/main/src/Builtins/History.cs"
click node_path_search "https://github.com/abdullahmahfouz/shell/blob/main/src/Execution/SearchPath.cs"
click node_prefix "https://github.com/abdullahmahfouz/shell/blob/main/src/Utils/LongestPrefix.cs"

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_completion,node_historynav,node_user toneBlue
class node_parser,node_command,node_pipeline toneAmber
class node_dispatcher,node_pipeline_runner,node_redirection,node_process_runner toneMint
class node_builtins,node_navigation,node_history toneRose
class node_path_search,node_prefix,node_terminal,node_filesystem,node_os_processes toneIndigo
```

## Components

### Shell interaction

- [Shell loop](https://github.com/abdullahmahfouz/shell/blob/main/src/Shell/Shell.cs): `src/Shell/Shell.cs`
- [Tab completion](https://github.com/abdullahmahfouz/shell/blob/main/src/Shell/AutoCompletion.cs): `src/Shell/AutoCompletion.cs`
- [History navigation](https://github.com/abdullahmahfouz/shell/blob/main/src/Shell/HistoryNavigation.cs): `src/Shell/HistoryNavigation.cs`

### Command parsing

- [Command parser](https://github.com/abdullahmahfouz/shell/blob/main/src/Parsing/CommandLineParser.cs): `src/Parsing/CommandLineParser.cs`
- [Command model](https://github.com/abdullahmahfouz/shell/blob/main/src/Parsing/Command.cs): `src/Parsing/Command.cs`
- [Pipeline model](https://github.com/abdullahmahfouz/shell/blob/main/src/Parsing/Pipeline.cs): `src/Parsing/Pipeline.cs`

### Command execution

- [Command dispatch](https://github.com/abdullahmahfouz/shell/blob/main/src/Shell/ProcessCommands.cs): `src/Shell/ProcessCommands.cs`
- [Pipeline runner](https://github.com/abdullahmahfouz/shell/blob/main/src/Execution/PipelineRunner.cs): `src/Execution/PipelineRunner.cs`
- [Output redirection](https://github.com/abdullahmahfouz/shell/blob/main/src/Execution/OutputRedirection.cs): `src/Execution/OutputRedirection.cs`
- [External process runner](https://github.com/abdullahmahfouz/shell/blob/main/src/Execution/ProcessRunner.cs): `src/Execution/ProcessRunner.cs`

### Built-in features

- [Built-in commands](https://github.com/abdullahmahfouz/shell/blob/main/src/Builtins/Builtins.cs): `src/Builtins/Builtins.cs`
- [Directory navigation](https://github.com/abdullahmahfouz/shell/blob/main/src/Builtins/Navigation.cs): `src/Builtins/Navigation.cs`
- [Command history](https://github.com/abdullahmahfouz/shell/blob/main/src/Builtins/History.cs): `src/Builtins/History.cs`

### System environment

- [Executable search](https://github.com/abdullahmahfouz/shell/blob/main/src/Execution/SearchPath.cs): `src/Execution/SearchPath.cs`
- [Prefix matching](https://github.com/abdullahmahfouz/shell/blob/main/src/Utils/LongestPrefix.cs): `src/Utils/LongestPrefix.cs`
- **Terminal**
- **Filesystem**
- **External programs**

### Other components

- **Shell user**

## Connections

- Shell user → Shell loop: enters commands
- Shell loop → Tab completion: reads input
- Tab completion → Executable search: searches PATH
- Tab completion → Built-in commands: matches built-ins
- Tab completion → Prefix matching: finds common prefix
- Tab completion → History navigation: handles arrows
- History navigation → Command history: reads history
- Shell loop → Command parser: submits line
- Command parser → Command model: creates commands
- Command parser → Pipeline model: creates pipeline
- Shell loop → Command dispatch: dispatches input
- Command dispatch → Command parser: parses input
- Command dispatch → Pipeline runner: runs pipeline
- Command dispatch → Built-in commands: runs built-ins
- Command dispatch → External process runner: runs external command
- Command dispatch → Output redirection: applies redirects
- Pipeline runner → Built-in commands: runs pipeline built-ins
- Pipeline runner → External programs: starts processes
- External process runner → Executable search: locates executable
- External process runner → External programs: starts program
- Built-in commands → Executable search: resolves type
- Built-in commands → Directory navigation: changes directory
- Built-in commands → Command history: manages history
- Command history → Filesystem: reads and writes
- Output redirection → Filesystem: writes output
- Built-in commands → Filesystem: reads cat files
- Shell loop → Terminal: reads and prints
- External programs → Terminal: produces output
