# nizarcan/ncanrc architecture

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

- Interactive diagram: https://gitdiagram.com/nizarcan/ncanrc
- Repository: https://github.com/nizarcan/ncanrc

## Overview

##### Project type and purpose
- This is a dotfiles/configuration-management repository (“ncanrc”) whose purpose is to centralize, version-control, and automate the setup of development and shell environments.
- Key indicators: a top-level `run.sh` orchestrator, `config/` directory for various tool configurations, `scripts/` for operations (install, backup, clean), and `utilities/` for standalone helper scripts.

##### File structure
- Top-level components:
- run.sh – the main entry point and CLI dispatcher
- config/ – subfolders per tool (alacritty, ghostty, git, nvim, tmux, zsh) containing dotfiles
- scripts/ – operation scripts (sym, brew, clean, backup, load_backup, etc.)
- utilities/ – reusable helper scripts, further organized into “personal”, “tmux”, “work”
- Patterns: a layered architecture where run.sh invokes scripts which in turn apply or manipulate files in config/ or utilities/
- External dependencies: Homebrew, Oh My Zsh, tmux, neovim, Alacritty, Ghostty, standard UNIX commands

##### README for additional insights
- README outlines available commands and maps them to specific scripts
- It describes usage of run.sh as unified interface

##### Detail
- Script’s purpose (label backups, installs, cleans)
- Backup flow: scripts/backup.sh → config/ → backup directory
- Don’t lump everything together: keep each tool’s config as its own block under the “Config Store”
- Extensibility: call-out how to add a new tool (add config folder + script + run.sh case)

## Diagram (Mermaid)

```mermaid
graph TD
    subgraph "Orchestrator Layer"
        Run["run.sh Orchestrator"]:::orchestrator
    end

    subgraph "Scripts Layer"
        Sym["sym.sh (Symlink Module)"]:::scripts
        Brew["brew.sh (Homebrew Module)"]:::scripts
        Install["install.sh (Oh My Zsh Module)"]:::scripts
        Clean["clean.sh (Clean Module)"]:::scripts
        Backup["backup.sh (Backup Module)"]:::scripts
        ClearBackup["clear_backup.sh (Clear Backup Module)"]:::scripts
        LoadBackup["load_backup.sh (Load Backup Module)"]:::scripts
    end

    subgraph "Configuration Store"
        Alac["alacritty.toml (Alacritty Config)"]:::config
        GhostCfg["config (Ghostty Config)"]:::config
        GhostExe["ghostty (Ghostty Executable)"]:::config
        GitCfg["gitconfig (Git Config)"]:::config
        Nvim["nvim/ (Neovim Config)"]:::config
        TmuxCfg["tmux.conf (Tmux Config)"]:::config
        ZshCfg["zshrc (Zsh Config)"]:::config
    end

    subgraph "Utilities"
        Personal["personal/ (Personal Utilities)"]:::utilities
        TmuxUtil["tmux-session.sh (Tmux Utilities)"]:::utilities
        WorkUtil["work/ (Work Utilities)"]:::utilities
    end

    subgraph "External Systems"
        OS["OS FileSystem"]:::external
        HomebrewExt["Homebrew"]:::external
        OhMyZshExt["Oh My Zsh"]:::external
        TmuxExt["tmux"]:::external
        NvimExt["neovim"]:::external
        ZshExt["zsh"]:::external
        AlacExt["Alacritty"]:::external
        GhosttyExt["Ghostty"]:::external
    end

    %% Orchestration flow
    Run -->|"dispatch"| Sym
    Run -->|"dispatch"| Brew
    Run -->|"dispatch"| Install
    Run -->|"dispatch"| Clean
    Run -->|"dispatch"| Backup
    Run -->|"dispatch"| ClearBackup
    Run -->|"dispatch"| LoadBackup

    %% Scripts to Config
    Sym -->|"symlink files"| Alac
    Sym -->|"symlink files"| GhostCfg
    Sym -->|"symlink files"| GhostExe
    Sym -->|"symlink files"| GitCfg
    Sym -->|"symlink files"| Nvim
    Sym -->|"symlink files"| TmuxCfg
    Sym -->|"symlink files"| ZshCfg

    Brew -->|"install packages"| HomebrewExt
    Install -->|"set up shell"| OhMyZshExt
    Clean -->|"remove configs"| OS
    Backup -->|"backup configs"| OS
    ClearBackup -->|"clear backup"| OS
    LoadBackup -->|"restore backup"| OS

    %% Scripts use Utilities
    Sym -->|"use helpers"| Personal
    Sym -->|"use helpers"| TmuxUtil
    Sym -->|"use helpers"| WorkUtil

    %% Utilities installed in PATH
    Personal -->|"added to PATH"| OS
    TmuxUtil -->|"added to PATH"| OS
    WorkUtil -->|"added to PATH"| OS

    %% Config used by external tools at runtime
    Alac -->|"read|write"| AlacExt
    GhostCfg -->|"read|write"| GhosttyExt
    GhostExe -->|"execute"| GhosttyExt
    GitCfg -->|"read|write"| OS
    Nvim -->|"read|write"| NvimExt
    TmuxCfg -->|"read|write"| TmuxExt
    ZshCfg -->|"read|write"| ZshExt

    %% Click Events
    click Run "https://github.com/nizarcan/ncanrc/blob/main/run.sh"
    click Sym "https://github.com/nizarcan/ncanrc/blob/main/scripts/sym.sh"
    click Brew "https://github.com/nizarcan/ncanrc/blob/main/scripts/brew.sh"
    click Install "https://github.com/nizarcan/ncanrc/blob/main/scripts/install.sh"
    click Clean "https://github.com/nizarcan/ncanrc/blob/main/scripts/clean.sh"
    click Backup "https://github.com/nizarcan/ncanrc/blob/main/scripts/backup.sh"
    click ClearBackup "https://github.com/nizarcan/ncanrc/blob/main/scripts/clear_backup.sh"
    click LoadBackup "https://github.com/nizarcan/ncanrc/blob/main/scripts/load_backup.sh"
    click Alac "https://github.com/nizarcan/ncanrc/blob/main/config/alacritty/alacritty.toml"
    click GhostCfg "https://github.com/nizarcan/ncanrc/tree/main/config/ghostty/config"
    click GhostExe "https://github.com/nizarcan/ncanrc/tree/main/config/ghostty/ghostty"
    click GitCfg "https://github.com/nizarcan/ncanrc/tree/main/config/git/gitconfig"
    click Nvim "https://github.com/nizarcan/ncanrc/tree/main/config/nvim/"
    click TmuxCfg "https://github.com/nizarcan/ncanrc/blob/main/config/tmux/tmux.conf"
    click ZshCfg "https://github.com/nizarcan/ncanrc/tree/main/config/zsh/zshrc"
    click Personal "https://github.com/nizarcan/ncanrc/tree/main/utilities/personal/"
    click TmuxUtil "https://github.com/nizarcan/ncanrc/blob/main/utilities/tmux/tmux-session.sh"
    click WorkUtil "https://github.com/nizarcan/ncanrc/tree/main/utilities/work/"

    %% Styles
    classDef orchestrator fill:#89CFF0,stroke:#333,stroke-width:1px
    classDef scripts fill:#90EE90,stroke:#333,stroke-width:1px
    classDef config fill:#FFD700,stroke:#333,stroke-width:1px
    classDef utilities fill:#FFA500,stroke:#333,stroke-width:1px
    classDef external fill:#D3D3D3,stroke:#333,stroke-width:1px
```
