# louka2b/minishell architecture

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

- Interactive diagram: https://gitdiagram.com/louka2b/minishell
- Repository: https://github.com/louka2b/minishell
- Video tour (about a minute): https://gitdiagram.com/louka2b/minishell/video

## Overview

Minishell is a compact Unix command interpreter. Its documented workflow accepts commands, parses and tokenizes them, expands environment variables, prepares commands and redirections, then executes processes with pipes and builtins while maintaining shell environment state. The README establishes the product capabilities; several implementation files were not sampled, so internal handoffs without direct evidence are shown as unverified dashed links.

Main entry points: [`src/minishell.c`](https://github.com/louka2b/minishell/blob/master/src/minishell.c) (Shell entry), [`src/executeur.c`](https://github.com/louka2b/minishell/blob/master/src/executeur.c) (Execution coordinator), [`src/executeur_child.c`](https://github.com/louka2b/minishell/blob/master/src/executeur_child.c) (Child execution), [`src/token.c`](https://github.com/louka2b/minishell/blob/master/src/token.c) (Tokenization)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_input["Input and parsing"]
  node_shell["Shell entry<br/>[minishell.c]"]
  node_prompt["Prompt input<br/>[prompt.c]"]
  node_tokenize["Tokenization<br/>[token.c]"]
  node_token_split["Token splitting<br/>[token_split.c]"]
  node_expand["Variable expansion<br/>[variable_extend.c]"]
  node_arguments["Argument handling<br/>[args.c]"]
  node_commands["Command parsing<br/>[parse_cmd.c]"]
  node_file_parse["Redirection parsing<br/>[parse_files.c]"]
end

subgraph group_execution["Execution"]
  node_executor["Execution coordinator<br/>[executeur.c]"]
  node_pipes["Pipe management<br/>[executeur_pipes.c]"]
  node_child["Child execution<br/>[executeur_child.c]"]
  node_redirections["Redirection setup<br/>[executeur_redirs.c]"]
  node_open_files["Open redirections<br/>[open_file.c]"]
  node_heredoc["Here documents<br/>[heredoc.c]"]
end

subgraph group_state["Shell state"]
  node_builtins["Builtins<br/>[builtin.c]"]
  node_environment[("Environment table<br/>[env.c]")]
  node_env_updates["Environment updates<br/>[env_more.c]"]
end

subgraph group_runtime["Runtime support"]
  node_signals["Signal behavior<br/>[prompt.c]"]
  node_libft["C utility library<br/>[ft_split.c]"]
end

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

node_user -->|"runs"| node_shell
node_shell -.->|"reads input"| node_prompt
node_prompt -.->|"submits command"| node_tokenize
node_tokenize -.->|"splits tokens"| node_token_split
node_tokenize -.->|"expands variables"| node_expand
node_expand -.->|"reads values"| node_environment
node_token_split -.->|"prepares arguments"| node_arguments
node_arguments -.->|"builds commands"| node_commands
node_commands -.->|"parses redirections"| node_file_parse
node_shell -.->|"executes commands"| node_executor
node_executor -.->|"manages pipes"| node_pipes
node_executor -.->|"spawns processes"| node_child
node_child -.->|"applies redirections"| node_redirections
node_executor -.->|"opens files"| node_open_files
node_open_files -.->|"handles heredoc"| node_heredoc
node_child -.->|"dispatches builtins"| node_builtins
node_builtins -.->|"updates state"| node_environment
node_shell -.->|"handles signals"| node_signals
node_child -.->|"executes commands"| node_external
node_shell -.->|"uses utilities"| node_libft

click node_shell "https://github.com/louka2b/minishell/blob/master/src/minishell.c"
click node_prompt "https://github.com/louka2b/minishell/blob/master/src/prompt.c"
click node_tokenize "https://github.com/louka2b/minishell/blob/master/src/token.c"
click node_token_split "https://github.com/louka2b/minishell/blob/master/src/token_split.c"
click node_expand "https://github.com/louka2b/minishell/blob/master/src/variable_extend.c"
click node_arguments "https://github.com/louka2b/minishell/blob/master/src/args.c"
click node_commands "https://github.com/louka2b/minishell/blob/master/src/utils/parse_cmd.c"
click node_file_parse "https://github.com/louka2b/minishell/blob/master/src/utils/parse_files.c"
click node_executor "https://github.com/louka2b/minishell/blob/master/src/executeur.c"
click node_pipes "https://github.com/louka2b/minishell/blob/master/src/executeur_pipes.c"
click node_child "https://github.com/louka2b/minishell/blob/master/src/executeur_child.c"
click node_redirections "https://github.com/louka2b/minishell/blob/master/src/executeur_redirs.c"
click node_open_files "https://github.com/louka2b/minishell/blob/master/src/open_file.c"
click node_heredoc "https://github.com/louka2b/minishell/blob/master/src/heredoc.c"
click node_builtins "https://github.com/louka2b/minishell/blob/master/src/utils/builtin.c"
click node_environment "https://github.com/louka2b/minishell/blob/master/src/env.c"
click node_env_updates "https://github.com/louka2b/minishell/blob/master/src/env_more.c"
click node_signals "https://github.com/louka2b/minishell/blob/master/src/prompt.c"
click node_libft "https://github.com/louka2b/minishell/blob/master/src/libft/ft_split.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,node_prompt,node_tokenize,node_token_split,node_expand,node_arguments,node_commands,node_file_parse,node_user toneBlue
class node_executor,node_pipes,node_child,node_redirections,node_open_files,node_heredoc toneAmber
class node_builtins,node_environment,node_env_updates toneMint
class node_signals,node_libft toneRose
class node_external toneIndigo
```

## Components

### Input and parsing

- [Shell entry](https://github.com/louka2b/minishell/blob/master/src/minishell.c): `src/minishell.c`
- [Prompt input](https://github.com/louka2b/minishell/blob/master/src/prompt.c): `src/prompt.c`
- [Tokenization](https://github.com/louka2b/minishell/blob/master/src/token.c): `src/token.c`
- [Token splitting](https://github.com/louka2b/minishell/blob/master/src/token_split.c): `src/token_split.c`
- [Variable expansion](https://github.com/louka2b/minishell/blob/master/src/variable_extend.c): `src/variable_extend.c`
- [Argument handling](https://github.com/louka2b/minishell/blob/master/src/args.c): `src/args.c`
- [Command parsing](https://github.com/louka2b/minishell/blob/master/src/utils/parse_cmd.c): `src/utils/parse_cmd.c`
- [Redirection parsing](https://github.com/louka2b/minishell/blob/master/src/utils/parse_files.c): `src/utils/parse_files.c`

### Execution

- [Execution coordinator](https://github.com/louka2b/minishell/blob/master/src/executeur.c): `src/executeur.c`
- [Pipe management](https://github.com/louka2b/minishell/blob/master/src/executeur_pipes.c): `src/executeur_pipes.c`
- [Child execution](https://github.com/louka2b/minishell/blob/master/src/executeur_child.c): `src/executeur_child.c`
- [Redirection setup](https://github.com/louka2b/minishell/blob/master/src/executeur_redirs.c): `src/executeur_redirs.c`
- [Open redirections](https://github.com/louka2b/minishell/blob/master/src/open_file.c): `src/open_file.c`
- [Here documents](https://github.com/louka2b/minishell/blob/master/src/heredoc.c): `src/heredoc.c`

### Shell state

- [Builtins](https://github.com/louka2b/minishell/blob/master/src/utils/builtin.c): `src/utils/builtin.c`
- [Environment table](https://github.com/louka2b/minishell/blob/master/src/env.c): `src/env.c`
- [Environment updates](https://github.com/louka2b/minishell/blob/master/src/env_more.c): `src/env_more.c`

### Runtime support

- [Signal behavior](https://github.com/louka2b/minishell/blob/master/src/prompt.c): `src/prompt.c`
- [C utility library](https://github.com/louka2b/minishell/blob/master/src/libft/ft_split.c): `src/libft/ft_split.c`

### Other components

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

## Connections

- Shell user → Shell entry: runs (evidence: `README.md`)
- Shell entry → Prompt input: reads input
- Prompt input → Tokenization: submits command
- Tokenization → Token splitting: splits tokens
- Tokenization → Variable expansion: expands variables
- Variable expansion → Environment table: reads values
- Token splitting → Argument handling: prepares arguments
- Argument handling → Command parsing: builds commands
- Command parsing → Redirection parsing: parses redirections
- Shell entry → Execution coordinator: executes commands
- Execution coordinator → Pipe management: manages pipes
- Execution coordinator → Child execution: spawns processes
- Child execution → Redirection setup: applies redirections
- Execution coordinator → Open redirections: opens files
- Open redirections → Here documents: handles heredoc
- Child execution → Builtins: dispatches builtins
- Builtins → Environment table: updates state
- Shell entry → Signal behavior: handles signals
- Child execution → External commands: executes commands
- Shell entry → C utility library: uses utilities
