# mharcerz/microshell architecture

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

- Interactive diagram: https://gitdiagram.com/mharcerz/microshell
- Repository: https://github.com/mharcerz/microshell

## Overview

Microshell is a small interactive Linux shell. Its main workflow is to show a user-and-directory prompt, read a command with Readline, split it into arguments, and either handle a supported command or run an external program. The README also advertises command history, completion, colored output, signal handling, and quoted arguments. The source excerpt confirms the prompt, history, parsing, signal setup, and external execution; omitted portions prevent verifying the internal dispatch paths for individual built-ins.

Main entry points: [`microshell.c`](https://github.com/mharcerz/microshell/blob/main/microshell.c) (Shell loop)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_interaction["Interactive shell"]
  node_shell_loop["Shell loop<br/>[microshell.c]"]
  node_prompt["Prompt and identity<br/>[microshell.c]"]
  node_readline["Readline input<br/>[microshell.c]"]
  node_history["Command history<br/>[microshell.c]"]
  node_completion["Syntax completion<br/>[microshell.c]"]
end

subgraph group_commands["Command handling"]
  node_parser["Argument parser<br/>[microshell.c]"]
  node_builtins["Shell built-ins<br/>[microshell.c]"]
  node_cut["Cut command<br/>[microshell.c]"]
  node_calendar["Calendar command<br/>[microshell.c]"]
  node_help["Help output<br/>[microshell.c]"]
end

subgraph group_execution["System execution"]
  node_signal_handler["Signal handling<br/>[microshell.c]"]
  node_external_program["External programs"]
end

node_user(("Shell user"))

node_user -->|"starts shell"| node_shell_loop
node_shell_loop -->|"shows prompt"| node_prompt
node_shell_loop -->|"reads command"| node_readline
node_readline -->|"records input"| node_history
node_readline -.->|"supports completion"| node_completion
node_shell_loop -->|"splits command"| node_parser
node_parser -.->|"dispatches command"| node_builtins
node_builtins -.->|"dispatches cut"| node_cut
node_builtins -.->|"dispatches cal"| node_calendar
node_builtins -.->|"prints help"| node_help
node_parser -->|"executes unsupported"| node_external_program
node_shell_loop -->|"registers signals"| node_signal_handler

click node_shell_loop "https://github.com/mharcerz/microshell/blob/main/microshell.c"
click node_prompt "https://github.com/mharcerz/microshell/blob/main/microshell.c"
click node_readline "https://github.com/mharcerz/microshell/blob/main/microshell.c"
click node_history "https://github.com/mharcerz/microshell/blob/main/microshell.c"
click node_completion "https://github.com/mharcerz/microshell/blob/main/microshell.c"
click node_parser "https://github.com/mharcerz/microshell/blob/main/microshell.c"
click node_builtins "https://github.com/mharcerz/microshell/blob/main/microshell.c"
click node_cut "https://github.com/mharcerz/microshell/blob/main/microshell.c"
click node_calendar "https://github.com/mharcerz/microshell/blob/main/microshell.c"
click node_help "https://github.com/mharcerz/microshell/blob/main/microshell.c"
click node_signal_handler "https://github.com/mharcerz/microshell/blob/main/microshell.c"

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_loop,node_prompt,node_readline,node_history,node_completion,node_user toneBlue
class node_parser,node_builtins,node_cut,node_calendar,node_help toneAmber
class node_signal_handler,node_external_program toneMint
```

## Components

### Interactive shell

- [Shell loop](https://github.com/mharcerz/microshell/blob/main/microshell.c): `microshell.c`
- [Prompt and identity](https://github.com/mharcerz/microshell/blob/main/microshell.c): `microshell.c`
- [Readline input](https://github.com/mharcerz/microshell/blob/main/microshell.c): `microshell.c`
- [Command history](https://github.com/mharcerz/microshell/blob/main/microshell.c): `microshell.c`
- [Syntax completion](https://github.com/mharcerz/microshell/blob/main/microshell.c): `microshell.c`

### Command handling

- [Argument parser](https://github.com/mharcerz/microshell/blob/main/microshell.c): `microshell.c`
- [Shell built-ins](https://github.com/mharcerz/microshell/blob/main/microshell.c): `microshell.c`
- [Cut command](https://github.com/mharcerz/microshell/blob/main/microshell.c): `microshell.c`
- [Calendar command](https://github.com/mharcerz/microshell/blob/main/microshell.c): `microshell.c`
- [Help output](https://github.com/mharcerz/microshell/blob/main/microshell.c): `microshell.c`

### System execution

- [Signal handling](https://github.com/mharcerz/microshell/blob/main/microshell.c): `microshell.c`
- **External programs**

### Other components

- **Shell user**

## Connections

- Shell user → Shell loop: starts shell (evidence: `README.md`)
- Shell loop → Prompt and identity: shows prompt (evidence: `microshell.c`)
- Shell loop → Readline input: reads command (evidence: `microshell.c`)
- Readline input → Command history: records input (evidence: `microshell.c`)
- Readline input → Syntax completion: supports completion (evidence: `README.md`)
- Shell loop → Argument parser: splits command (evidence: `microshell.c`)
- Argument parser → Shell built-ins: dispatches command (evidence: `microshell.c`)
- Shell built-ins → Cut command: dispatches cut (evidence: `microshell.c`)
- Shell built-ins → Calendar command: dispatches cal (evidence: `microshell.c`)
- Shell built-ins → Help output: prints help (evidence: `microshell.c`)
- Argument parser → External programs: executes unsupported (evidence: `microshell.c`)
- Shell loop → Signal handling: registers signals (evidence: `microshell.c`)
