# rgrmra/minishell architecture

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

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

## Overview

Minishell is an interactive shell: a user enters a command, which is processed into shell syntax and executed against built-ins or external programs. The tree also shows distinct execution paths for pipelines, conditionals, redirections, and subshells, plus variable, command, quote, and wildcard expansion. The source index confirms several module references, but the README only says “A Shell!” and many implementation files were not excerpted; dashed edges mark likely dispatch or feature links whose exact calls cannot be verified from the available evidence.

Main entry points: [`src/execution/execute_command.c`](https://github.com/rgrmra/minishell/blob/master/src/execution/execute_command.c) (Command execution), [`src/execution/execution.c`](https://github.com/rgrmra/minishell/blob/master/src/execution/execution.c) (Execution dispatch), [`src/prompt/prompt.c`](https://github.com/rgrmra/minishell/blob/master/src/prompt/prompt.c) (Prompt loop), [`src/tokenizer/tokenizer.c`](https://github.com/rgrmra/minishell/blob/master/src/tokenizer/tokenizer.c) (Tokenization)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_interaction["Interactive input"]
  node_main["Shell startup<br/>[main.c]"]
  node_prompt["Prompt loop<br/>[prompt.c]"]
  node_format["Input formatting<br/>[format_input.c]"]
end

subgraph group_syntax["Command syntax"]
  node_tokenize["Tokenization<br/>[tokenizer.c]"]
  node_append["Command assembly<br/>[append_commands.c]"]
  node_parser["Parser<br/>[parser.c]"]
  node_ast["AST construction<br/>[ast.c]"]
  node_astutils["AST utilities<br/>[ast_utils.c]"]
end

subgraph group_execution["Execution"]
  node_dispatch["Execution dispatch<br/>[execution.c]"]
  node_command["Command execution<br/>[execute_command.c]"]
  node_pipe["Pipeline execution<br/>[execute_pipe.c]"]
  node_conditional["Conditional execution"]
  node_redirection["Redirection execution"]
  node_subshell["Subshell execution<br/>[execute_subshell.c]"]
  node_expansion["Word expansion<br/>[var_expansions.c]"]
  node_commandexp["Command substitution"]
  node_wildcard["Wildcard expansion"]
  node_quotes["Quote removal<br/>[remove_quotes.c]"]
  node_builtins["Shell built-ins"]
end

subgraph group_state["Shell state"]
  node_environment["Environment<br/>[get_env.c]"]
  node_errors["Error handling<br/>[errors.c]"]
end

node_user(("User"))
node_external["External programs"]

node_user -->|"enters commands"| node_prompt
node_main -->|"starts loop"| node_prompt
node_prompt -.->|"formats input"| node_format
node_prompt -.->|"tokenizes input"| node_tokenize
node_tokenize -.->|"assembles commands"| node_append
node_tokenize -.->|"invokes parser"| node_parser
node_parser -.->|"builds syntax tree"| node_ast
node_ast -.->|"uses utilities"| node_astutils
node_prompt -.->|"executes input"| node_dispatch
node_dispatch -.->|"dispatches commands"| node_command
node_dispatch -.->|"dispatches pipelines"| node_pipe
node_dispatch -.->|"dispatches conditionals"| node_conditional
node_dispatch -.->|"dispatches redirections"| node_redirection
node_dispatch -.->|"dispatches subshells"| node_subshell
node_command -->|"expands variables"| node_expansion
node_command -->|"expands wildcards"| node_wildcard
node_command -->|"removes quotes"| node_quotes
node_command -->|"expands commands"| node_commandexp
node_command -->|"dispatches built-ins"| node_builtins
node_command -->|"executes program"| node_external
node_command -->|"exports variables"| node_environment
node_builtins -.->|"updates variables"| node_environment
node_dispatch -.->|"reports errors"| node_errors

click node_main "https://github.com/rgrmra/minishell/blob/master/src/main.c"
click node_prompt "https://github.com/rgrmra/minishell/blob/master/src/prompt/prompt.c"
click node_format "https://github.com/rgrmra/minishell/blob/master/src/prompt/format_input.c"
click node_tokenize "https://github.com/rgrmra/minishell/blob/master/src/tokenizer/tokenizer.c"
click node_append "https://github.com/rgrmra/minishell/blob/master/src/tokenizer/append_commands.c"
click node_parser "https://github.com/rgrmra/minishell/blob/master/src/parser/parser.c"
click node_ast "https://github.com/rgrmra/minishell/blob/master/src/ast/ast.c"
click node_astutils "https://github.com/rgrmra/minishell/blob/master/src/ast/ast_utils.c"
click node_dispatch "https://github.com/rgrmra/minishell/blob/master/src/execution/execution.c"
click node_command "https://github.com/rgrmra/minishell/blob/master/src/execution/execute_command.c"
click node_pipe "https://github.com/rgrmra/minishell/blob/master/src/execution/execute_pipe.c"
click node_conditional "https://github.com/rgrmra/minishell/blob/master/src/execution/execute_conditional.c"
click node_redirection "https://github.com/rgrmra/minishell/blob/master/src/execution/execute_redirection.c"
click node_subshell "https://github.com/rgrmra/minishell/blob/master/src/execution/execute_subshell.c"
click node_expansion "https://github.com/rgrmra/minishell/blob/master/src/expansions/var_expansions.c"
click node_commandexp "https://github.com/rgrmra/minishell/blob/master/src/expansions/command_expansions.c"
click node_wildcard "https://github.com/rgrmra/minishell/blob/master/src/expansions/wildcard_expansions.c"
click node_quotes "https://github.com/rgrmra/minishell/blob/master/src/expansions/remove_quotes.c"
click node_builtins "https://github.com/rgrmra/minishell/tree/master/src/builtin"
click node_environment "https://github.com/rgrmra/minishell/blob/master/src/getenv/get_env.c"
click node_errors "https://github.com/rgrmra/minishell/blob/master/src/error/errors.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_prompt,node_format,node_user toneBlue
class node_tokenize,node_append,node_parser,node_ast,node_astutils toneAmber
class node_dispatch,node_command,node_pipe,node_conditional,node_redirection,node_subshell,node_expansion,node_commandexp,node_wildcard,node_quotes,node_builtins toneMint
class node_environment,node_errors toneRose
class node_external toneIndigo
```

## Components

### Interactive input

- [Shell startup](https://github.com/rgrmra/minishell/blob/master/src/main.c): `src/main.c`
- [Prompt loop](https://github.com/rgrmra/minishell/blob/master/src/prompt/prompt.c): `src/prompt/prompt.c`
- [Input formatting](https://github.com/rgrmra/minishell/blob/master/src/prompt/format_input.c): `src/prompt/format_input.c`

### Command syntax

- [Tokenization](https://github.com/rgrmra/minishell/blob/master/src/tokenizer/tokenizer.c): `src/tokenizer/tokenizer.c`
- [Command assembly](https://github.com/rgrmra/minishell/blob/master/src/tokenizer/append_commands.c): `src/tokenizer/append_commands.c`
- [Parser](https://github.com/rgrmra/minishell/blob/master/src/parser/parser.c): `src/parser/parser.c`
- [AST construction](https://github.com/rgrmra/minishell/blob/master/src/ast/ast.c): `src/ast/ast.c`
- [AST utilities](https://github.com/rgrmra/minishell/blob/master/src/ast/ast_utils.c): `src/ast/ast_utils.c`

### Execution

- [Execution dispatch](https://github.com/rgrmra/minishell/blob/master/src/execution/execution.c): `src/execution/execution.c`
- [Command execution](https://github.com/rgrmra/minishell/blob/master/src/execution/execute_command.c): `src/execution/execute_command.c`
- [Pipeline execution](https://github.com/rgrmra/minishell/blob/master/src/execution/execute_pipe.c): `src/execution/execute_pipe.c`
- [Conditional execution](https://github.com/rgrmra/minishell/blob/master/src/execution/execute_conditional.c): `src/execution/execute_conditional.c`
- [Redirection execution](https://github.com/rgrmra/minishell/blob/master/src/execution/execute_redirection.c): `src/execution/execute_redirection.c`
- [Subshell execution](https://github.com/rgrmra/minishell/blob/master/src/execution/execute_subshell.c): `src/execution/execute_subshell.c`
- [Word expansion](https://github.com/rgrmra/minishell/blob/master/src/expansions/var_expansions.c): `src/expansions/var_expansions.c`
- [Command substitution](https://github.com/rgrmra/minishell/blob/master/src/expansions/command_expansions.c): `src/expansions/command_expansions.c`
- [Wildcard expansion](https://github.com/rgrmra/minishell/blob/master/src/expansions/wildcard_expansions.c): `src/expansions/wildcard_expansions.c`
- [Quote removal](https://github.com/rgrmra/minishell/blob/master/src/expansions/remove_quotes.c): `src/expansions/remove_quotes.c`
- [Shell built-ins](https://github.com/rgrmra/minishell/tree/master/src/builtin): `src/builtin`

### Shell state

- [Environment](https://github.com/rgrmra/minishell/blob/master/src/getenv/get_env.c): `src/getenv/get_env.c`
- [Error handling](https://github.com/rgrmra/minishell/blob/master/src/error/errors.c): `src/error/errors.c`

### Other components

- **User**
- **External programs**

## Connections

- User → Prompt loop: enters commands
- Shell startup → Prompt loop: starts loop (evidence: `src/main.c`)
- Prompt loop → Input formatting: formats input
- Prompt loop → Tokenization: tokenizes input
- Tokenization → Command assembly: assembles commands
- Tokenization → Parser: invokes parser
- Parser → AST construction: builds syntax tree
- AST construction → AST utilities: uses utilities
- Prompt loop → Execution dispatch: executes input
- Execution dispatch → Command execution: dispatches commands
- Execution dispatch → Pipeline execution: dispatches pipelines
- Execution dispatch → Conditional execution: dispatches conditionals
- Execution dispatch → Redirection execution: dispatches redirections
- Execution dispatch → Subshell execution: dispatches subshells
- Command execution → Word expansion: expands variables (evidence: `src/execution/execute_command.c`)
- Command execution → Wildcard expansion: expands wildcards (evidence: `src/execution/execute_command.c`)
- Command execution → Quote removal: removes quotes (evidence: `src/execution/execute_command.c`)
- Command execution → Command substitution: expands commands (evidence: `src/execution/execute_command.c`)
- Command execution → Shell built-ins: dispatches built-ins (evidence: `src/execution/execute_command.c`)
- Command execution → External programs: executes program (evidence: `src/execution/execute_command.c`)
- Command execution → Environment: exports variables (evidence: `src/execution/execute_command.c`)
- Shell built-ins → Environment: updates variables
- Execution dispatch → Error handling: reports errors
