# インフラ構成図

## システム全体構成図

```mermaid
graph TB
    subgraph "開発者環境"
        DEV[開発者]
    end

    subgraph "GitHub Platform"
        REPO[GitHub Repository<br/>liuchengxu/space-vim]
        GHA[GitHub Actions<br/>CI/CD Runner]
        PAGES[GitHub Pages<br/>gh-pages branch]

        REPO --> GHA
        REPO --> PAGES
    end

    subgraph "外部サービス"
        VINT[reviewdog/action-vint]
        PPA[deadsnakes PPA]
        PYPI[PyPI]
    end

    subgraph "ユーザー環境"
        USER[エンドユーザー]
        LOCAL[ローカル環境<br/>~/.space-vim]
        VIMPLUG[vim-plug]
        VIM[Vim / NeoVim]
    end

    subgraph "プラグインリポジトリ"
        PLUGINS[各種Vimプラグイン<br/>GitHub上の各リポジトリ]
    end

    DEV -->|push/PR| REPO
    GHA -->|lint| VINT
    GHA -->|apt| PPA
    GHA -->|pip| PYPI

    USER -->|git clone| REPO
    USER -->|browse| PAGES
    REPO -->|install.sh| LOCAL
    LOCAL --> VIM
    VIM --> VIMPLUG
    VIMPLUG -->|:PlugInstall| PLUGINS
```

## CI/CDパイプライン構成図

```mermaid
flowchart LR
    subgraph "トリガー"
        PUSH[Push]
        PR[Pull Request]
    end

    subgraph "GitHub Actions Workflow"
        subgraph "vint job"
            CHECKOUT1[Checkout]
            VINT[reviewdog/action-vint]
        end

        subgraph "install-script job"
            CHECKOUT2[Checkout]
            APT[apt-get install<br/>shellcheck, python3.6]
            SHELLCHECK[shellcheck *.sh]
            INSTALL[./install.sh]
        end
    end

    PUSH --> CHECKOUT1
    PUSH --> CHECKOUT2
    PR --> CHECKOUT1
    PR --> CHECKOUT2

    CHECKOUT1 --> VINT
    CHECKOUT2 --> APT --> SHELLCHECK --> INSTALL
```

## インストールフロー図

```mermaid
sequenceDiagram
    participant User as ユーザー
    participant Script as install.sh
    participant GitHub as GitHub
    participant VimPlug as vim-plug
    participant Plugins as プラグインリポジトリ

    User->>Script: bash install.sh
    Script->>Script: check git exists
    Script->>GitHub: git clone space-vim
    GitHub-->>Script: リポジトリ取得
    Script->>Script: backup existing config
    Script->>GitHub: curl vim-plug
    GitHub-->>Script: plug.vim取得
    Script->>Script: create symlinks
    Script->>Script: generate .spacevim
    Script->>VimPlug: vim +PlugInstall
    VimPlug->>Plugins: 各プラグインダウンロード
    Plugins-->>VimPlug: プラグイン取得
    VimPlug-->>User: インストール完了
```

## ディレクトリ構成図

```mermaid
graph TB
    subgraph "space-vim Repository"
        ROOT[space-vim/]

        CORE[core/]
        LAYERS[layers/]
        CI[ci/]
        GITHUB[.github/]

        ROOT --> CORE
        ROOT --> LAYERS
        ROOT --> CI
        ROOT --> GITHUB

        subgraph "core/"
            AUTOLOAD[autoload/]
            FTPLUGIN[ftplugin/]
            PLUGIN[plugin/]
            DOC[doc/]
        end

        CORE --> AUTOLOAD
        CORE --> FTPLUGIN
        CORE --> PLUGIN
        CORE --> DOC

        subgraph "layers/"
            DISTRIBUTIONS[+distributions/]
            LANG[+lang/]
            TOOLS[+tools/]
            THEMES[+themes/]
            VC[+version-control/]
            VIMEXT[+vim/]
            CHECKERS[+checkers/]
        end

        LAYERS --> DISTRIBUTIONS
        LAYERS --> LANG
        LAYERS --> TOOLS
        LAYERS --> THEMES
        LAYERS --> VC
        LAYERS --> VIMEXT
        LAYERS --> CHECKERS
    end

    subgraph "User Environment"
        HOME[~/]
        SPACEVIM[.spacevim]
        VIMRC[.vimrc]
        NVIMRC[.config/nvim/init.vim]
        PLUGGED[.vim/plugged/]

        HOME --> SPACEVIM
        HOME --> VIMRC
        HOME --> NVIMRC
        HOME --> PLUGGED
    end

    ROOT -.->|symlink| VIMRC
    ROOT -.->|symlink| NVIMRC
```

## プラットフォーム別構成図

```mermaid
graph TB
    subgraph "Linux / macOS"
        L_USER[ユーザー]
        L_INSTALL[install.sh / Makefile]
        L_VIMRC[~/.vimrc]
        L_NVIMRC[~/.config/nvim/init.vim]
        L_SPACEVIM[~/.spacevim]
        L_PLUGGED[~/.vim/plugged/]

        L_USER --> L_INSTALL
        L_INSTALL --> L_VIMRC
        L_INSTALL --> L_NVIMRC
        L_INSTALL --> L_SPACEVIM
        L_INSTALL --> L_PLUGGED
    end

    subgraph "Windows"
        W_USER[ユーザー]
        W_INSTALL[install.cmd<br/>管理者権限]
        W_VIMRC[%USERPROFILE%\_vimrc]
        W_GVIMRC[%USERPROFILE%\_gvimrc]
        W_SPACEVIM[%USERPROFILE%\.spacevim]

        W_USER --> W_INSTALL
        W_INSTALL --> W_VIMRC
        W_INSTALL --> W_GVIMRC
        W_INSTALL --> W_SPACEVIM
    end
```

## 依存関係図

```mermaid
graph LR
    subgraph "必須依存"
        GIT[Git]
        CURL[curl]
        VIM[Vim 8.0+ / NeoVim 0.4+]
    end

    subgraph "推奨ツール"
        FZF[fzf]
        RG[ripgrep]
        AG[ag]
    end

    subgraph "CI依存"
        SHELLCHECK[shellcheck]
        PYTHON[Python 3.6]
        VINT[vim-vint]
    end

    SPACEVIM[space-vim]

    GIT --> SPACEVIM
    CURL --> SPACEVIM
    VIM --> SPACEVIM

    FZF -.->|optional| SPACEVIM
    RG -.->|optional| SPACEVIM
    AG -.->|optional| SPACEVIM

    SHELLCHECK --> CI[CI Pipeline]
    PYTHON --> VINT
    VINT --> CI
```
