# インフラ構成図

## 全体構成図

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

    subgraph GitHub["GitHub (tailwindlabs/tailwindcss)"]
        REPO[Git リポジトリ]
        subgraph Actions["GitHub Actions CI/CD"]
            CI[CI ワークフロー]
            IT[Integration Tests ワークフロー]
            RI[Release Insiders ワークフロー]
            PR[Prepare Release ワークフロー]
            REL[Release ワークフロー]
        end
        GHR[GitHub Releases]
        ART[GitHub Artifacts]
        SEC[GitHub Secrets]
    end

    subgraph BuildMatrix["ビルドマトリクス"]
        LINUX[Linux Runner<br/>namespace-profile-default]
        MACOS[macOS Runner<br/>macos-14 M1]
        WIN[Windows Runner<br/>windows-latest]
        FBSD[FreeBSD VM<br/>14.0 / 13GB RAM]
    end

    subgraph Containers["ビルドコンテナ (ghcr.io)"]
        DEB[napi-rs/nodejs-rust<br/>lts-debian]
        DEB_ARM[napi-rs/nodejs-rust<br/>lts-debian-aarch64]
        DEB_ZIG[napi-rs/nodejs-rust<br/>lts-debian-zig]
        ALP[napi-rs/nodejs-rust<br/>lts-alpine]
    end

    subgraph Registry["パッケージレジストリ"]
        NPM[npm レジストリ<br/>npmjs.org]
        CRATES[crates.io]
    end

    subgraph Notification["通知"]
        DISCORD[Discord<br/>Webhook]
    end

    subgraph External["外部サービス"]
        PLAY[Tailwind Play<br/>tailwindlabs/upgrades]
        RUSTUP[static.rust-lang.org<br/>Rust ツールチェイン]
    end

    DEV -->|push / PR| REPO
    REPO -->|push to main| CI
    REPO -->|push to main| IT
    REPO -->|push to main| RI
    REPO -->|tag push v*| PR
    REPO -->|release published| REL

    CI --> LINUX
    CI --> MACOS
    CI --> WIN
    IT --> LINUX
    IT --> MACOS
    IT --> WIN

    RI --> BuildMatrix
    PR --> BuildMatrix
    REL --> BuildMatrix

    LINUX --> DEB
    LINUX --> DEB_ARM
    LINUX --> DEB_ZIG
    LINUX --> ALP
    LINUX --> FBSD

    BuildMatrix -->|ネイティブバイナリ| ART
    ART -->|アーティファクト統合| REL
    REL -->|npm publish| NPM
    PR -->|GitHub Release 作成| GHR

    CI -->|失敗通知| DISCORD
    IT -->|失敗通知| DISCORD
    REL -->|リリース通知| PLAY

    SEC -->|NPM_TOKEN| NPM
    SEC -->|DISCORD_WEBHOOK_URL| DISCORD
    SEC -->|TAILWIND_PLAY_TOKEN| PLAY

    BuildMatrix -->|Cargo 依存取得| CRATES
    BuildMatrix -->|rustup| RUSTUP
```

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

```mermaid
flowchart LR
    subgraph Trigger["トリガー"]
        PUSH[push to main]
        PR_EV[Pull Request]
        TAG[Tag push v*]
        RELEASE[Release published]
    end

    subgraph CI_Pipeline["CI パイプライン"]
        direction TB
        CHECKOUT1[Checkout]
        SETUP1[Node.js / pnpm / Rust セットアップ]
        CACHE1[キャッシュ復元<br/>Cargo / Oxide / pnpm]
        BUILD1[ビルド<br/>pnpm run build]
        LINT1[Lint<br/>prettier --check]
        TEST1[テスト<br/>cargo test + vitest]
        UITEST1[UI テスト<br/>Playwright]
    end

    subgraph INT_Pipeline["Integration Tests パイプライン"]
        direction TB
        CHECKOUT2[Checkout]
        SETUP2[セットアップ]
        BUILD2[ビルド]
        INT_TEST[統合テスト<br/>vite / cli / postcss<br/>oxide / webpack / upgrade]
    end

    subgraph Release_Pipeline["リリースパイプライン"]
        direction TB
        CROSS[クロスコンパイルビルド<br/>14ターゲット並列]
        UPLOAD[アーティファクト<br/>アップロード]
        DOWNLOAD[アーティファクト<br/>ダウンロード・統合]
        BUILD_FINAL[最終ビルド]
        OPTIMIZE[プリパブリッシュ最適化]
        PUBLISH[npm publish<br/>--tag latest/insiders]
        GH_REL[GitHub Release 作成]
        NOTIFY_PLAY[Tailwind Play 更新]
    end

    subgraph Notify["通知"]
        DISCORD_N[Discord 通知<br/>main ブランチ失敗時]
    end

    PUSH --> CI_Pipeline
    PR_EV --> CI_Pipeline
    PUSH --> INT_Pipeline
    PR_EV --> INT_Pipeline
    PUSH --> Release_Pipeline
    TAG --> Release_Pipeline
    RELEASE --> Release_Pipeline

    CHECKOUT1 --> SETUP1 --> CACHE1 --> BUILD1 --> LINT1 --> TEST1 --> UITEST1
    CHECKOUT2 --> SETUP2 --> BUILD2 --> INT_TEST

    CROSS --> UPLOAD --> DOWNLOAD --> BUILD_FINAL --> OPTIMIZE --> PUBLISH --> GH_REL --> NOTIFY_PLAY

    CI_Pipeline -->|失敗時| DISCORD_N
    INT_Pipeline -->|失敗時| DISCORD_N
