# rvnsenkuuu/minishell architecture

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

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

## Overview

Minishell is an interactive Unix command shell. Its principal workflow reads a line, transforms and lexes it into command/control structures, then executes commands and updates the shell’s exit status. Execution covers pipelines, logical operations, subshells, redirections, here-documents and built-ins; environment expansion, wildcard handling and signal behavior are separate runtime concerns. The README is empty, and sampled execution-preparation code is incomplete, so uncertain wiring—especially expansion and wildcard invocation—is omitted.

Main entry points: [`src/main.c`](https://github.com/rvnsenkuuu/minishell/blob/main/src/main.c) (Shell loop), [`src/lexer/lexer.c`](https://github.com/rvnsenkuuu/minishell/blob/main/src/lexer/lexer.c) (Lexer), [`src/exec/ft_exec_class.c`](https://github.com/rvnsenkuuu/minishell/blob/main/src/exec/ft_exec_class.c) (Execution dispatcher), [`src/exec/ft_exec_cmd.c`](https://github.com/rvnsenkuuu/minishell/blob/main/src/exec/ft_exec_cmd.c) (Command execution)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_shell["Shell lifecycle"]
  node_main["Shell loop<br/>[main.c]"]
end

subgraph group_parse["Input parsing"]
  node_transform["Line transform<br/>[ft_cmd_parsing.c]"]
  node_lexer["Lexer<br/>[lexer.c]"]
  node_command["Command construction<br/>[create_cmd.c]"]
  node_structures["Control structures<br/>[create_logic.c]"]
  node_pipes["Pipe parsing<br/>[create_pipe.c]"]
  node_subshells["Subshell parsing<br/>[create_subshell.c]"]
end

subgraph group_run["Execution"]
  node_executor["Execution dispatcher<br/>[ft_exec_class.c]"]
  node_exec_cmd["Command execution<br/>[ft_exec_cmd.c]"]
  node_logic["Logical execution<br/>[ft_exec_logic.c]"]
  node_pipe_exec["Pipeline execution<br/>[ft_exec_pipe.c]"]
  node_sub_exec["Subshell execution<br/>[ft_exec_sub.c]"]
  node_preparation["Command preparation<br/>[ft_cmd_init.c]"]
  node_redirection["Redirection<br/>[ft_redir_child.c]"]
  node_heredoc["Here-documents"]
  node_builtins["Built-in commands<br/>[builtins_exec.c]"]
end

subgraph group_state["Shell state"]
  node_env[("Environment<br/>[create_env.c]")]
  node_expansion["Variable expansion<br/>[expand.c]"]
  node_status["Exit status<br/>[ft_exit_codes.c]"]
end

subgraph group_support["Runtime support"]
  node_signals["Signal handling<br/>[signal.c]"]
  node_wildcards["Wildcard matching<br/>[wildcard.c]"]
end

node_user(("Interactive user"))
node_external["External programs"]
node_filesystem["Filesystem"]

node_user -->|"enters commands"| node_main
node_main -->|"initializes"| node_env
node_main -->|"sets handlers"| node_signals
node_main -->|"transforms input"| node_transform
node_transform -->|"returns line"| node_lexer
node_main -->|"lexes line"| node_lexer
node_lexer -->|"builds commands"| node_command
node_lexer -->|"builds logic"| node_structures
node_lexer -->|"builds pipelines"| node_pipes
node_lexer -->|"builds subshells"| node_subshells
node_command -->|"creates here-doc"| node_heredoc
node_main -->|"dispatches execution"| node_executor
node_executor -->|"runs commands"| node_exec_cmd
node_executor -->|"runs logic"| node_logic
node_executor -->|"runs pipelines"| node_pipe_exec
node_executor -->|"runs subshells"| node_sub_exec
node_exec_cmd -->|"prepares command"| node_preparation
node_exec_cmd -->|"dispatches built-in"| node_builtins
node_exec_cmd -->|"forks and executes"| node_external
node_exec_cmd -->|"sets child redirections"| node_redirection
node_builtins -->|"reads and updates"| node_env
node_main -->|"updates status"| node_status
node_expansion -->|"reads variables"| node_env
node_wildcards -->|"reads directory entries"| node_filesystem
node_redirection -->|"opens files"| node_filesystem

click node_main "https://github.com/rvnsenkuuu/minishell/blob/main/src/main.c"
click node_signals "https://github.com/rvnsenkuuu/minishell/blob/main/src/signal/signal.c"
click node_transform "https://github.com/rvnsenkuuu/minishell/blob/main/src/utils/ft_cmd_parsing.c"
click node_lexer "https://github.com/rvnsenkuuu/minishell/blob/main/src/lexer/lexer.c"
click node_command "https://github.com/rvnsenkuuu/minishell/blob/main/src/lexer/create_cmd.c"
click node_structures "https://github.com/rvnsenkuuu/minishell/blob/main/src/lexer/create_logic.c"
click node_pipes "https://github.com/rvnsenkuuu/minishell/blob/main/src/lexer/create_pipe.c"
click node_subshells "https://github.com/rvnsenkuuu/minishell/blob/main/src/lexer/create_subshell.c"
click node_executor "https://github.com/rvnsenkuuu/minishell/blob/main/src/exec/ft_exec_class.c"
click node_exec_cmd "https://github.com/rvnsenkuuu/minishell/blob/main/src/exec/ft_exec_cmd.c"
click node_logic "https://github.com/rvnsenkuuu/minishell/blob/main/src/exec/ft_exec_logic.c"
click node_pipe_exec "https://github.com/rvnsenkuuu/minishell/blob/main/src/exec/ft_exec_pipe.c"
click node_sub_exec "https://github.com/rvnsenkuuu/minishell/blob/main/src/exec/ft_exec_sub.c"
click node_preparation "https://github.com/rvnsenkuuu/minishell/blob/main/src/exec/ft_cmd_init.c"
click node_redirection "https://github.com/rvnsenkuuu/minishell/blob/main/src/exec/ft_redir_child.c"
click node_heredoc "https://github.com/rvnsenkuuu/minishell/blob/main/src/exec/ft_handle_heredoc.c"
click node_builtins "https://github.com/rvnsenkuuu/minishell/blob/main/src/builtins/builtins_exec.c"
click node_env "https://github.com/rvnsenkuuu/minishell/blob/main/src/env/create_env.c"
click node_expansion "https://github.com/rvnsenkuuu/minishell/blob/main/src/env/expand.c"
click node_wildcards "https://github.com/rvnsenkuuu/minishell/blob/main/src/wildcard/wildcard.c"
click node_status "https://github.com/rvnsenkuuu/minishell/blob/main/src/exitcodes/ft_exit_codes.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_user toneBlue
class node_transform,node_lexer,node_command,node_structures,node_pipes,node_subshells toneAmber
class node_executor,node_exec_cmd,node_logic,node_pipe_exec,node_sub_exec,node_preparation,node_redirection,node_heredoc,node_builtins toneMint
class node_env,node_expansion,node_status toneRose
class node_signals,node_wildcards,node_external,node_filesystem toneIndigo
```

## Components

### Shell lifecycle

- [Shell loop](https://github.com/rvnsenkuuu/minishell/blob/main/src/main.c): `src/main.c`

### Input parsing

- [Line transform](https://github.com/rvnsenkuuu/minishell/blob/main/src/utils/ft_cmd_parsing.c): `src/utils/ft_cmd_parsing.c`
- [Lexer](https://github.com/rvnsenkuuu/minishell/blob/main/src/lexer/lexer.c): `src/lexer/lexer.c`
- [Command construction](https://github.com/rvnsenkuuu/minishell/blob/main/src/lexer/create_cmd.c): `src/lexer/create_cmd.c`
- [Control structures](https://github.com/rvnsenkuuu/minishell/blob/main/src/lexer/create_logic.c): `src/lexer/create_logic.c`
- [Pipe parsing](https://github.com/rvnsenkuuu/minishell/blob/main/src/lexer/create_pipe.c): `src/lexer/create_pipe.c`
- [Subshell parsing](https://github.com/rvnsenkuuu/minishell/blob/main/src/lexer/create_subshell.c): `src/lexer/create_subshell.c`

### Execution

- [Execution dispatcher](https://github.com/rvnsenkuuu/minishell/blob/main/src/exec/ft_exec_class.c): `src/exec/ft_exec_class.c`
- [Command execution](https://github.com/rvnsenkuuu/minishell/blob/main/src/exec/ft_exec_cmd.c): `src/exec/ft_exec_cmd.c`
- [Logical execution](https://github.com/rvnsenkuuu/minishell/blob/main/src/exec/ft_exec_logic.c): `src/exec/ft_exec_logic.c`
- [Pipeline execution](https://github.com/rvnsenkuuu/minishell/blob/main/src/exec/ft_exec_pipe.c): `src/exec/ft_exec_pipe.c`
- [Subshell execution](https://github.com/rvnsenkuuu/minishell/blob/main/src/exec/ft_exec_sub.c): `src/exec/ft_exec_sub.c`
- [Command preparation](https://github.com/rvnsenkuuu/minishell/blob/main/src/exec/ft_cmd_init.c): `src/exec/ft_cmd_init.c`
- [Redirection](https://github.com/rvnsenkuuu/minishell/blob/main/src/exec/ft_redir_child.c): `src/exec/ft_redir_child.c`
- [Here-documents](https://github.com/rvnsenkuuu/minishell/blob/main/src/exec/ft_handle_heredoc.c): `src/exec/ft_handle_heredoc.c`
- [Built-in commands](https://github.com/rvnsenkuuu/minishell/blob/main/src/builtins/builtins_exec.c): `src/builtins/builtins_exec.c`

### Shell state

- [Environment](https://github.com/rvnsenkuuu/minishell/blob/main/src/env/create_env.c): `src/env/create_env.c`
- [Variable expansion](https://github.com/rvnsenkuuu/minishell/blob/main/src/env/expand.c): `src/env/expand.c`
- [Exit status](https://github.com/rvnsenkuuu/minishell/blob/main/src/exitcodes/ft_exit_codes.c): `src/exitcodes/ft_exit_codes.c`

### Runtime support

- [Signal handling](https://github.com/rvnsenkuuu/minishell/blob/main/src/signal/signal.c): `src/signal/signal.c`
- [Wildcard matching](https://github.com/rvnsenkuuu/minishell/blob/main/src/wildcard/wildcard.c): `src/wildcard/wildcard.c`

### Other components

- **Interactive user**
- **External programs**
- **Filesystem**

## Connections

- Interactive user → Shell loop: enters commands
- Shell loop → Environment: initializes
- Shell loop → Signal handling: sets handlers
- Shell loop → Line transform: transforms input
- Line transform → Lexer: returns line
- Shell loop → Lexer: lexes line
- Lexer → Command construction: builds commands
- Lexer → Control structures: builds logic
- Lexer → Pipe parsing: builds pipelines
- Lexer → Subshell parsing: builds subshells
- Command construction → Here-documents: creates here-doc
- Shell loop → Execution dispatcher: dispatches execution
- Execution dispatcher → Command execution: runs commands
- Execution dispatcher → Logical execution: runs logic
- Execution dispatcher → Pipeline execution: runs pipelines
- Execution dispatcher → Subshell execution: runs subshells
- Command execution → Command preparation: prepares command
- Command execution → Built-in commands: dispatches built-in
- Command execution → External programs: forks and executes
- Command execution → Redirection: sets child redirections
- Built-in commands → Environment: reads and updates
- Shell loop → Exit status: updates status
- Variable expansion → Environment: reads variables
- Wildcard matching → Filesystem: reads directory entries
- Redirection → Filesystem: opens files
