# avivbens/shell-config architecture

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

- Interactive diagram: https://gitdiagram.com/avivbens/shell-config
- Repository: https://github.com/avivbens/shell-config

## Overview

##### Project type and purpose
- This is an open-source CLI tool (“shell-config”) written in Node/NestJS.
- Purpose: automate and standardize macOS setup—install apps, configure zsh, apply dotfiles, run scripts, manage updates.

##### File structure
- Top level:
- src/ – application code
- src/commands/ – each CLI command and its sub-commands
- src/services/ – core services (e.g., logger, update checker)
- src/common/ – shared utilities and prompt renderers
- src/models/ – data models for configs and API payloads
- src/scripts/ – shell scripts used by the installer
- templates/ & zsh/ – template files for dotfiles and zsh extensions
- docs/ & assets/ – documentation site powered by VitePress
- Configs and build:
- nest-cli.json, tsconfig*.json, package.json, project-scripts/pack.js

##### README for additional insights
- CLI entry point is a bootstrap script (`src/main.ts` called by init.sh).
- Features: install apps, asset management, external installs, init scripts, shell prompt setup, update.
- Structured as a NestJS application (app.module.ts) but geared for CLI.

##### Detailed capture
- Layering: Presentation (CLI prompts) → Business Logic (commands) → Infrastructure (scripts/OS calls).
- Config files and docs as side modules to show maintenance and documentation flow.

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% CLI Launcher
    ScriptInit["init.sh"]:::shellGreen
    click ScriptInit "https://github.com/avivbens/shell-config/blob/master/src/scripts/init.sh"
    Main["CLI Launcher\nsrc/main.ts"]:::nodeBlue
    click Main "https://github.com/avivbens/shell-config/blob/master/src/main.ts"
    ScriptInit -->|invokes| Main

    %% Router
    Router["Command Router\nsrc/commands/"]:::nodeBlue
    click Router "https://github.com/avivbens/shell-config/tree/master/src/commands/"
    Main -->|bootstraps| Router

    %% Command Modules
    subgraph "Command Modules"
        direction TB
        Assets["Assets Command\nassets.command.ts"]:::nodeBlue
        click Assets "https://github.com/avivbens/shell-config/blob/master/src/commands/assets/assets.command.ts"
        External["External Command\nexternal.command.ts"]:::nodeBlue
        click External "https://github.com/avivbens/shell-config/blob/master/src/commands/external/external.command.ts"
        InitCmd["Init Command\ninit.command.ts"]:::nodeBlue
        click InitCmd "https://github.com/avivbens/shell-config/blob/master/src/commands/init/init.command.ts"
        InitScript["Init-Script Command\ninit-script.command.ts"]:::nodeBlue
        click InitScript "https://github.com/avivbens/shell-config/blob/master/src/commands/init-script/init-script.command.ts"
        Install["Install Command\ninstall.command.ts"]:::nodeBlue
        click Install "https://github.com/avivbens/shell-config/blob/master/src/commands/install/install.command.ts"
        ShellCmd["Shell Command\nshell.command.ts"]:::nodeBlue
        click ShellCmd "https://github.com/avivbens/shell-config/blob/master/src/commands/shell/shell.command.ts"
        Update["Update Command\nupdate.command.ts"]:::nodeBlue
        click Update "https://github.com/avivbens/shell-config/blob/master/src/commands/update/update.command.ts"
    end
    Router -->|routes to| Assets
    Router --> External
    Router --> InitCmd
    Router --> InitScript
    Router --> Install
    Router --> ShellCmd
    Router --> Update

    %% Core Services
    subgraph "Core Services"
        direction TB
        LoggerModule["Logger Module\nlogger.module.ts"]:::nodeBlue
        click LoggerModule "https://github.com/avivbens/shell-config/blob/master/src/services/logger/logger.module.ts"
        LoggerService["Logger Service\nlogger.service.ts"]:::nodeBlue
        click LoggerService "https://github.com/avivbens/shell-config/blob/master/src/services/logger/logger.service.ts"
        LoggerDecorator["Logger Decorator\nlogger.decorator.ts"]:::nodeBlue
        click LoggerDecorator "https://github.com/avivbens/shell-config/blob/master/src/services/logger/decorators/logger.decorator.ts"
        UpdateService["Check Update Service\ncheck-update.service.ts"]:::nodeBlue
        click UpdateService "https://github.com/avivbens/shell-config/blob/master/src/services/check-update.service.ts"
    end
    Assets -->|uses| LoggerService
    External --> LoggerService
    InitCmd --> LoggerService
    InitScript --> LoggerService
    Install --> LoggerService
    ShellCmd --> LoggerService
    Update --> LoggerService
    Assets -->|checks update| UpdateService
    External --> UpdateService
    InitCmd --> UpdateService
    InitScript --> UpdateService
    Install --> UpdateService
    ShellCmd --> UpdateService
    Update --> UpdateService

    %% Common Utilities
    subgraph "Common Utilities"
        direction TB
        Inquirer["Inquirer Wrapper\ninquirer.ts"]:::nodeBlue
        click Inquirer "https://github.com/avivbens/shell-config/blob/master/src/common/inquirer.ts"
        SelectRenderer["Select Prompt Renderer\nselect-prompt.renderer.ts"]:::nodeBlue
        click SelectRenderer "https://github.com/avivbens/shell-config/blob/master/src/common/renderers/select-prompt.renderer.ts"
        Utils["Utilities\nutils.ts"]:::nodeBlue
        click Utils "https://github.com/avivbens/shell-config/blob/master/src/common/utils.ts"
        Constants["Constants\nconstants.ts"]:::nodeBlue
        click Constants "https://github.com/avivbens/shell-config/blob/master/src/common/constants.ts"
    end
    Assets -->|prompts| Inquirer
    External --> Inquirer
    InitCmd --> Inquirer
    InitScript --> Inquirer
    Install --> Inquirer
    ShellCmd --> Inquirer
    Update --> Inquirer

    %% Templates & Config
    TemplateFS["Templates & Config\ntemplates/, zsh/, src/commands/*/config/"]:::fsGrey
    click TemplateFS "https://github.com/avivbens/shell-config/tree/master/templates/"
    click TemplateFS "https://github.com/avivbens/shell-config/tree/master/zsh/"
    Assets -->|renders| TemplateFS
    External --> TemplateFS
    InitCmd --> TemplateFS
    InitScript --> TemplateFS
    Install --> TemplateFS
    ShellCmd --> TemplateFS

    %% External Shell Scripts
    subgraph "Shell Scripts" 
        direction TB
        InitBeta["init-beta.sh"]:::shellGreen
        click InitBeta "https://github.com/avivbens/shell-config/blob/master/src/scripts/init-beta.sh"
        PackJS["pack.js"]:::shellGreen
        click PackJS "https://github.com/avivbens/shell-config/blob/master/project-scripts/pack.js"
        PackLocal["pack-local.sh"]:::shellGreen
        click PackLocal "https://github.com/avivbens/shell-config/blob/master/project-scripts/pack-local.sh"
    end
    InitCmd -->|executes| InitBeta
    InitCmd -->|executes| ScriptInit
    InitCmd -->|executes| PackJS
    InitCmd -->|executes| PackLocal
    Install -->|executes| InitBeta
    Install -->|executes| ScriptInit

    %% OS Interfaces
    Brew["Homebrew (brew)"]:::extOrange
    ZshShell["Zsh Shell"]:::extOrange
    Install -->|spawn brew| Brew
    ShellCmd -->|reload| ZshShell
    InitScript -->|spawn shell| ZshShell

    %% Documentation
    DocsFS["Documentation Site\ndocs/, assets/"]:::fsGrey
    click DocsFS "https://github.com/avivbens/shell-config/tree/master/docs/"
    click DocsFS "https://github.com/avivbens/shell-config/tree/master/assets/"
    DocsFS -.->|served via VitePress| Router

    %% Styles
    classDef nodeBlue fill:#D0E8FF,stroke:#0366d6
    classDef shellGreen fill:#DFF5E1,stroke:#2F8F00
    classDef extOrange fill:#FFE8B0,stroke:#D97706
    classDef fsGrey fill:#F0F0F0,stroke:#999999
```