```

## クロスコンパイルビルドターゲット図

```mermaid
graph TD
    subgraph Targets["ビルドターゲット一覧"]
        subgraph Windows_T["Windows"]
            W1[x86_64-pc-windows-msvc]
            W2[aarch64-pc-windows-msvc]
        end
        subgraph macOS_T["macOS"]
            M1[x86_64-apple-darwin]
            M2[aarch64-apple-darwin]
        end
        subgraph Linux_T["Linux"]
            L1[x86_64-unknown-linux-gnu]
            L2[x86_64-unknown-linux-musl]
            L3[aarch64-unknown-linux-gnu]
            L4[aarch64-unknown-linux-musl]
            L5[armv7-unknown-linux-gnueabihf]
        end
        subgraph Android_T["Android"]
            A1[aarch64-linux-android]
            A2[armv7-linux-androideabi]
        end
        subgraph Other_T["その他"]
            F1[x86_64-unknown-freebsd]
            WA[wasm32-wasip1-threads]
        end
    end

    subgraph Runners["ビルドランナー"]
        WIN_R[windows-latest]
        MAC_R[macos-latest]
        UBU_R[ubuntu-latest]
        FBSD_R[FreeBSD VM]
    end

    WIN_R --> W1
    WIN_R --> W2
    MAC_R --> M1
    MAC_R --> M2
    UBU_R --> L1
    UBU_R --> L2
    UBU_R --> L3
    UBU_R --> L4
    UBU_R --> L5
    UBU_R --> A1
    UBU_R --> A2
    FBSD_R --> F1
    MAC_R --> WA
```

## モノレポパッケージ構成図

```mermaid
graph TD
    subgraph Packages["パッケージ構成"]
        CORE[tailwindcss<br/>コアライブラリ]
        CLI[@tailwindcss/cli<br/>CLI ツール]
        POSTCSS[@tailwindcss/postcss<br/>PostCSS プラグイン]
        VITE[@tailwindcss/vite<br/>Vite プラグイン]
        WEBPACK[@tailwindcss/webpack<br/>Webpack プラグイン]
        NODE[@tailwindcss/node<br/>Node.js ユーティリティ]
        BROWSER[@tailwindcss/browser<br/>ブラウザ用ビルド]
        STANDALONE[@tailwindcss/standalone<br/>スタンドアロン CLI]
        UPGRADE[@tailwindcss/upgrade<br/>アップグレードツール]
    end

    subgraph Rust_Crates["Rust クレート"]
        OXIDE[tailwindcss-oxide<br/>コアエンジン]
        OXIDE_NODE[@tailwindcss/oxide<br/>Node.js バインディング]
        IGNORE[ignore<br/>ファイル無視]
        CLASS_MACRO[classification-macros<br/>マクロ]
    end

    subgraph BuildTools["ビルドツール"]
        PNPM[pnpm 9.6.0]
        TURBO[Turborepo]
        CARGO[Cargo / Rust]
        TSUP[tsup]
        BUN[Bun]
    end

    CLI --> CORE
    CLI --> NODE
    CLI --> OXIDE_NODE
    POSTCSS --> CORE
    POSTCSS --> NODE
    VITE --> CORE
    VITE --> NODE
    WEBPACK --> CORE
    WEBPACK --> NODE
    STANDALONE --> CLI
    STANDALONE --> CORE
    BROWSER --> CORE
    CORE --> OXIDE_NODE
    OXIDE_NODE --> OXIDE
    OXIDE --> IGNORE
    OXIDE --> CLASS_MACRO

    PNPM --> TURBO
    TURBO --> TSUP
    TURBO --> CARGO
    BUN --> STANDALONE
```
