# dbl-works/rubocop-dbl architecture

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

- Interactive diagram: https://gitdiagram.com/dbl-works/rubocop-dbl
- Repository: https://github.com/dbl-works/rubocop-dbl

## Overview

##### Project type and purpose
- This is an open‑source Ruby gem (“rubocop-dbl”) that provides a shared RuboCop configuration for Ruby on Rails projects.
- It bundles a set of Cop rules (in config/cops/*.yml and config/dbl.yml), a Rails generator to install those configs into a host app, and supporting scripts for release and CI.

##### File structure
- Top‑level components:
- bin/ – release helper script (bin/release)
- config/ – all the RuboCop configuration YAML files and subfolders for different rule categories
- lib/ – the generator code (lib/generators/rubocop_dbl/install_generator.rb) and version file
- rubocop-dbl.gemspec & Gemfile – gem metadata and dependencies
- .github/workflows/test.yml – CI configuration
- test/ – fixture RuboCop configs for internal testing
- Patterns & roles: it’s a library/plugin (no frontend/backend), with:
- “generator” submodule to scaffold config in host apps
- “config” module of static YAML definitions
- CI/build scripts to test & release the gem

##### README for additional insights
- Describes installation via Gemfile, setup via Rails generator or manual inherit_gem
- Publishes releases to RubyGems via bin/release
- CI runs tests across Ruby–Rails matrix (test.yml)

a. Main components
1. Developer workspace / GitHub repo
2. CI pipeline (GitHub Actions)
3. RubyGems Registry
4. Host Rails Application
5. Bundler & RuboCop Engine
6. rubocop-dbl gem internals (config files + generator + version)
b. Relationships & interactions
- Developer pushes to GitHub → CI workflow runs tests across Ruby/Rails versions
- On tagged release → bin/release publishes to RubyGems
- Host app adds gem to Gemfile → Bundler installs from RubyGems
- Host app runs “rails generate rubocop_dbl:install” → generator reads gem’s config files and writes into .rubocop.yml
- rubocop execution in host app loads .rubocop.yml → inherit_gem loads rule definitions from the gem’s config
c. Architectural patterns & principles
- Plugin/extension architecture: the gem “plugs in” to RuboCop via inherit_gem
- Convention over configuration: generator scaffolds a standard setup
- CI matrix testing ensures compatibility across Ruby/Rails versions
d. Key technologies/frameworks
- RubyGems & Bundler as package distribution
- RuboCop engine for static analysis
- Rails generator API for installation
- GitHub Actions for CI
- RSpec or Minitest under test/ for gem self‑tests

##### Elements
- Git push → CI
- CI → RubyGems (on release)
- Host App → Bundler → rubocop-dbl gem
- Generator → writes config → Host App .rubocop.yml
- RuboCop CLI → loads config from both Host .rubocop.yml and gem
- External services (GitHub Actions, RubyGems) in another
- Host app environment in a third

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Actors
    Dev["Developer"]:::external
    Repo["GitHub Repository"]:::external
    CI["GitHub Actions CI"]:::external
    TestSuite["Test Suite & Fixtures"]:::lib
    ReleaseScript["Release Script"]:::lib
    Rake["CI/Test Rake Tasks"]:::lib
    Readme["README.md"]:::lib

    %% Gem Package
    subgraph "rubocop-dbl gem"
        direction TB
        GemSpec["rubocop-dbl.gemspec"]:::lib
        Version["lib/rubocop_dbl/version.rb"]:::lib
        InstallGen["Rails Generator"]:::lib
        subgraph "Static Config Module"
            direction TB
            SC_dbl["config/dbl.yml"]:::lib
            SC_layout["config/cops/layout.yml"]:::lib
            SC_lint["config/cops/lint.yml"]:::lib
            SC_metrics["config/cops/metrics.yml"]:::lib
            SC_naming["config/cops/naming.yml"]:::lib
            SC_perf["config/cops/performance.yml"]:::lib
            SC_rspec["config/cops/rspec.yml"]:::lib
            SC_style["config/cops/style.yml"]:::lib
            SC_types["config/cops/types.yml"]:::lib
        end
    end

    %% External Services and Host
    RubyGems["RubyGems Registry"]:::external
    subgraph "Host Rails App"
        direction TB
        Bundler["Bundler"]:::host
        HostConfig[".rubocop.yml"]:::host
        RuboCopCLI["RuboCop CLI"]:::host
    end

    %% Flows
    Dev -->|push code| Repo
    Repo -->|run tests| CI
    CI -->|uses fixtures| TestSuite
    CI -->|on tag| ReleaseScript
    ReleaseScript -->|publishes| RubyGems

    HostRailsAppStart(( )) --> HostAppInvoke
    HostAppInvoke["Host Rails App"]:::host
    HostAppInvoke -->|adds gem to Gemfile| Bundler
    Bundler -->|installs gem| rubocop_dbl
    rubocop_dbl["rubocop-dbl gem"] --> Bundler

    HostAppInvoke -->|runs generator| InstallGen
    InstallGen -->|writes configs| HostConfig
    HostAppInvoke -->|runs analysis| RuboCopCLI
    RuboCopCLI -->|loads| HostConfig
    RuboCopCLI -->|inherits rules| SC_dbl

    %% Click Events
    click CI "https://github.com/dbl-works/rubocop-dbl/blob/main/.github/workflows/test.yml"
    click TestSuite "https://github.com/dbl-works/rubocop-dbl/blob/main/test/fixture/.rubocop.yml"
    click ReleaseScript "https://github.com/dbl-works/rubocop-dbl/tree/main/bin/release"
    click Rake "https://github.com/dbl-works/rubocop-dbl/tree/main/Rakefile"
    click Readme "https://github.com/dbl-works/rubocop-dbl/blob/main/README.md"
    click GemSpec "https://github.com/dbl-works/rubocop-dbl/blob/main/rubocop-dbl.gemspec"
    click Version "https://github.com/dbl-works/rubocop-dbl/blob/main/lib/rubocop_dbl/version.rb"
    click InstallGen "https://github.com/dbl-works/rubocop-dbl/blob/main/lib/generators/rubocop_dbl/install_generator.rb"
    click SC_dbl "https://github.com/dbl-works/rubocop-dbl/blob/main/config/dbl.yml"
    click SC_layout "https://github.com/dbl-works/rubocop-dbl/blob/main/config/cops/layout.yml"
    click SC_lint "https://github.com/dbl-works/rubocop-dbl/blob/main/config/cops/lint.yml"
    click SC_metrics "https://github.com/dbl-works/rubocop-dbl/blob/main/config/cops/metrics.yml"
    click SC_naming "https://github.com/dbl-works/rubocop-dbl/blob/main/config/cops/naming.yml"
    click SC_perf "https://github.com/dbl-works/rubocop-dbl/blob/main/config/cops/performance.yml"
    click SC_rspec "https://github.com/dbl-works/rubocop-dbl/blob/main/config/cops/rspec.yml"
    click SC_style "https://github.com/dbl-works/rubocop-dbl/blob/main/config/cops/style.yml"
    click SC_types "https://github.com/dbl-works/rubocop-dbl/blob/main/config/cops/types.yml"

    %% Styles
    classDef lib fill:#E3F2FD,stroke:#90CAF9
    classDef external fill:#FFF3E0,stroke:#FFB74D
    classDef host fill:#E8F5E9,stroke:#A5D6A7
```
