# jaevibing/g-shell architecture

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

- Interactive diagram: https://gitdiagram.com/jaevibing/g-shell
- Repository: https://github.com/jaevibing/g-shell

## Overview

g-shell is a pre-alpha Unix-like shell. Its main workflow reads terminal input, records commands, dispatches built-ins or external programs, and prints results; help is served from an embedded file. At startup it checks for a newer version, prompts the user, and can download an update. The graph separates shell behavior, update handling, and local state. Source excerpts show the main runtime calls; unsampled installer behavior and future roadmap features are omitted.

Main entry points: [`src/main.rs`](https://github.com/jaevibing/g-shell/blob/master/src/main.rs) (Shell loop), [`src/autoupdate.rs`](https://github.com/jaevibing/g-shell/blob/master/src/autoupdate.rs) (Update check), [`src/download.rs`](https://github.com/jaevibing/g-shell/blob/master/src/download.rs) (Binary downloader), [`src/saveLastCheck.rs`](https://github.com/jaevibing/g-shell/blob/master/src/saveLastCheck.rs) (Cache writer)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_shell["Shell runtime"]
  node_shell_loop["Shell loop<br/>[main.rs]"]
  node_command_dispatch["Command dispatch<br/>[main.rs]"]
  node_help_content["Help content"]
end

subgraph group_updates["Update lifecycle"]
  node_update_check["Update check<br/>[autoupdate.rs]"]
  node_release_downloader["Binary downloader<br/>[download.rs]"]
  node_installed_binary[("Installed binary")]
end

subgraph group_state["Local state"]
  node_history["Command history<br/>[history.rs]"]
  node_cache_reader["Cache check<br/>[autoupdate.rs]"]
  node_cache_writer["Cache writer<br/>[saveLastCheck.rs]"]
  node_cache_file[("Update cache")]
end

node_user(("Shell user"))
node_terminal(("Terminal"))
node_external_program["External programs"]
node_version_source["Version endpoint"]
node_release_assets["Release assets"]

node_user -->|"enters commands"| node_terminal
node_terminal -->|"provides input"| node_shell_loop
node_shell_loop -->|"prints prompt"| node_terminal
node_shell_loop -->|"checks version"| node_update_check
node_update_check -->|"checks freshness"| node_cache_reader
node_cache_reader -->|"reads cache"| node_cache_file
node_update_check -->|"fetches version"| node_version_source
node_shell_loop -->|"saves declined check"| node_cache_writer
node_cache_writer -->|"writes cache"| node_cache_file
node_shell_loop -->|"requests update"| node_release_downloader
node_release_downloader -->|"downloads binary"| node_release_assets
node_release_downloader -->|"writes file"| node_installed_binary
node_shell_loop -->|"records command"| node_history
node_shell_loop -->|"dispatches command"| node_command_dispatch
node_command_dispatch -->|"clears history"| node_history
node_command_dispatch -->|"runs program"| node_external_program
node_command_dispatch -->|"prints help"| node_help_content
node_command_dispatch -->|"prints results"| node_terminal

click node_shell_loop "https://github.com/jaevibing/g-shell/blob/master/src/main.rs"
click node_command_dispatch "https://github.com/jaevibing/g-shell/blob/master/src/main.rs"
click node_help_content "https://github.com/jaevibing/g-shell/blob/master/src/docs/HELPFILE"
click node_history "https://github.com/jaevibing/g-shell/blob/master/src/history.rs"
click node_update_check "https://github.com/jaevibing/g-shell/blob/master/src/autoupdate.rs"
click node_cache_reader "https://github.com/jaevibing/g-shell/blob/master/src/autoupdate.rs"
click node_cache_writer "https://github.com/jaevibing/g-shell/blob/master/src/saveLastCheck.rs"
click node_release_downloader "https://github.com/jaevibing/g-shell/blob/master/src/download.rs"

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_shell_loop,node_command_dispatch,node_help_content,node_user toneBlue
class node_update_check,node_release_downloader,node_installed_binary toneAmber
class node_history,node_cache_reader,node_cache_writer,node_cache_file toneMint
class node_terminal,node_external_program,node_version_source,node_release_assets toneIndigo
```

## Components

### Shell runtime

- [Shell loop](https://github.com/jaevibing/g-shell/blob/master/src/main.rs): `src/main.rs`
- [Command dispatch](https://github.com/jaevibing/g-shell/blob/master/src/main.rs): `src/main.rs`
- [Help content](https://github.com/jaevibing/g-shell/blob/master/src/docs/HELPFILE): `src/docs/HELPFILE`

### Update lifecycle

- [Update check](https://github.com/jaevibing/g-shell/blob/master/src/autoupdate.rs): `src/autoupdate.rs`
- [Binary downloader](https://github.com/jaevibing/g-shell/blob/master/src/download.rs): `src/download.rs`
- **Installed binary**

### Local state

- [Command history](https://github.com/jaevibing/g-shell/blob/master/src/history.rs): `src/history.rs`
- [Cache check](https://github.com/jaevibing/g-shell/blob/master/src/autoupdate.rs): `src/autoupdate.rs`
- [Cache writer](https://github.com/jaevibing/g-shell/blob/master/src/saveLastCheck.rs): `src/saveLastCheck.rs`
- **Update cache**

### Other components

- **Shell user**
- **Terminal**
- **External programs**
- **Version endpoint**
- **Release assets**

## Connections

- Shell user → Terminal: enters commands (evidence: `README.md`)
- Terminal → Shell loop: provides input (evidence: `src/main.rs`)
- Shell loop → Terminal: prints prompt (evidence: `src/main.rs`)
- Shell loop → Update check: checks version (evidence: `src/main.rs`)
- Update check → Cache check: checks freshness (evidence: `src/autoupdate.rs`)
- Cache check → Update cache: reads cache (evidence: `src/autoupdate.rs`)
- Update check → Version endpoint: fetches version (evidence: `src/autoupdate.rs`)
- Shell loop → Cache writer: saves declined check (evidence: `src/main.rs`)
- Cache writer → Update cache: writes cache (evidence: `src/saveLastCheck.rs`)
- Shell loop → Binary downloader: requests update (evidence: `src/main.rs`)
- Binary downloader → Release assets: downloads binary (evidence: `src/download.rs`)
- Binary downloader → Installed binary: writes file (evidence: `src/download.rs`)
- Shell loop → Command history: records command (evidence: `src/main.rs`)
- Shell loop → Command dispatch: dispatches command (evidence: `src/main.rs`)
- Command dispatch → Command history: clears history (evidence: `src/main.rs`)
- Command dispatch → External programs: runs program (evidence: `src/main.rs`)
- Command dispatch → Help content: prints help (evidence: `src/main.rs`)
- Command dispatch → Terminal: prints results (evidence: `src/main.rs`)
