# gariyong/choco-shell architecture

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

- Interactive diagram: https://gitdiagram.com/gariyong/choco-shell
- Repository: https://github.com/gariyong/choco-shell

## Overview

Choco Shell is a C/POSIX command-line shell with an optional terminal file-browser panel. The user enters a line; the shell records it, parses command lists and pipelines, then executes eligible pipelines as built-ins or child processes with job control and I/O wiring. Results are reflected in exit status, job notifications, and the next prompt. The graph also preserves editing/completion, history, status explanations, and the explorer. Edges follow the README’s execution-flow description and shown call/reference evidence; unsampled implementation details are not inferred.

Main entry points: [`src/jobs.c`](https://github.com/gariyong/choco-shell/blob/main/src/jobs.c) (Job control), [`src/main.c`](https://github.com/gariyong/choco-shell/blob/main/src/main.c) (Shell loop), [`src/executor.c`](https://github.com/gariyong/choco-shell/blob/main/src/executor.c) (Pipeline executor), [`src/process.c`](https://github.com/gariyong/choco-shell/blob/main/src/process.c) (Process spawning)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_interaction["Shell interaction"]
  node_main["Shell loop<br/>[main.c]"]
  node_prompt["Prompt and input<br/>[prompt.c]"]
  node_lineedit["Line editor<br/>[lineedit.c]"]
  node_complete["Tab completion<br/>[complete.c]"]
  node_history[("Command history<br/>[history.c]")]
end

subgraph group_language["Command language"]
  node_parser["Parser and expansion<br/>[parser.c]"]
  node_builtin["Built-in commands<br/>[builtin.c]"]
end

subgraph group_runtime["Execution and jobs"]
  node_executor["Pipeline executor<br/>[executor.c]"]
  node_process["Process spawning<br/>[process.c]"]
  node_jobs["Job control<br/>[jobs.c]"]
  node_signals["Signal handling<br/>[signal_handler.c]"]
  node_status["Exit status explanations<br/>[status.c]"]
end

subgraph group_io["I/O and terminal UI"]
  node_pipes["Pipe setup<br/>[pipeline.c]"]
  node_redirect["Redirection<br/>[redirect.c]"]
  node_explorer["File explorer panel<br/>[explorer.c]"]
end

node_user(("User"))

node_user -->|"enters commands"| node_prompt
node_main -->|"reads input"| node_prompt
node_main -->|"parses lines"| node_parser
node_main -->|"records input"| node_history
node_main -->|"executes pipelines"| node_executor
node_main -->|"reaps jobs"| node_jobs
node_main -->|"initializes signals"| node_signals
node_main -->|"refreshes panel"| node_explorer
node_prompt -->|"reads edited input"| node_lineedit
node_lineedit -->|"requests completion"| node_complete
node_lineedit -->|"registers notify hook"| node_jobs
node_prompt -->|"checks panel state"| node_explorer
node_parser -->|"produces pipeline"| node_executor
node_executor -->|"dispatches built-ins"| node_builtin
node_executor -->|"spawns commands"| node_process
node_executor -->|"sets up pipes"| node_pipes
node_executor -->|"registers background jobs"| node_jobs
node_executor -->|"reports pipeline status"| node_status
node_process -->|"connects pipe ends"| node_pipes
node_process -->|"applies redirection"| node_redirect
node_process -->|"runs child built-ins"| node_builtin
node_process -->|"resets child signals"| node_signals
node_process -->|"converts wait status"| node_status
node_jobs -->|"waits for jobs"| node_process
node_jobs -->|"handles child events"| node_signals
node_jobs -->|"formats job outcomes"| node_status
node_jobs -->|"coordinates notifications"| node_explorer
node_builtin -->|"runs job commands"| node_jobs
node_builtin -->|"prints history"| node_history

click node_main "https://github.com/gariyong/choco-shell/blob/main/src/main.c"
click node_prompt "https://github.com/gariyong/choco-shell/blob/main/src/prompt.c"
click node_lineedit "https://github.com/gariyong/choco-shell/blob/main/src/lineedit.c"
click node_complete "https://github.com/gariyong/choco-shell/blob/main/src/complete.c"
click node_history "https://github.com/gariyong/choco-shell/blob/main/src/history.c"
click node_parser "https://github.com/gariyong/choco-shell/blob/main/src/parser.c"
click node_builtin "https://github.com/gariyong/choco-shell/blob/main/src/builtin.c"
click node_executor "https://github.com/gariyong/choco-shell/blob/main/src/executor.c"
click node_process "https://github.com/gariyong/choco-shell/blob/main/src/process.c"
click node_jobs "https://github.com/gariyong/choco-shell/blob/main/src/jobs.c"
click node_signals "https://github.com/gariyong/choco-shell/blob/main/src/signal_handler.c"
click node_status "https://github.com/gariyong/choco-shell/blob/main/src/status.c"
click node_pipes "https://github.com/gariyong/choco-shell/blob/main/src/pipeline.c"
click node_redirect "https://github.com/gariyong/choco-shell/blob/main/src/redirect.c"
click node_explorer "https://github.com/gariyong/choco-shell/blob/main/src/explorer.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_lineedit,node_complete,node_history,node_user toneBlue
class node_parser,node_builtin toneAmber
class node_executor,node_process,node_jobs,node_signals,node_status toneMint
class node_pipes,node_redirect,node_explorer toneRose
```

## Components

### Shell interaction

- [Shell loop](https://github.com/gariyong/choco-shell/blob/main/src/main.c): `src/main.c`
- [Prompt and input](https://github.com/gariyong/choco-shell/blob/main/src/prompt.c): `src/prompt.c`
- [Line editor](https://github.com/gariyong/choco-shell/blob/main/src/lineedit.c): `src/lineedit.c`
- [Tab completion](https://github.com/gariyong/choco-shell/blob/main/src/complete.c): `src/complete.c`
- [Command history](https://github.com/gariyong/choco-shell/blob/main/src/history.c): `src/history.c`

### Command language

- [Parser and expansion](https://github.com/gariyong/choco-shell/blob/main/src/parser.c): `src/parser.c`
- [Built-in commands](https://github.com/gariyong/choco-shell/blob/main/src/builtin.c): `src/builtin.c`

### Execution and jobs

- [Pipeline executor](https://github.com/gariyong/choco-shell/blob/main/src/executor.c): `src/executor.c`
- [Process spawning](https://github.com/gariyong/choco-shell/blob/main/src/process.c): `src/process.c`
- [Job control](https://github.com/gariyong/choco-shell/blob/main/src/jobs.c): `src/jobs.c`
- [Signal handling](https://github.com/gariyong/choco-shell/blob/main/src/signal_handler.c): `src/signal_handler.c`
- [Exit status explanations](https://github.com/gariyong/choco-shell/blob/main/src/status.c): `src/status.c`

### I/O and terminal UI

- [Pipe setup](https://github.com/gariyong/choco-shell/blob/main/src/pipeline.c): `src/pipeline.c`
- [Redirection](https://github.com/gariyong/choco-shell/blob/main/src/redirect.c): `src/redirect.c`
- [File explorer panel](https://github.com/gariyong/choco-shell/blob/main/src/explorer.c): `src/explorer.c`

### Other components

- **User**

## Connections

- User → Prompt and input: enters commands (evidence: `README.md`)
- Shell loop → Prompt and input: reads input (evidence: `src/main.c`)
- Shell loop → Parser and expansion: parses lines (evidence: `src/main.c`)
- Shell loop → Command history: records input (evidence: `src/main.c`)
- Shell loop → Pipeline executor: executes pipelines (evidence: `src/main.c`)
- Shell loop → Job control: reaps jobs (evidence: `src/main.c`)
- Shell loop → Signal handling: initializes signals (evidence: `src/main.c`)
- Shell loop → File explorer panel: refreshes panel (evidence: `src/main.c`)
- Prompt and input → Line editor: reads edited input (evidence: `README.md`)
- Line editor → Tab completion: requests completion (evidence: `src/lineedit.c`)
- Line editor → Job control: registers notify hook (evidence: `src/lineedit.c`)
- Prompt and input → File explorer panel: checks panel state (evidence: `src/prompt.c`)
- Parser and expansion → Pipeline executor: produces pipeline (evidence: `README.md`)
- Pipeline executor → Built-in commands: dispatches built-ins (evidence: `src/executor.c`)
- Pipeline executor → Process spawning: spawns commands (evidence: `README.md`)
- Pipeline executor → Pipe setup: sets up pipes (evidence: `README.md`)
- Pipeline executor → Job control: registers background jobs (evidence: `README.md`)
- Pipeline executor → Exit status explanations: reports pipeline status (evidence: `src/executor.c`)
- Process spawning → Pipe setup: connects pipe ends (evidence: `README.md`)
- Process spawning → Redirection: applies redirection (evidence: `README.md`)
- Process spawning → Built-in commands: runs child built-ins
- Process spawning → Signal handling: resets child signals
- Process spawning → Exit status explanations: converts wait status (evidence: `src/process.c`)
- Job control → Process spawning: waits for jobs (evidence: `src/jobs.c`)
- Job control → Signal handling: handles child events (evidence: `src/jobs.c`)
- Job control → Exit status explanations: formats job outcomes (evidence: `src/jobs.c`)
- Job control → File explorer panel: coordinates notifications (evidence: `src/jobs.c`)
- Built-in commands → Job control: runs job commands (evidence: `src/builtin.c`)
- Built-in commands → Command history: prints history (evidence: `src/builtin.c`)
