# myivanov-c/minishell architecture

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

- Interactive diagram: https://gitdiagram.com/myivanov-c/minishell
- Repository: https://github.com/myivanov-c/minishell

## Overview

Minishell is an interactive C shell. Its main workflow reads a command line, tokenizes and validates it, builds a command tree, then expands and executes commands with redirections, pipes, and built-ins. The graph also preserves documented shell capabilities such as heredocs, logical operators, environment handling, and signals. Some subsystem links rely on the README because their implementation files were not sampled; those relationships are cited to the README rather than presented as inspected source behavior.

Main entry points: [`exec_cmdtree/exec_cmdtree.c`](https://github.com/myivanov-c/minishell/blob/main/exec_cmdtree/exec_cmdtree.c) (Tree dispatcher), [`get_cmdtree/tokenize.c`](https://github.com/myivanov-c/minishell/blob/main/get_cmdtree/tokenize.c) (Tokenize input), [`exec_cmdtree/expand/expand.c`](https://github.com/myivanov-c/minishell/blob/main/exec_cmdtree/expand/expand.c) (Expansion), [`minishell.c`](https://github.com/myivanov-c/minishell/blob/main/minishell.c) (Interactive input)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_input["Input and parsing"]
  node_readline["Interactive input<br/>[minishell.c]"]
  node_tokenize["Tokenize input<br/>[tokenize.c]"]
  node_syntax["Syntax checks"]
  node_tree["Command tree<br/>[create_cmdtree.c]"]
  node_heredoc["Heredoc collection<br/>[here_doc.c]"]
  node_tokenutils["Quote-aware tokens"]
end

subgraph group_execution["Execution"]
  node_dispatcher["Tree dispatcher<br/>[exec_cmdtree.c]"]
  node_expand["Expansion<br/>[expand.c]"]
  node_envexpand["Variable expansion<br/>[get_expanded_env.c]"]
  node_wildcards["Wildcard matching"]
  node_redirect["Redirections<br/>[redirect.c]"]
  node_pipes["Pipe execution<br/>[exec_pipe.c]"]
  node_control["Logical and groups<br/>[exec_control.c]"]
  node_command["Command execution<br/>[exec_cmd.c]"]
end

subgraph group_shellstate["Shell state and built-ins"]
  node_builtinrouter["Built-in dispatch<br/>[builtin.c]"]
  node_builtins["Built-in commands"]
  node_environment["Environment state<br/>[minishell.c]"]
  node_signals["Signal handling<br/>[minishell.c]"]
end

subgraph group_support["Runtime support"]
  node_libft["Utility library<br/>[libft.h]"]
end

node_user(("Shell user"))
node_external["External commands"]

node_user -->|"enters commands"| node_readline
node_readline -->|"submits line"| node_tokenize
node_tokenize -.->|"checks tokens"| node_syntax
node_syntax -.->|"accepts valid input"| node_tree
node_tokenize -->|"builds command tree"| node_tree
node_tree -->|"collects heredocs"| node_heredoc
node_tokenize -->|"tracks quote flags"| node_tokenutils
node_dispatcher -->|"expands commands"| node_expand
node_expand -->|"expands variables"| node_envexpand
node_expand -->|"matches patterns"| node_wildcards
node_dispatcher -->|"applies redirections"| node_redirect
node_dispatcher -->|"dispatches pipes"| node_pipes
node_dispatcher -->|"dispatches operators"| node_control
node_dispatcher -.->|"executes leaves"| node_command
node_command -.->|"checks built-ins"| node_builtinrouter
node_command -.->|"runs external commands"| node_external
node_builtinrouter -->|"dispatches built-ins"| node_builtins
node_builtins -->|"manages variables"| node_environment
node_readline -->|"handles interrupts"| node_signals
node_expand -->|"reads variables"| node_environment
node_tokenize -.->|"uses utilities"| node_libft

click node_readline "https://github.com/myivanov-c/minishell/blob/main/minishell.c"
click node_tokenize "https://github.com/myivanov-c/minishell/blob/main/get_cmdtree/tokenize.c"
click node_syntax "https://github.com/myivanov-c/minishell/tree/main/get_cmdtree/check_syntax"
click node_tree "https://github.com/myivanov-c/minishell/blob/main/get_cmdtree/create_cmdtree/create_cmdtree.c"
click node_heredoc "https://github.com/myivanov-c/minishell/blob/main/get_cmdtree/here_doc.c"
click node_tokenutils "https://github.com/myivanov-c/minishell/tree/main/token_utils"
click node_dispatcher "https://github.com/myivanov-c/minishell/blob/main/exec_cmdtree/exec_cmdtree.c"
click node_expand "https://github.com/myivanov-c/minishell/blob/main/exec_cmdtree/expand/expand.c"
click node_envexpand "https://github.com/myivanov-c/minishell/blob/main/exec_cmdtree/expand/get_expanded_env.c"
click node_wildcards "https://github.com/myivanov-c/minishell/tree/main/exec_cmdtree/expand/Wildcards"
click node_redirect "https://github.com/myivanov-c/minishell/blob/main/exec_cmdtree/redirect.c"
click node_pipes "https://github.com/myivanov-c/minishell/blob/main/exec_cmdtree/exec_pipe.c"
click node_control "https://github.com/myivanov-c/minishell/blob/main/exec_cmdtree/exec_control.c"
click node_command "https://github.com/myivanov-c/minishell/blob/main/exec_cmdtree/exec_cmd.c"
click node_builtinrouter "https://github.com/myivanov-c/minishell/blob/main/exec_cmdtree/builtins/builtin.c"
click node_builtins "https://github.com/myivanov-c/minishell/tree/main/exec_cmdtree/builtins"
click node_environment "https://github.com/myivanov-c/minishell/blob/main/minishell.c"
click node_signals "https://github.com/myivanov-c/minishell/blob/main/minishell.c"
click node_libft "https://github.com/myivanov-c/minishell/blob/main/libft/libft.h"

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_readline,node_tokenize,node_syntax,node_tree,node_heredoc,node_tokenutils,node_user toneBlue
class node_dispatcher,node_expand,node_envexpand,node_wildcards,node_redirect,node_pipes,node_control,node_command toneAmber
class node_builtinrouter,node_builtins,node_environment,node_signals toneMint
class node_libft toneRose
class node_external toneIndigo
```

## Components

### Input and parsing

- [Interactive input](https://github.com/myivanov-c/minishell/blob/main/minishell.c): `minishell.c`
- [Tokenize input](https://github.com/myivanov-c/minishell/blob/main/get_cmdtree/tokenize.c): `get_cmdtree/tokenize.c`
- [Syntax checks](https://github.com/myivanov-c/minishell/tree/main/get_cmdtree/check_syntax): `get_cmdtree/check_syntax`
- [Command tree](https://github.com/myivanov-c/minishell/blob/main/get_cmdtree/create_cmdtree/create_cmdtree.c): `get_cmdtree/create_cmdtree/create_cmdtree.c`
- [Heredoc collection](https://github.com/myivanov-c/minishell/blob/main/get_cmdtree/here_doc.c): `get_cmdtree/here_doc.c`
- [Quote-aware tokens](https://github.com/myivanov-c/minishell/tree/main/token_utils): `token_utils`

### Execution

- [Tree dispatcher](https://github.com/myivanov-c/minishell/blob/main/exec_cmdtree/exec_cmdtree.c): `exec_cmdtree/exec_cmdtree.c`
- [Expansion](https://github.com/myivanov-c/minishell/blob/main/exec_cmdtree/expand/expand.c): `exec_cmdtree/expand/expand.c`
- [Variable expansion](https://github.com/myivanov-c/minishell/blob/main/exec_cmdtree/expand/get_expanded_env.c): `exec_cmdtree/expand/get_expanded_env.c`
- [Wildcard matching](https://github.com/myivanov-c/minishell/tree/main/exec_cmdtree/expand/Wildcards): `exec_cmdtree/expand/Wildcards`
- [Redirections](https://github.com/myivanov-c/minishell/blob/main/exec_cmdtree/redirect.c): `exec_cmdtree/redirect.c`
- [Pipe execution](https://github.com/myivanov-c/minishell/blob/main/exec_cmdtree/exec_pipe.c): `exec_cmdtree/exec_pipe.c`
- [Logical and groups](https://github.com/myivanov-c/minishell/blob/main/exec_cmdtree/exec_control.c): `exec_cmdtree/exec_control.c`
- [Command execution](https://github.com/myivanov-c/minishell/blob/main/exec_cmdtree/exec_cmd.c): `exec_cmdtree/exec_cmd.c`

### Shell state and built-ins

- [Built-in dispatch](https://github.com/myivanov-c/minishell/blob/main/exec_cmdtree/builtins/builtin.c): `exec_cmdtree/builtins/builtin.c`
- [Built-in commands](https://github.com/myivanov-c/minishell/tree/main/exec_cmdtree/builtins): `exec_cmdtree/builtins`
- [Environment state](https://github.com/myivanov-c/minishell/blob/main/minishell.c): `minishell.c`
- [Signal handling](https://github.com/myivanov-c/minishell/blob/main/minishell.c): `minishell.c`

### Runtime support

- [Utility library](https://github.com/myivanov-c/minishell/blob/main/libft/libft.h): `libft/libft.h`

### Other components

- **Shell user**
- **External commands**

## Connections

- Shell user → Interactive input: enters commands
- Interactive input → Tokenize input: submits line
- Tokenize input → Syntax checks: checks tokens
- Syntax checks → Command tree: accepts valid input
- Tokenize input → Command tree: builds command tree
- Command tree → Heredoc collection: collects heredocs
- Tokenize input → Quote-aware tokens: tracks quote flags
- Tree dispatcher → Expansion: expands commands
- Expansion → Variable expansion: expands variables
- Expansion → Wildcard matching: matches patterns
- Tree dispatcher → Redirections: applies redirections
- Tree dispatcher → Pipe execution: dispatches pipes
- Tree dispatcher → Logical and groups: dispatches operators
- Tree dispatcher → Command execution: executes leaves
- Command execution → Built-in dispatch: checks built-ins
- Command execution → External commands: runs external commands
- Built-in dispatch → Built-in commands: dispatches built-ins
- Built-in commands → Environment state: manages variables
- Interactive input → Signal handling: handles interrupts (evidence: `minishell.c`)
- Expansion → Environment state: reads variables
- Tokenize input → Utility library: uses utilities
