# thedixon11/minishell architecture

> Architecture diagram of the GitHub repository thedixon11/minishell, 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/thedixon11/minishell
- Repository: https://github.com/thedixon11/minishell

## Overview

Minishell is an interactive Unix-shell implementation. Its principal workflow reads a command line, tokenizes and validates shell syntax, expands quoting and environment references, prepares redirections and heredocs, then dispatches built-ins or external programs and reports status. The graph also preserves environment management, signal handling, and the supporting C utility library. The README documents the overall workflow and capabilities; several orchestration and execution files were not sampled, so uncertain internal handoffs are omitted rather than inferred.

Main entry points: [`src_parsing/minishell.c`](https://github.com/thedixon11/minishell/blob/main/src_parsing/minishell.c) (Interactive loop), [`src_xpand/val_manager.c`](https://github.com/thedixon11/minishell/blob/main/src_xpand/val_manager.c) (Value expansion), [`src_exec/execute_cmds.c`](https://github.com/thedixon11/minishell/blob/main/src_exec/execute_cmds.c) (Execution dispatch), [`src_parsing/to_token.c`](https://github.com/thedixon11/minishell/blob/main/src_parsing/to_token.c) (Tokenizer)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_input_parse["Input and parsing"]
  node_input_loop["Interactive loop<br/>[minishell.c]"]
  node_tokenizer["Tokenizer<br/>[to_token.c]"]
  node_syntax_check["Syntax validation<br/>[to_token_control.c]"]
  node_command_parse["Command parsing<br/>[to_parse.c]"]
  node_command_fusion["Command fusion"]
end

subgraph group_expansion["Expansion and environment"]
  node_value_expand["Value expansion<br/>[val_manager.c]"]
  node_quote_expand["Quote handling<br/>[quote_manager.c]"]
  node_dollar_expand["Dollar handling<br/>[dollar_manager.c]"]
  node_env_expand["Variable lookup<br/>[env_var_manager.c]"]
end

subgraph group_execution["Execution and I/O"]
  node_heredoc["Heredoc input<br/>[heredoc_exec.c]"]
  node_redirections["Redirections and pipes"]
  node_execution_dispatch["Execution dispatch<br/>[execute_cmds.c]"]
  node_external_exec["External commands<br/>[child_process.c]"]
  node_builtins["Built-in commands<br/>[builtin_exec.c]"]
end

subgraph group_shell_services["Shell services"]
  node_environment[("Shell environment<br/>[create_env.c]")]
  node_signals["Signal handling<br/>[signal.c]"]
  node_error_handling["Errors and cleanup<br/>[ft_error.c]"]
end

subgraph group_support["C utilities"]
  node_libft["Libft utilities<br/>[libft.h]"]
end

node_user(("Shell user"))
node_readline["Readline"]
node_programs["System executables"]

node_user -->|"enters commands"| node_input_loop
node_input_loop -->|"reads input"| node_readline
node_input_loop -->|"parses input"| node_tokenizer
node_tokenizer -->|"validates operators"| node_syntax_check
node_input_loop -.->|"builds commands"| node_command_parse
node_command_parse -.->|"fuses commands"| node_command_fusion
node_input_loop -->|"expands values"| node_value_expand
node_value_expand -->|"handles quotes"| node_quote_expand
node_quote_expand -->|"expands double quotes"| node_dollar_expand
node_dollar_expand -->|"looks up variables"| node_env_expand
node_value_expand -->|"reads variables"| node_environment
node_input_loop -->|"handles heredocs"| node_heredoc
node_input_loop -->|"executes commands"| node_execution_dispatch
node_execution_dispatch -.->|"applies redirections"| node_redirections
node_execution_dispatch -->|"dispatches built-ins"| node_builtins
node_execution_dispatch -->|"runs binaries"| node_external_exec
node_external_exec -->|"executes via PATH"| node_programs
node_builtins -.->|"updates environment"| node_environment
node_user -->|"sends signals"| node_signals
node_input_loop -.->|"reports failures"| node_error_handling
node_value_expand -->|"uses string utilities"| node_libft

click node_input_loop "https://github.com/thedixon11/minishell/blob/main/src_parsing/minishell.c"
click node_tokenizer "https://github.com/thedixon11/minishell/blob/main/src_parsing/to_token.c"
click node_syntax_check "https://github.com/thedixon11/minishell/blob/main/src_parsing/to_token_control.c"
click node_command_parse "https://github.com/thedixon11/minishell/blob/main/src_parsing/to_parse.c"
click node_command_fusion "https://github.com/thedixon11/minishell/blob/main/src_parsing/to_parse_fusion_cmd.c"
click node_value_expand "https://github.com/thedixon11/minishell/blob/main/src_xpand/val_manager.c"
click node_quote_expand "https://github.com/thedixon11/minishell/blob/main/src_xpand/quote_manager.c"
click node_dollar_expand "https://github.com/thedixon11/minishell/blob/main/src_xpand/dollar_manager.c"
click node_env_expand "https://github.com/thedixon11/minishell/blob/main/src_xpand/env_var_manager.c"
click node_heredoc "https://github.com/thedixon11/minishell/blob/main/src_heredoc/heredoc_exec.c"
click node_redirections "https://github.com/thedixon11/minishell/blob/main/src_exec/manage_redirections.c"
click node_execution_dispatch "https://github.com/thedixon11/minishell/blob/main/src_exec/execute_cmds.c"
click node_external_exec "https://github.com/thedixon11/minishell/blob/main/src_exec/child_process.c"
click node_builtins "https://github.com/thedixon11/minishell/blob/main/src_builtin/builtin_exec.c"
click node_environment "https://github.com/thedixon11/minishell/blob/main/src_parsing/create_env.c"
click node_signals "https://github.com/thedixon11/minishell/blob/main/src_signal/signal.c"
click node_error_handling "https://github.com/thedixon11/minishell/blob/main/src_errors/ft_error.c"
click node_libft "https://github.com/thedixon11/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_input_loop,node_tokenizer,node_syntax_check,node_command_parse,node_command_fusion,node_user toneBlue
class node_value_expand,node_quote_expand,node_dollar_expand,node_env_expand toneAmber
class node_heredoc,node_redirections,node_execution_dispatch,node_external_exec,node_builtins toneMint
class node_environment,node_signals,node_error_handling toneRose
class node_libft,node_readline,node_programs toneIndigo
```

## Components

### Input and parsing

- [Interactive loop](https://github.com/thedixon11/minishell/blob/main/src_parsing/minishell.c): `src_parsing/minishell.c`
- [Tokenizer](https://github.com/thedixon11/minishell/blob/main/src_parsing/to_token.c): `src_parsing/to_token.c`
- [Syntax validation](https://github.com/thedixon11/minishell/blob/main/src_parsing/to_token_control.c): `src_parsing/to_token_control.c`
- [Command parsing](https://github.com/thedixon11/minishell/blob/main/src_parsing/to_parse.c): `src_parsing/to_parse.c`
- [Command fusion](https://github.com/thedixon11/minishell/blob/main/src_parsing/to_parse_fusion_cmd.c): `src_parsing/to_parse_fusion_cmd.c`

### Expansion and environment

- [Value expansion](https://github.com/thedixon11/minishell/blob/main/src_xpand/val_manager.c): `src_xpand/val_manager.c`
- [Quote handling](https://github.com/thedixon11/minishell/blob/main/src_xpand/quote_manager.c): `src_xpand/quote_manager.c`
- [Dollar handling](https://github.com/thedixon11/minishell/blob/main/src_xpand/dollar_manager.c): `src_xpand/dollar_manager.c`
- [Variable lookup](https://github.com/thedixon11/minishell/blob/main/src_xpand/env_var_manager.c): `src_xpand/env_var_manager.c`

### Execution and I/O

- [Heredoc input](https://github.com/thedixon11/minishell/blob/main/src_heredoc/heredoc_exec.c): `src_heredoc/heredoc_exec.c`
- [Redirections and pipes](https://github.com/thedixon11/minishell/blob/main/src_exec/manage_redirections.c): `src_exec/manage_redirections.c`
- [Execution dispatch](https://github.com/thedixon11/minishell/blob/main/src_exec/execute_cmds.c): `src_exec/execute_cmds.c`
- [External commands](https://github.com/thedixon11/minishell/blob/main/src_exec/child_process.c): `src_exec/child_process.c`
- [Built-in commands](https://github.com/thedixon11/minishell/blob/main/src_builtin/builtin_exec.c): `src_builtin/builtin_exec.c`

### Shell services

- [Shell environment](https://github.com/thedixon11/minishell/blob/main/src_parsing/create_env.c): `src_parsing/create_env.c`
- [Signal handling](https://github.com/thedixon11/minishell/blob/main/src_signal/signal.c): `src_signal/signal.c`
- [Errors and cleanup](https://github.com/thedixon11/minishell/blob/main/src_errors/ft_error.c): `src_errors/ft_error.c`

### C utilities

- [Libft utilities](https://github.com/thedixon11/minishell/blob/main/libft/libft.h): `libft/libft.h`

### Other components

- **Shell user**
- **Readline**
- **System executables**

## Connections

- Shell user → Interactive loop: enters commands
- Interactive loop → Readline: reads input
- Interactive loop → Tokenizer: parses input
- Tokenizer → Syntax validation: validates operators (evidence: `src_parsing/to_token_control.c`)
- Interactive loop → Command parsing: builds commands
- Command parsing → Command fusion: fuses commands
- Interactive loop → Value expansion: expands values
- Value expansion → Quote handling: handles quotes (evidence: `src_xpand/val_manager.c`)
- Quote handling → Dollar handling: expands double quotes (evidence: `src_xpand/quote_manager.c`)
- Dollar handling → Variable lookup: looks up variables (evidence: `src_xpand/dollar_manager.c`)
- Value expansion → Shell environment: reads variables
- Interactive loop → Heredoc input: handles heredocs
- Interactive loop → Execution dispatch: executes commands
- Execution dispatch → Redirections and pipes: applies redirections
- Execution dispatch → Built-in commands: dispatches built-ins (evidence: `src_builtin/builtin_exec.c`)
- Execution dispatch → External commands: runs binaries
- External commands → System executables: executes via PATH
- Built-in commands → Shell environment: updates environment
- Shell user → Signal handling: sends signals
- Interactive loop → Errors and cleanup: reports failures
- Value expansion → Libft utilities: uses string utilities (evidence: `src_xpand/val_manager.c`)
