# moumniucf/minishell architecture

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

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

## Overview

Minishell is a custom interactive shell. Its principal workflow reads a command line, checks and tokenizes shell syntax, expands variables and parses tokens into command segments, then executes built-ins or external programs with redirection and pipes. The graph also preserves environment management and signal handling as distinct capabilities. README statements support the high-level workflow and documented features; sampled source confirms token parsing, redirection handling, and built-in dispatch. Some unsampled implementation links are therefore documented rather than source-verified.

Main entry points: [`minishell/parss/parss_er.c`](https://github.com/moumniucf/minishell/blob/main/minishell/parss/parss_er.c) (Command parsing), [`minishell/exec/exec.c`](https://github.com/moumniucf/minishell/blob/main/minishell/exec/exec.c) (Execution control), [`minishell/exec/builtins.c`](https://github.com/moumniucf/minishell/blob/main/minishell/exec/builtins.c) (Built-in dispatch), [`minishell/parss/pro_mpt.c`](https://github.com/moumniucf/minishell/blob/main/minishell/parss/pro_mpt.c) (Prompt and input)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_input["Input and parsing"]
  node_prompt["Prompt and input<br/>[pro_mpt.c]"]
  node_syntax["Syntax checks<br/>[syntax_err.c]"]
  node_tokenization["Tokenization<br/>[minishell.h]"]
  node_quote_expansion["Quote expansion<br/>[handl_qs.c]"]
  node_variable_expansion["Variable expansion<br/>[expa_nd.c]"]
  node_redirections["Redirections<br/>[help_norm_1.c]"]
  node_heredocs["Here-documents<br/>[herdoc_handle.c]"]
  node_command_parse["Command parsing<br/>[parss_er.c]"]
end

subgraph group_execution["Command execution"]
  node_execution["Execution control<br/>[exec.c]"]
  node_builtin_dispatch["Built-in dispatch<br/>[builtins.c]"]
  node_builtin_commands["Built-in commands<br/>[echo.c]"]
  node_external_commands["External commands<br/>[exec_utils.c]"]
  node_pipeline["Pipes and processes<br/>[exec_utils1.c]"]
end

subgraph group_state["Shell state"]
  node_environment[("Environment state<br/>[env.c]")]
  node_environment_builtins["Environment built-ins<br/>[export.c]"]
  node_directory_builtins["Directory built-ins<br/>[cd.c]"]
end

subgraph group_runtime["Runtime behavior"]
  node_signals["Signal handling<br/>[signal.c]"]
end

node_user(("Shell user"))
node_terminal_signals(("Terminal signals"))
node_command_result(("Command result"))

node_user -->|"enters commands"| node_prompt
node_prompt -.->|"checks syntax"| node_syntax
node_syntax -.->|"accepts input"| node_tokenization
node_tokenization -->|"parses tokens"| node_command_parse
node_command_parse -->|"handles quotes"| node_quote_expansion
node_command_parse -->|"expands variables"| node_variable_expansion
node_command_parse -->|"handles redirects"| node_redirections
node_command_parse -->|"uses here-docs"| node_heredocs
node_command_parse -.->|"produces commands"| node_execution
node_execution -.->|"dispatches built-ins"| node_builtin_dispatch
node_builtin_dispatch -->|"calls commands"| node_builtin_commands
node_execution -.->|"runs programs"| node_external_commands
node_execution -.->|"manages pipes"| node_pipeline
node_variable_expansion -.->|"reads variables"| node_environment
node_environment_builtins -->|"updates environment"| node_environment
node_directory_builtins -->|"updates directory state"| node_environment
node_builtin_dispatch -.->|"dispatches commands"| node_environment_builtins
node_builtin_dispatch -.->|"dispatches commands"| node_directory_builtins
node_terminal_signals -.->|"raises signals"| node_signals
node_signals -.->|"handles interrupts"| node_prompt
node_execution -.->|"produces status"| node_command_result

click node_prompt "https://github.com/moumniucf/minishell/blob/main/minishell/parss/pro_mpt.c"
click node_syntax "https://github.com/moumniucf/minishell/blob/main/minishell/parss/syntax_err.c"
click node_tokenization "https://github.com/moumniucf/minishell/blob/main/minishell/minishell.h"
click node_quote_expansion "https://github.com/moumniucf/minishell/blob/main/minishell/parss/handl_qs.c"
click node_variable_expansion "https://github.com/moumniucf/minishell/blob/main/minishell/parss/expa_nd.c"
click node_redirections "https://github.com/moumniucf/minishell/blob/main/minishell/parss/help_norm_1.c"
click node_heredocs "https://github.com/moumniucf/minishell/blob/main/minishell/parss/herdoc_handle.c"
click node_command_parse "https://github.com/moumniucf/minishell/blob/main/minishell/parss/parss_er.c"
click node_execution "https://github.com/moumniucf/minishell/blob/main/minishell/exec/exec.c"
click node_builtin_dispatch "https://github.com/moumniucf/minishell/blob/main/minishell/exec/builtins.c"
click node_builtin_commands "https://github.com/moumniucf/minishell/blob/main/minishell/exec/echo.c"
click node_external_commands "https://github.com/moumniucf/minishell/blob/main/minishell/exec/exec_utils.c"
click node_pipeline "https://github.com/moumniucf/minishell/blob/main/minishell/exec/exec_utils1.c"
click node_environment "https://github.com/moumniucf/minishell/blob/main/minishell/exec/env.c"
click node_environment_builtins "https://github.com/moumniucf/minishell/blob/main/minishell/exec/export.c"
click node_directory_builtins "https://github.com/moumniucf/minishell/blob/main/minishell/exec/cd.c"
click node_signals "https://github.com/moumniucf/minishell/blob/main/minishell/exec/signal.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_prompt,node_syntax,node_tokenization,node_quote_expansion,node_variable_expansion,node_redirections,node_heredocs,node_command_parse,node_user toneBlue
class node_execution,node_builtin_dispatch,node_builtin_commands,node_external_commands,node_pipeline toneAmber
class node_environment,node_environment_builtins,node_directory_builtins toneMint
class node_signals toneRose
class node_terminal_signals,node_command_result toneIndigo
```

## Components

### Input and parsing

- [Prompt and input](https://github.com/moumniucf/minishell/blob/main/minishell/parss/pro_mpt.c): `minishell/parss/pro_mpt.c`
- [Syntax checks](https://github.com/moumniucf/minishell/blob/main/minishell/parss/syntax_err.c): `minishell/parss/syntax_err.c`
- [Tokenization](https://github.com/moumniucf/minishell/blob/main/minishell/minishell.h): `minishell/minishell.h`
- [Quote expansion](https://github.com/moumniucf/minishell/blob/main/minishell/parss/handl_qs.c): `minishell/parss/handl_qs.c`
- [Variable expansion](https://github.com/moumniucf/minishell/blob/main/minishell/parss/expa_nd.c): `minishell/parss/expa_nd.c`
- [Redirections](https://github.com/moumniucf/minishell/blob/main/minishell/parss/help_norm_1.c): `minishell/parss/help_norm_1.c`
- [Here-documents](https://github.com/moumniucf/minishell/blob/main/minishell/parss/herdoc_handle.c): `minishell/parss/herdoc_handle.c`
- [Command parsing](https://github.com/moumniucf/minishell/blob/main/minishell/parss/parss_er.c): `minishell/parss/parss_er.c`

### Command execution

- [Execution control](https://github.com/moumniucf/minishell/blob/main/minishell/exec/exec.c): `minishell/exec/exec.c`
- [Built-in dispatch](https://github.com/moumniucf/minishell/blob/main/minishell/exec/builtins.c): `minishell/exec/builtins.c`
- [Built-in commands](https://github.com/moumniucf/minishell/blob/main/minishell/exec/echo.c): `minishell/exec/echo.c`
- [External commands](https://github.com/moumniucf/minishell/blob/main/minishell/exec/exec_utils.c): `minishell/exec/exec_utils.c`
- [Pipes and processes](https://github.com/moumniucf/minishell/blob/main/minishell/exec/exec_utils1.c): `minishell/exec/exec_utils1.c`

### Shell state

- [Environment state](https://github.com/moumniucf/minishell/blob/main/minishell/exec/env.c): `minishell/exec/env.c`
- [Environment built-ins](https://github.com/moumniucf/minishell/blob/main/minishell/exec/export.c): `minishell/exec/export.c`
- [Directory built-ins](https://github.com/moumniucf/minishell/blob/main/minishell/exec/cd.c): `minishell/exec/cd.c`

### Runtime behavior

- [Signal handling](https://github.com/moumniucf/minishell/blob/main/minishell/exec/signal.c): `minishell/exec/signal.c`

### Other components

- **Shell user**
- **Terminal signals**
- **Command result**

## Connections

- Shell user → Prompt and input: enters commands
- Prompt and input → Syntax checks: checks syntax
- Syntax checks → Tokenization: accepts input (evidence: `minishell/parss/syntax_err.c`)
- Tokenization → Command parsing: parses tokens (evidence: `minishell/parss/parss_er.c`)
- Command parsing → Quote expansion: handles quotes (evidence: `minishell/parss/parss_er.c`)
- Command parsing → Variable expansion: expands variables (evidence: `minishell/parss/parss_er.c`)
- Command parsing → Redirections: handles redirects (evidence: `minishell/parss/parss_er.c`)
- Command parsing → Here-documents: uses here-docs (evidence: `minishell/parss/parss_er.c`)
- Command parsing → Execution control: produces commands
- Execution control → Built-in dispatch: dispatches built-ins
- Built-in dispatch → Built-in commands: calls commands (evidence: `minishell/exec/builtins.c`)
- Execution control → External commands: runs programs
- Execution control → Pipes and processes: manages pipes
- Variable expansion → Environment state: reads variables
- Environment built-ins → Environment state: updates environment (evidence: `minishell/exec/export.c`)
- Directory built-ins → Environment state: updates directory state (evidence: `minishell/exec/cd.c`)
- Built-in dispatch → Environment built-ins: dispatches commands
- Built-in dispatch → Directory built-ins: dispatches commands
- Terminal signals → Signal handling: raises signals
- Signal handling → Prompt and input: handles interrupts
- Execution control → Command result: produces status
