# jdecorte-be/minishell architecture

> Architecture diagram of the GitHub repository jdecorte-be/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/jdecorte-be/minishell
- Repository: https://github.com/jdecorte-be/minishell

## Overview

Minishell is a POSIX-oriented interactive shell: it reads commands, prepares and parses input, then executes builtins or system programs while tracking shell state. The README documents pipes, redirections, here-documents, variable and exit-status expansion, history, and signal handling. The main loop and several execution and expansion components are evidenced in source excerpts; other capability links below rely on the README, so unsampled implementation details are not inferred.

Main entry points: [`src/main.c`](https://github.com/jdecorte-be/minishell/blob/main/src/main.c) (Interactive loop), [`src/utils/ft_chdollar.c`](https://github.com/jdecorte-be/minishell/blob/main/src/utils/ft_chdollar.c) (Variable expansion), [`src/exec/ope_2.c`](https://github.com/jdecorte-be/minishell/blob/main/src/exec/ope_2.c) (Execution dispatch), [`src/exec/exec.c`](https://github.com/jdecorte-be/minishell/blob/main/src/exec/exec.c) (Command execution)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_interaction["Shell interaction"]
  node_loop["Interactive loop<br/>[main.c]"]
  node_signals["Signal handling<br/>[signal.c]"]
end

subgraph group_language["Command processing"]
  node_preprocess["Input preparation<br/>[main.c]"]
  node_parser["Command parser<br/>[token_2.c]"]
  node_tokens["Token structures<br/>[token.c]"]
  node_expansion["Variable expansion<br/>[ft_chdollar.c]"]
  node_redirect["Redirections<br/>[file_redirect.c]"]
  node_heredoc["Here-documents<br/>[here_doc.c]"]
end

subgraph group_runtime["Execution runtime"]
  node_dispatch["Execution dispatch<br/>[ope_2.c]"]
  node_executor["Command execution<br/>[exec.c]"]
  node_pipes["Pipelines<br/>[pipe.c]"]
  node_builtins["Builtins<br/>[export.c]"]
  node_external["System programs<br/>[exec.c]"]
end

subgraph group_state["Shell state and support"]
  node_environment["Environment<br/>[env.c]"]
  node_status[("Shell status<br/>[minishell.h]")]
  node_libft["C utility library<br/>[libft.h]"]
end

node_user(("Shell user"))

node_user -->|"enters commands"| node_loop
node_loop -->|"prepares input"| node_preprocess
node_loop -->|"parses input"| node_parser
node_loop -->|"executes tokens"| node_dispatch
node_parser -->|"creates tokens"| node_tokens
node_loop -.->|"expands variables"| node_expansion
node_loop -.->|"handles redirects"| node_redirect
node_loop -.->|"handles heredocs"| node_heredoc
node_dispatch -->|"dispatches commands"| node_executor
node_executor -->|"selects builtins"| node_builtins
node_executor -->|"forks and executes"| node_external
node_dispatch -.->|"supports pipelines"| node_pipes
node_builtins -->|"reads and updates"| node_environment
node_expansion -->|"looks up variables"| node_environment
node_expansion -->|"expands exit status"| node_status
node_loop -->|"registers handlers"| node_signals
node_loop -->|"tracks last result"| node_status
node_loop -->|"uses utilities"| node_libft

click node_loop "https://github.com/jdecorte-be/minishell/blob/main/src/main.c"
click node_signals "https://github.com/jdecorte-be/minishell/blob/main/src/signal/signal.c"
click node_preprocess "https://github.com/jdecorte-be/minishell/blob/main/src/main.c"
click node_parser "https://github.com/jdecorte-be/minishell/blob/main/src/lst/token_2.c"
click node_tokens "https://github.com/jdecorte-be/minishell/blob/main/src/lst/token.c"
click node_expansion "https://github.com/jdecorte-be/minishell/blob/main/src/utils/ft_chdollar.c"
click node_redirect "https://github.com/jdecorte-be/minishell/blob/main/src/utils/file_redirect.c"
click node_heredoc "https://github.com/jdecorte-be/minishell/blob/main/src/utils/here_doc.c"
click node_dispatch "https://github.com/jdecorte-be/minishell/blob/main/src/exec/ope_2.c"
click node_executor "https://github.com/jdecorte-be/minishell/blob/main/src/exec/exec.c"
click node_pipes "https://github.com/jdecorte-be/minishell/blob/main/src/exec/pipe.c"
click node_builtins "https://github.com/jdecorte-be/minishell/blob/main/src/builtins/export.c"
click node_external "https://github.com/jdecorte-be/minishell/blob/main/src/exec/exec.c"
click node_environment "https://github.com/jdecorte-be/minishell/blob/main/src/builtins/env.c"
click node_status "https://github.com/jdecorte-be/minishell/blob/main/includes/minishell.h"
click node_libft "https://github.com/jdecorte-be/minishell/blob/main/libft/libft.h"

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_loop,node_signals,node_user toneBlue
class node_preprocess,node_parser,node_tokens,node_expansion,node_redirect,node_heredoc toneAmber
class node_dispatch,node_executor,node_pipes,node_builtins,node_external toneMint
class node_environment,node_status,node_libft toneRose
```

## Components

### Shell interaction

- [Interactive loop](https://github.com/jdecorte-be/minishell/blob/main/src/main.c): `src/main.c`
- [Signal handling](https://github.com/jdecorte-be/minishell/blob/main/src/signal/signal.c): `src/signal/signal.c`

### Command processing

- [Input preparation](https://github.com/jdecorte-be/minishell/blob/main/src/main.c): `src/main.c`
- [Command parser](https://github.com/jdecorte-be/minishell/blob/main/src/lst/token_2.c): `src/lst/token_2.c`
- [Token structures](https://github.com/jdecorte-be/minishell/blob/main/src/lst/token.c): `src/lst/token.c`
- [Variable expansion](https://github.com/jdecorte-be/minishell/blob/main/src/utils/ft_chdollar.c): `src/utils/ft_chdollar.c`
- [Redirections](https://github.com/jdecorte-be/minishell/blob/main/src/utils/file_redirect.c): `src/utils/file_redirect.c`
- [Here-documents](https://github.com/jdecorte-be/minishell/blob/main/src/utils/here_doc.c): `src/utils/here_doc.c`

### Execution runtime

- [Execution dispatch](https://github.com/jdecorte-be/minishell/blob/main/src/exec/ope_2.c): `src/exec/ope_2.c`
- [Command execution](https://github.com/jdecorte-be/minishell/blob/main/src/exec/exec.c): `src/exec/exec.c`
- [Pipelines](https://github.com/jdecorte-be/minishell/blob/main/src/exec/pipe.c): `src/exec/pipe.c`
- [Builtins](https://github.com/jdecorte-be/minishell/blob/main/src/builtins/export.c): `src/builtins/export.c`
- [System programs](https://github.com/jdecorte-be/minishell/blob/main/src/exec/exec.c): `src/exec/exec.c`

### Shell state and support

- [Environment](https://github.com/jdecorte-be/minishell/blob/main/src/builtins/env.c): `src/builtins/env.c`
- [Shell status](https://github.com/jdecorte-be/minishell/blob/main/includes/minishell.h): `includes/minishell.h`
- [C utility library](https://github.com/jdecorte-be/minishell/blob/main/libft/libft.h): `libft/libft.h`

### Other components

- **Shell user**

## Connections

- Shell user → Interactive loop: enters commands (evidence: `src/main.c`)
- Interactive loop → Input preparation: prepares input (evidence: `src/main.c`)
- Interactive loop → Command parser: parses input (evidence: `src/main.c`)
- Interactive loop → Execution dispatch: executes tokens (evidence: `src/main.c`)
- Command parser → Token structures: creates tokens
- Interactive loop → Variable expansion: expands variables
- Interactive loop → Redirections: handles redirects
- Interactive loop → Here-documents: handles heredocs
- Execution dispatch → Command execution: dispatches commands (evidence: `src/exec/ope_2.c`)
- Command execution → Builtins: selects builtins (evidence: `src/exec/exec.c`)
- Command execution → System programs: forks and executes (evidence: `src/exec/exec.c`)
- Execution dispatch → Pipelines: supports pipelines
- Builtins → Environment: reads and updates (evidence: `src/builtins/env.c`)
- Variable expansion → Environment: looks up variables (evidence: `src/utils/ft_chdollar.c`)
- Variable expansion → Shell status: expands exit status (evidence: `src/utils/ft_chdollar.c`)
- Interactive loop → Signal handling: registers handlers (evidence: `src/main.c`)
- Interactive loop → Shell status: tracks last result (evidence: `src/main.c`)
- Interactive loop → C utility library: uses utilities (evidence: `src/main.c`)
