# shigosag/mini-shell architecture

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

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

## Overview

Mini Shell is an interactive C command-line shell. Its principal runtime path is the user entering a line, the shell handling its loop-level exit/clear cases or dispatching it to command handling, and command handling invoking built-ins or passing other input to the host system. Parsing and history/logging are additional capabilities. The README describes an executor stage, but the sampled command handler parses and discards the parsed result; the separate executor implementation was not excerpted, so its runtime role is uncertain.

Main entry points: [`src/command.c`](https://github.com/shigosag/mini-shell/blob/main/src/command.c) (Command handler), [`src/shell.c`](https://github.com/shigosag/mini-shell/blob/main/src/shell.c) (Interactive shell), [`src/history.c`](https://github.com/shigosag/mini-shell/blob/main/src/history.c) (Command history), [`src/main.c`](https://github.com/shigosag/mini-shell/blob/main/src/main.c) (Program entry)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_interface["Shell Interface"]
  node_entry["Program entry<br/>[main.c]"]
  node_shell["Interactive shell<br/>[shell.c]"]
end

subgraph group_commands["Command Handling"]
  node_command["Command handler<br/>[command.c]"]
  node_parser["Input parser<br/>[parser.c]"]
  node_executor["Command executor<br/>[executor.c]"]
end

subgraph group_support["Shell Services"]
  node_history["Command history<br/>[history.c]"]
  node_logger["Command logger<br/>[logger.c]"]
end

node_user(("Shell user"))
node_system["Host command system"]
node_terminal["Terminal output"]

node_user -->|"enters commands"| node_shell
node_entry -->|"starts shell"| node_shell
node_shell -->|"reads input"| node_user
node_shell -->|"dispatches input"| node_command
node_command -->|"parses input"| node_parser
node_command -->|"runs raw command"| node_system
node_command -->|"records command"| node_history
node_command -->|"shows history"| node_history
node_command -->|"logs command"| node_logger
node_shell -->|"prints interface"| node_terminal

click node_entry "https://github.com/shigosag/mini-shell/blob/main/src/main.c"
click node_shell "https://github.com/shigosag/mini-shell/blob/main/src/shell.c"
click node_command "https://github.com/shigosag/mini-shell/blob/main/src/command.c"
click node_parser "https://github.com/shigosag/mini-shell/blob/main/src/parser.c"
click node_executor "https://github.com/shigosag/mini-shell/blob/main/src/executor.c"
click node_history "https://github.com/shigosag/mini-shell/blob/main/src/history.c"
click node_logger "https://github.com/shigosag/mini-shell/blob/main/src/logger.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_entry,node_shell,node_user toneBlue
class node_command,node_parser,node_executor toneAmber
class node_history,node_logger toneMint
class node_system,node_terminal toneIndigo
```

## Components

### Shell Interface

- [Program entry](https://github.com/shigosag/mini-shell/blob/main/src/main.c): `src/main.c`
- [Interactive shell](https://github.com/shigosag/mini-shell/blob/main/src/shell.c): `src/shell.c`

### Command Handling

- [Command handler](https://github.com/shigosag/mini-shell/blob/main/src/command.c): `src/command.c`
- [Input parser](https://github.com/shigosag/mini-shell/blob/main/src/parser.c): `src/parser.c`
- [Command executor](https://github.com/shigosag/mini-shell/blob/main/src/executor.c): `src/executor.c`

### Shell Services

- [Command history](https://github.com/shigosag/mini-shell/blob/main/src/history.c): `src/history.c`
- [Command logger](https://github.com/shigosag/mini-shell/blob/main/src/logger.c): `src/logger.c`

### Other components

- **Shell user**
- **Host command system**
- **Terminal output**

## Connections

- Shell user → Interactive shell: enters commands (evidence: `README.md`)
- Program entry → Interactive shell: starts shell (evidence: `src/main.c`)
- Interactive shell → Shell user: reads input (evidence: `src/shell.c`)
- Interactive shell → Command handler: dispatches input (evidence: `src/shell.c`)
- Command handler → Input parser: parses input (evidence: `src/command.c`)
- Command handler → Host command system: runs raw command (evidence: `src/command.c`)
- Command handler → Command history: records command (evidence: `src/command.c`)
- Command handler → Command history: shows history (evidence: `src/command.c`)
- Command handler → Command logger: logs command (evidence: `src/command.c`)
- Interactive shell → Terminal output: prints interface (evidence: `src/shell.c`)
