# vishalk91-4/custom-shell architecture

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

- Interactive diagram: https://gitdiagram.com/vishalk91-4/custom-shell
- Repository: https://github.com/vishalk91-4/custom-shell

## Overview

This is a small interactive Unix-like shell. Its demonstrated workflow reads a command line, tokenizes it, dispatches built-ins or searches PATH and launches an external program. The README also claims pipelines, redirection, job control, signals, and environment expansion, but the only sampled source does not show those features; they are represented as documented, unverified capabilities rather than asserted implementation flows.

Main entry points: [`src/main.cpp`](https://github.com/vishalk91-4/custom-shell/blob/main/src/main.cpp) (External execution), [`src`](https://github.com/vishalk91-4/custom-shell/tree/main/src) (Pipelines)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_interaction["Shell interaction"]
  node_loop["Command loop<br/>[main.cpp]"]
  node_tokenize["Whitespace tokenizer<br/>[main.cpp]"]
end

subgraph group_commands["Command handling"]
  node_dispatch["Command dispatch<br/>[main.cpp]"]
  node_builtins["Built-in handlers<br/>[main.cpp]"]
  node_type["Type lookup<br/>[main.cpp]"]
end

subgraph group_execution["Process execution"]
  node_path["PATH search<br/>[main.cpp]"]
  node_argv["Argument builder<br/>[main.cpp]"]
  node_external["External execution<br/>[main.cpp]"]
end

subgraph group_documented["Documented capabilities"]
  node_pipeline["Pipelines"]
  node_redirection["I/O redirection"]
  node_jobs["Background and job control"]
  node_signals["Signal handling"]
  node_expansion["Environment expansion"]
end

node_user(("Shell user"))

node_user -->|"enters commands"| node_loop
node_loop -->|"tokenizes input"| node_tokenize
node_loop -->|"dispatches command"| node_dispatch
node_dispatch -->|"handles built-ins"| node_builtins
node_dispatch -->|"runs other commands"| node_external
node_builtins -->|"calls type handler"| node_type
node_type -->|"searches PATH"| node_path
node_external -->|"resolves command"| node_path
node_external -->|"builds arguments"| node_argv
node_external -->|"runs and waits"| node_user
node_user -.->|"uses pipelines"| node_pipeline
node_user -.->|"uses redirection"| node_redirection
node_user -.->|"controls jobs"| node_jobs
node_user -.->|"sends signals"| node_signals
node_user -.->|"uses expansion"| node_expansion

click node_loop "https://github.com/vishalk91-4/custom-shell/blob/main/src/main.cpp"
click node_tokenize "https://github.com/vishalk91-4/custom-shell/blob/main/src/main.cpp"
click node_dispatch "https://github.com/vishalk91-4/custom-shell/blob/main/src/main.cpp"
click node_builtins "https://github.com/vishalk91-4/custom-shell/blob/main/src/main.cpp"
click node_type "https://github.com/vishalk91-4/custom-shell/blob/main/src/main.cpp"
click node_path "https://github.com/vishalk91-4/custom-shell/blob/main/src/main.cpp"
click node_argv "https://github.com/vishalk91-4/custom-shell/blob/main/src/main.cpp"
click node_external "https://github.com/vishalk91-4/custom-shell/blob/main/src/main.cpp"
click node_pipeline "https://github.com/vishalk91-4/custom-shell/tree/main/src"
click node_redirection "https://github.com/vishalk91-4/custom-shell/tree/main/src"
click node_jobs "https://github.com/vishalk91-4/custom-shell/tree/main/src"
click node_signals "https://github.com/vishalk91-4/custom-shell/tree/main/src"
click node_expansion "https://github.com/vishalk91-4/custom-shell/tree/main/src"

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_tokenize,node_user toneBlue
class node_dispatch,node_builtins,node_type toneAmber
class node_path,node_argv,node_external toneMint
class node_pipeline,node_redirection,node_jobs,node_signals,node_expansion toneRose
```

## Components

### Shell interaction

- [Command loop](https://github.com/vishalk91-4/custom-shell/blob/main/src/main.cpp): `src/main.cpp`
- [Whitespace tokenizer](https://github.com/vishalk91-4/custom-shell/blob/main/src/main.cpp): `src/main.cpp`

### Command handling

- [Command dispatch](https://github.com/vishalk91-4/custom-shell/blob/main/src/main.cpp): `src/main.cpp`
- [Built-in handlers](https://github.com/vishalk91-4/custom-shell/blob/main/src/main.cpp): `src/main.cpp`
- [Type lookup](https://github.com/vishalk91-4/custom-shell/blob/main/src/main.cpp): `src/main.cpp`

### Process execution

- [PATH search](https://github.com/vishalk91-4/custom-shell/blob/main/src/main.cpp): `src/main.cpp`
- [Argument builder](https://github.com/vishalk91-4/custom-shell/blob/main/src/main.cpp): `src/main.cpp`
- [External execution](https://github.com/vishalk91-4/custom-shell/blob/main/src/main.cpp): `src/main.cpp`

### Documented capabilities

- [Pipelines](https://github.com/vishalk91-4/custom-shell/tree/main/src): `src`
- [I/O redirection](https://github.com/vishalk91-4/custom-shell/tree/main/src): `src`
- [Background and job control](https://github.com/vishalk91-4/custom-shell/tree/main/src): `src`
- [Signal handling](https://github.com/vishalk91-4/custom-shell/tree/main/src): `src`
- [Environment expansion](https://github.com/vishalk91-4/custom-shell/tree/main/src): `src`

### Other components

- **Shell user**

## Connections

- Shell user → Command loop: enters commands (evidence: `README.md`)
- Command loop → Whitespace tokenizer: tokenizes input (evidence: `src/main.cpp`)
- Command loop → Command dispatch: dispatches command (evidence: `src/main.cpp`)
- Command dispatch → Built-in handlers: handles built-ins (evidence: `src/main.cpp`)
- Command dispatch → External execution: runs other commands (evidence: `src/main.cpp`)
- Built-in handlers → Type lookup: calls type handler (evidence: `src/main.cpp`)
- Type lookup → PATH search: searches PATH (evidence: `src/main.cpp`)
- External execution → PATH search: resolves command (evidence: `src/main.cpp`)
- External execution → Argument builder: builds arguments (evidence: `src/main.cpp`)
- External execution → Shell user: runs and waits (evidence: `src/main.cpp`)
- Shell user → Pipelines: uses pipelines (evidence: `README.md`)
- Shell user → I/O redirection: uses redirection (evidence: `README.md`)
- Shell user → Background and job control: controls jobs (evidence: `README.md`)
- Shell user → Signal handling: sends signals (evidence: `README.md`)
- Shell user → Environment expansion: uses expansion (evidence: `README.md`)
