# kamalmarhubi/shell-workshop architecture

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

- Interactive diagram: https://gitdiagram.com/kamalmarhubi/shell-workshop
- Repository: https://github.com/kamalmarhubi/shell-workshop

## Overview

This repository is a small Unix-shell workshop implementation. The user enters a line; the shell parses it into commands, connects pipeline stages with file descriptors, forks children to execute programs, and waits for them. The README describes builtins such as `cd`, but the sampled implementation does not show builtin handling. The graph reflects the sampled source and documented workflow; it does not infer other shell features.

Main entry points: [`shell.c`](https://github.com/kamalmarhubi/shell-workshop/blob/master/shell.c) (Shell loop), [`utils.c`](https://github.com/kamalmarhubi/shell-workshop/blob/master/utils.c) (Pipeline parser)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_interaction["Shell interaction"]
  node_input["Prompt input<br/>[shell.c]"]
  node_shell["Shell loop<br/>[shell.c]"]
  node_pipeline_parser["Pipeline parser<br/>[utils.c]"]
  node_command_parser["Command parser<br/>[utils.c]"]
end

subgraph group_execution["Command execution"]
  node_pipeline_setup["Pipe setup<br/>[shell.c]"]
  node_launcher["Child launcher<br/>[shell.c]"]
  node_child_exec["Redirect and exec<br/>[shell.c]"]
end

node_user(("User"))
node_process_services["OS process services"]

node_user -->|"enters commands"| node_input
node_input -->|"returns input"| node_shell
node_shell -->|"parses pipeline"| node_pipeline_parser
node_pipeline_parser -->|"parses stages"| node_command_parser
node_shell -->|"connects stages"| node_pipeline_setup
node_shell -->|"launches commands"| node_launcher
node_launcher -->|"executes in child"| node_child_exec
node_shell -->|"forks and waits"| node_process_services
node_pipeline_setup -->|"creates pipes"| node_process_services
node_child_exec -->|"redirects and execs"| node_process_services

click node_input "https://github.com/kamalmarhubi/shell-workshop/blob/master/shell.c"
click node_shell "https://github.com/kamalmarhubi/shell-workshop/blob/master/shell.c"
click node_pipeline_parser "https://github.com/kamalmarhubi/shell-workshop/blob/master/utils.c"
click node_command_parser "https://github.com/kamalmarhubi/shell-workshop/blob/master/utils.c"
click node_pipeline_setup "https://github.com/kamalmarhubi/shell-workshop/blob/master/shell.c"
click node_launcher "https://github.com/kamalmarhubi/shell-workshop/blob/master/shell.c"
click node_child_exec "https://github.com/kamalmarhubi/shell-workshop/blob/master/shell.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_input,node_shell,node_pipeline_parser,node_command_parser,node_user toneBlue
class node_pipeline_setup,node_launcher,node_child_exec toneAmber
class node_process_services toneIndigo
```

## Components

### Shell interaction

- [Prompt input](https://github.com/kamalmarhubi/shell-workshop/blob/master/shell.c): `shell.c`
- [Shell loop](https://github.com/kamalmarhubi/shell-workshop/blob/master/shell.c): `shell.c`
- [Pipeline parser](https://github.com/kamalmarhubi/shell-workshop/blob/master/utils.c): `utils.c`
- [Command parser](https://github.com/kamalmarhubi/shell-workshop/blob/master/utils.c): `utils.c`

### Command execution

- [Pipe setup](https://github.com/kamalmarhubi/shell-workshop/blob/master/shell.c): `shell.c`
- [Child launcher](https://github.com/kamalmarhubi/shell-workshop/blob/master/shell.c): `shell.c`
- [Redirect and exec](https://github.com/kamalmarhubi/shell-workshop/blob/master/shell.c): `shell.c`

### Other components

- **User**
- **OS process services**

## Connections

- User → Prompt input: enters commands (evidence: `README.md`)
- Prompt input → Shell loop: returns input (evidence: `shell.c`)
- Shell loop → Pipeline parser: parses pipeline (evidence: `shell.c`)
- Pipeline parser → Command parser: parses stages (evidence: `utils.c`)
- Shell loop → Pipe setup: connects stages (evidence: `shell.c`)
- Shell loop → Child launcher: launches commands (evidence: `shell.c`)
- Child launcher → Redirect and exec: executes in child (evidence: `shell.c`)
- Shell loop → OS process services: forks and waits (evidence: `shell.c`)
- Pipe setup → OS process services: creates pipes (evidence: `shell.c`)
- Redirect and exec → OS process services: redirects and execs (evidence: `shell.c`)
