# julialang/juliaup architecture

> Architecture diagram of the GitHub repository julialang/juliaup, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-07-14). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/julialang/juliaup
- Repository: https://github.com/julialang/juliaup

## Overview

##### Project Type and Purpose
- This is an open-source, cross-platform CLI tool and installer for the Julia programming language, written in Rust.
- It provides three main binaries:
- juliainstaller (bootstraps Juliaup on a fresh system)
- julialauncher (dispatches to the correct Julia runtime)
- juliaup (version manager CLI)
- It also includes packaging artifacts (MSI, MSIX, AppInstaller, shell scripts) and CI/CD workflows to build and release installers on multiple platforms.

##### File Structure
- Top-level “src” contains a lib.rs (core library) plus modules for commands (command_*.rs), utilities (utils.rs), operation logic (operations.rs), config and path management.
- “src/bin” holds the three entry‐point executables.
- “deploy” houses per-platform packaging layouts and scripts (MSI under deploy/msi, MSIX under deploy/msix, shell scripts under deploy/shellscript, etc.).
- “scripts” contains helper scripts to build installers, update version databases, and fetch bundled Julia tarballs.
- “versiondb” stores static JSON manifests of available Julia versions per platform.
- CI configuration lives under “.github/workflows” and release metadata under release.toml.

##### README for Additional Insights
- Confirms primary use cases: installing Julia, managing multiple Julia versions, switching default channels, auto-updating.
- Highlights environment variables (JULIAUP_DEPOT_PATH, JULIAUP_SERVER) and override mechanism (directory, env var, CLI flag).
- References external S3 server for downloading Julia binaries.
- Notes developer workflows (building locally, updating version db, using GitHub Actions).

##### Essential Architectural Elements
- Flow of a typical command: User types `juliaup update` → CLI parses → Core Library checks versiondb → downloads from server → updates local depot → returns status.
- Installer workflow: juliainstaller sets up PATH, writes initial config, invokes platform packager.
- CI flow: GitHub Actions → build & test → package → publish installers.

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% User Layer
    User["User (Shell/Terminal)"]:::user

    %% Binaries Layer
    subgraph "User-facing Binaries"
        direction TB
        juliaup["juliaup CLI"]:::binary
        juliainstaller["juliainstaller"]:::binary
        julialauncher["julialauncher"]:::binary
    end

    User -->|"invokes"| juliaup
    User -->|"invokes"| juliainstaller
    User -->|"invokes"| julialauncher

    %% Core Library Layer
    subgraph "Core Library (src/lib.rs)" 
        direction TB
        corelib["Library Entry Point"]:::library
        cli["Command Parser & Dispatcher"]:::library
        cmds["Command Modules\n(src/command_*.rs)"]:::library
        config_file["Configuration File Handling"]:::library
        global_paths["Global Path Abstractions"]:::library
        jsondb["JSON Struct Definitions"]:::library
        versiondb_files["Static Version Manifests\n(versiondb/*.json)"]:::storage
        operations["Core Operations Logic"]:::library
        utils["Utility Functions"]:::library
        versions_file["Local Versions File Abstraction"]:::library
    end

    juliaup -->|"uses"| cli
    cli -->|"loads"| cmds
    cli -->|"calls"| operations
    cli -->|"reads/writes"| config_file
    config_file -->|"uses"| global_paths
    operations -->|"uses"| utils
    operations -->|"loads"| jsondb
    jsondb -->|"reads"| versiondb_files
    operations -->|"reads/writes"| versions_file
    corelib --> cli

    %% File System & External
    subgraph "Persistent Stores & External"
        direction TB
        filesystem["File System\n(JULIAUP_DEPOT_PATH, symlinks)"]:::external
        s3["External Juliaup Server\n(S3 HTTP)"]:::external
    end

    operations -->|"downloads"| s3
    operations -->|"stores artifacts"| filesystem
    cli -->|"reads config"| filesystem

    %% Packaging Subsystem
    subgraph "Packaging Subsystem" 
        direction TB
        msi["MSI Packaging\n(deploy/msi/**)"]:::packaging
        msix["MSIX/AppInstaller\n(deploy/msix/**)"]:::packaging
        shellscript["Shell Script Installer\n(deploy/shellscript/juliaup-init.sh)"]:::packaging
        powershell["PowerShell Helpers\n(deploy/winpkgidentityext/**)"]:::packaging
    end

    juliainstaller -->|"invokes"| shellscript
    juliainstaller -->|"uses"| msi
    juliainstaller -->|"uses"| msix
    juliainstaller -->|"uses"| powershell

    %% CI/CD Pipeline
    subgraph "CI/CD Pipeline (GitHub Actions)" 
        direction TB
        workflows["Workflows\n(.github/workflows/*.yml)"]:::ci
        release_meta["Release Metadata\n(release.toml)"]:::ci
        build_scripts["Build & Release Scripts\n(scripts/**)"]:::ci
    end

    workflows -->|"triggers build"| corelib
    workflows -->|"runs tests"| corelib
    workflows -->|"invokes packaging"| msi
    workflows -->|"invokes packaging"| msix
    workflows -->|"invokes"| build_scripts
    build_scripts -->|"update versiondb"| versiondb_files

    %% Click Events
    click juliaup "https://github.com/julialang/juliaup/blob/main/src/bin/juliaup.rs"
    click juliainstaller "https://github.com/julialang/juliaup/blob/main/src/bin/juliainstaller.rs"
    click julialauncher "https://github.com/julialang/juliaup/blob/main/src/bin/julialauncher.rs"
    click corelib "https://github.com/julialang/juliaup/blob/main/src/lib.rs"
    click cli "https://github.com/julialang/juliaup/blob/main/src/cli.rs"
    click config_file "https://github.com/julialang/juliaup/blob/main/src/config_file.rs"
    click global_paths "https://github.com/julialang/juliaup/blob/main/src/global_paths.rs"
    click jsondb "https://github.com/julialang/juliaup/blob/main/src/jsonstructs_versionsdb.rs"
    click versiondb_files "https://github.com/julialang/juliaup/tree/main/versiondb/"
    click operations "https://github.com/julialang/juliaup/blob/main/src/operations.rs"
    click utils "https://github.com/julialang/juliaup/blob/main/src/utils.rs"
    click versions_file "https://github.com/julialang/juliaup/blob/main/src/versions_file.rs"
    click msi "https://github.com/julialang/juliaup/tree/main/deploy/msi/"
    click msix "https://github.com/julialang/juliaup/tree/main/deploy/msix/"
    click shellscript "https://github.com/julialang/juliaup/blob/main/deploy/shellscript/juliaup-init.sh"
    click powershell "https://github.com/julialang/juliaup/tree/main/deploy/winpkgidentityext/"
    click workflows "https://github.com/julialang/juliaup/tree/main/.github/workflows/"
    click build_scripts "https://github.com/julialang/juliaup/tree/main/scripts/"

    %% Styles
    classDef user fill:#c8facc,stroke:#088f0d,color:#000
    classDef binary fill:#a5f3fc,stroke:#05606d,color:#000
    classDef library fill:#dbeafe,stroke:#1e40af,color:#000
    classDef storage fill:#fef9c3,stroke:#a16207,color:#000
    classDef external fill:#fed7aa,stroke:#c2410c,color:#000
    classDef packaging fill:#e0e7ff,stroke:#4338ca,color:#000
    classDef ci fill:#e5e7eb,stroke:#374151,color:#000
```
