# table-en4/minishell architecture

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

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

## Overview

This repository is an interactive Unix shell: it reads commands, prepares a minibox representation, then executes commands while maintaining shell environment and status. Its command-processing stages include input setup, lexing, parsing (including expansion, wildcard handling, and redirections), and AST execution; shell builtins, configuration/aliases, and signal handling are distinct capabilities. The graph uses sampled code and the source index; several subsystem connections are omitted where their callers were not shown.

Main entry points: [`srcs/main.c`](https://github.com/table-en4/minishell/blob/main/srcs/main.c) (Shell loop), [`minibox/srcs/build.c`](https://github.com/table-en4/minishell/blob/main/minibox/srcs/build.c) (Command lifecycle), [`srcs/pipex/excute_minibox.c`](https://github.com/table-en4/minishell/blob/main/srcs/pipex/excute_minibox.c) (AST dispatcher), [`minibox/srcs/build_parsing.c`](https://github.com/table-en4/minishell/blob/main/minibox/srcs/build_parsing.c) (AST and syntax)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_shell["Shell runtime"]
  node_main["Shell loop<br/>[main.c]"]
  node_environment["Environment state<br/>[env_init.c]"]
  node_config["Config and aliases<br/>[config.c]"]
  node_signals["Signal handling<br/>[signals_setup.c]"]
end

subgraph group_build["Command construction"]
  node_minibox["Command lifecycle<br/>[build.c]"]
  node_input["Input setup<br/>[build_input.c]"]
  node_lexing["Lexing<br/>[build_lexing.c]"]
  node_parsing["AST and syntax<br/>[build_parsing.c]"]
  node_arguments["Argument expansion"]
  node_wildcards["Wildcard expansion"]
  node_redirections["Redirections and heredoc"]
end

subgraph group_exec["Execution"]
  node_executor["AST dispatcher<br/>[excute_minibox.c]"]
  node_commands["Command execution<br/>[exec_command.c]"]
  node_pipes["Pipeline execution<br/>[exec_pipe.c]"]
  node_external["External processes<br/>[exec_extern.c]"]
  node_builtins["Shell builtins<br/>[ft_export.c]"]
  node_env_builtins["Environment builtins<br/>[ft_unset.c]"]
end

subgraph group_support["Shell support"]
end

subgraph group_libft["Libft utilities"]
  node_libft["Libft<br/>[libft.h]"]
  node_printf["Formatted output<br/>[ft_dprintf.c]"]
  node_gnl["Line reader<br/>[get_next_line.c]"]
end

node_user(("Shell user"))
node_readline["Readline input"]

node_user -.->|"enters commands"| node_readline
node_readline -.->|"provides input"| node_main
node_main -->|"initializes"| node_environment
node_main -->|"loads config"| node_config
node_main -->|"sets up"| node_signals
node_main -->|"builds command"| node_minibox
node_main -->|"executes command"| node_executor
node_minibox -.->|"prepares input"| node_input
node_minibox -.->|"builds tokens"| node_lexing
node_minibox -.->|"builds AST"| node_parsing
node_parsing -->|"expands arguments"| node_arguments
node_parsing -->|"builds redirections"| node_redirections
node_arguments -.->|"expands patterns"| node_wildcards
node_executor -.->|"dispatches pipelines"| node_pipes
node_pipes -->|"executes AST sides"| node_executor
node_executor -.->|"dispatches commands"| node_commands
node_commands -.->|"runs external"| node_external
node_commands -.->|"runs builtins"| node_builtins
node_env_builtins -->|"updates variables"| node_environment
node_main -->|"reports status"| node_printf
node_main -.->|"uses utilities"| node_libft

click node_main "https://github.com/table-en4/minishell/blob/main/srcs/main.c"
click node_environment "https://github.com/table-en4/minishell/blob/main/srcs/builtins/env_init.c"
click node_config "https://github.com/table-en4/minishell/blob/main/srcs/config/config.c"
click node_signals "https://github.com/table-en4/minishell/blob/main/srcs/signals_setup.c"
click node_minibox "https://github.com/table-en4/minishell/blob/main/minibox/srcs/build.c"
click node_input "https://github.com/table-en4/minishell/blob/main/minibox/srcs/build_input.c"
click node_lexing "https://github.com/table-en4/minishell/blob/main/minibox/srcs/build_lexing.c"
click node_parsing "https://github.com/table-en4/minishell/blob/main/minibox/srcs/build_parsing.c"
click node_arguments "https://github.com/table-en4/minishell/blob/main/minibox/srcs/build_parsing_arguments_expand.c"
click node_wildcards "https://github.com/table-en4/minishell/blob/main/minibox/srcs/build_parsing_arguments_wildcard.c"
click node_redirections "https://github.com/table-en4/minishell/blob/main/minibox/srcs/build_parsing_redirection_heredoc.c"
click node_executor "https://github.com/table-en4/minishell/blob/main/srcs/pipex/excute_minibox.c"
click node_commands "https://github.com/table-en4/minishell/blob/main/srcs/pipex/exec_command.c"
click node_pipes "https://github.com/table-en4/minishell/blob/main/srcs/pipex/exec_pipe.c"
click node_external "https://github.com/table-en4/minishell/blob/main/srcs/exec_extern.c"
click node_builtins "https://github.com/table-en4/minishell/blob/main/srcs/builtins/ft_export.c"
click node_env_builtins "https://github.com/table-en4/minishell/blob/main/srcs/builtins/ft_unset.c"
click node_libft "https://github.com/table-en4/minishell/blob/main/Libft/incs/libft.h"
click node_printf "https://github.com/table-en4/minishell/blob/main/Libft/srcs/ft_dprintf/ft_dprintf.c"
click node_gnl "https://github.com/table-en4/minishell/blob/main/Libft/srcs/get_next_line/get_next_line.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_main,node_environment,node_config,node_signals,node_user toneBlue
class node_minibox,node_input,node_lexing,node_parsing,node_arguments,node_wildcards,node_redirections toneAmber
class node_executor,node_commands,node_pipes,node_external,node_builtins,node_env_builtins toneMint
class node_libft,node_printf,node_gnl,node_readline toneIndigo
```

## Components

### Shell runtime

- [Shell loop](https://github.com/table-en4/minishell/blob/main/srcs/main.c): `srcs/main.c`
- [Environment state](https://github.com/table-en4/minishell/blob/main/srcs/builtins/env_init.c): `srcs/builtins/env_init.c`
- [Config and aliases](https://github.com/table-en4/minishell/blob/main/srcs/config/config.c): `srcs/config/config.c`
- [Signal handling](https://github.com/table-en4/minishell/blob/main/srcs/signals_setup.c): `srcs/signals_setup.c`

### Command construction

- [Command lifecycle](https://github.com/table-en4/minishell/blob/main/minibox/srcs/build.c): `minibox/srcs/build.c`
- [Input setup](https://github.com/table-en4/minishell/blob/main/minibox/srcs/build_input.c): `minibox/srcs/build_input.c`
- [Lexing](https://github.com/table-en4/minishell/blob/main/minibox/srcs/build_lexing.c): `minibox/srcs/build_lexing.c`
- [AST and syntax](https://github.com/table-en4/minishell/blob/main/minibox/srcs/build_parsing.c): `minibox/srcs/build_parsing.c`
- [Argument expansion](https://github.com/table-en4/minishell/blob/main/minibox/srcs/build_parsing_arguments_expand.c): `minibox/srcs/build_parsing_arguments_expand.c`
- [Wildcard expansion](https://github.com/table-en4/minishell/blob/main/minibox/srcs/build_parsing_arguments_wildcard.c): `minibox/srcs/build_parsing_arguments_wildcard.c`
- [Redirections and heredoc](https://github.com/table-en4/minishell/blob/main/minibox/srcs/build_parsing_redirection_heredoc.c): `minibox/srcs/build_parsing_redirection_heredoc.c`

### Execution

- [AST dispatcher](https://github.com/table-en4/minishell/blob/main/srcs/pipex/excute_minibox.c): `srcs/pipex/excute_minibox.c`
- [Command execution](https://github.com/table-en4/minishell/blob/main/srcs/pipex/exec_command.c): `srcs/pipex/exec_command.c`
- [Pipeline execution](https://github.com/table-en4/minishell/blob/main/srcs/pipex/exec_pipe.c): `srcs/pipex/exec_pipe.c`
- [External processes](https://github.com/table-en4/minishell/blob/main/srcs/exec_extern.c): `srcs/exec_extern.c`
- [Shell builtins](https://github.com/table-en4/minishell/blob/main/srcs/builtins/ft_export.c): `srcs/builtins/ft_export.c`
- [Environment builtins](https://github.com/table-en4/minishell/blob/main/srcs/builtins/ft_unset.c): `srcs/builtins/ft_unset.c`

### Libft utilities

- [Libft](https://github.com/table-en4/minishell/blob/main/Libft/incs/libft.h): `Libft/incs/libft.h`
- [Formatted output](https://github.com/table-en4/minishell/blob/main/Libft/srcs/ft_dprintf/ft_dprintf.c): `Libft/srcs/ft_dprintf/ft_dprintf.c`
- [Line reader](https://github.com/table-en4/minishell/blob/main/Libft/srcs/get_next_line/get_next_line.c): `Libft/srcs/get_next_line/get_next_line.c`

### Other components

- **Shell user**
- **Readline input**

## Connections

- Shell user → Readline input: enters commands
- Readline input → Shell loop: provides input
- Shell loop → Environment state: initializes (evidence: `srcs/main.c`)
- Shell loop → Config and aliases: loads config (evidence: `srcs/main.c`)
- Shell loop → Signal handling: sets up (evidence: `srcs/main.c`)
- Shell loop → Command lifecycle: builds command (evidence: `srcs/main.c`)
- Shell loop → AST dispatcher: executes command (evidence: `srcs/main.c`)
- Command lifecycle → Input setup: prepares input
- Command lifecycle → Lexing: builds tokens
- Command lifecycle → AST and syntax: builds AST
- AST and syntax → Argument expansion: expands arguments (evidence: `minibox/srcs/build_parsing.c`)
- AST and syntax → Redirections and heredoc: builds redirections (evidence: `minibox/srcs/build_parsing.c`)
- Argument expansion → Wildcard expansion: expands patterns
- AST dispatcher → Pipeline execution: dispatches pipelines
- Pipeline execution → AST dispatcher: executes AST sides (evidence: `srcs/pipex/exec_pipe.c`)
- AST dispatcher → Command execution: dispatches commands
- Command execution → External processes: runs external
- Command execution → Shell builtins: runs builtins
- Environment builtins → Environment state: updates variables (evidence: `srcs/builtins/ft_unset.c`)
- Shell loop → Formatted output: reports status (evidence: `srcs/main.c`)
- Shell loop → Libft: uses utilities
