# jetbrains/bazel architecture

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

- Interactive diagram: https://gitdiagram.com/jetbrains/bazel
- Repository: https://github.com/jetbrains/bazel

## Overview

##### Project type and purpose
- This is an open-source integration/patch-management tool (“bazel-jetbrains-build”) that sits on top of the JetBrains build pipeline and leverages Bazel.
- It maintains a curated set of source-code patches (in the `patches/` directory) and a GitHub Actions CI workflow (`.github/workflows/on-push.yml`) to apply those patches whenever the JetBrains code is fetched and built by Bazel.

##### File structure
- Top-level files:
- `.editorconfig`, `.gitattributes` – formatting and Git settings
- `README.md`, `bazel-tag.txt` – high-level documentation and versioning tag for Bazel
- Directories:
- `patches/` – a sequence of numbered `.patch` files, each implementing a discrete change to JetBrains sources or the Bazel integration
- `.github/workflows/` – CI configuration that runs on every push
- No “src” or “lib” folders for application code; the repository’s primary “function” is the management and application of patches via Bazel in CI.

##### README for additional insights
- The README title “bazel-jetbrains-build” signals the integration between Bazel and JetBrains build pipelines.
- No further sections are present, so we infer behavior from file names: HTTP download handlers, file watchers, credential logic, caching—these are patch areas, not internal modules of this repo.

a. Main components
- Developer Workstation
- GitHub Repository (this project)
- GitHub Actions CI Runner
- Bazel Build System
- JetBrains Source Code (external)
- Patch Application Engine (sequences the `.patch` files)
- Artifact Storage / Distribution (built IDE packages)
b. Relationships & interactions
1. Developer pushes code → GitHub Repo
2. GitHub Actions CI triggers on ‛push’ event
3. CI pulls JetBrains sources & Bazel tag (from `bazel-tag.txt`)
4. Patch Application Engine reads patches/0001…000n → applies to sources
5. CI invokes Bazel to build patched sources
6. Build artifacts are published (e.g., to GitHub Releases or internal store)
c. Architectural patterns and principles
- Single responsibility: each patch addresses one issue/feature in isolation
- Immutable builds: use explicit Bazel tag to fix source version
- CI as code: workflow defined in YAML under version control
d. Key technologies
- Git/GitHub for source hosting and patch versioning
- GitHub Actions for CI orchestration
- Bazel as the hermetic build system
- Standard UNIX `patch` or Git’s `apply` for patch steps

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "Developer Workstation"
        DEV["Developer"]:::ext
    end

    subgraph "GitHub Repository"
        REPO["GitHub Repo"]:::vc
        DOC["README.md"]:::doc
        CFG1[".editorconfig"]:::doc
        CFG2[".gitattributes"]:::doc
        PATCHES["patches/"]:::vc
        CIYML[".github/workflows/on-push.yml"]:::build
        TAG["bazel-tag.txt"]:::build
    end

    subgraph "CI & Build"
        CI["CI Runner"]:::build
        ENGINE["Patch Application Engine"]:::build
        BAZEL["Bazel Build System"]:::build
    end

    subgraph "External Services"
        JB["JetBrains Source"]:::ext
        ARTIFACTS["Artifact Store"]:::ext
    end

    DEV -->|"push code"| REPO
    REPO -->|"trigger on push"| CI
    CI -->|"fetch JetBrains sources"| JB
    CI -->|"read bazel-tag"| TAG
    CI -->|"invoke patch engine"| ENGINE
    ENGINE -->|"apply patches"| PATCHES
    ENGINE -->|"patched source"| BAZEL
    BAZEL -->|"build artifacts"| ARTIFACTS

    click REPO "https://github.com/jetbrains/bazel/tree/master//"
    click DOC "https://github.com/jetbrains/bazel/blob/master//README.md"
    click CFG1 "https://github.com/jetbrains/bazel/blob/master//.editorconfig"
    click CFG2 "https://github.com/jetbrains/bazel/blob/master//.gitattributes"
    click PATCHES "https://github.com/jetbrains/bazel/tree/master//patches/"
    click CIYML "https://github.com/jetbrains/bazel/blob/master//.github/workflows/on-push.yml"
    click TAG "https://github.com/jetbrains/bazel/blob/master//bazel-tag.txt"

    classDef vc fill:#add8e6,stroke:#000,stroke-width:1px
    classDef build fill:#90ee90,stroke:#000,stroke-width:1px
    classDef ext fill:#ffa500,stroke:#000,stroke-width:1px
    classDef doc fill:#f4a60d,stroke:#000,stroke-width:1px
```
