# seattlerb/debride architecture

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

- Interactive diagram: https://gitdiagram.com/seattlerb/debride
- Repository: https://github.com/seattlerb/debride

## Overview

Debride is a Ruby static-analysis CLI that reports methods it believes may be uncalled, with Rails-aware handling and whitelist support. Its main workflow expands input paths, parses Ruby, records defined and referenced methods, filters candidates, and reports them. Separate commands derive whitelists from Rails routes and logs, or remove reported methods. The source excerpt is partial, so internal call links are limited to documented behavior and visible code.

Main entry points: [`lib/debride.rb`](https://github.com/seattlerb/debride/blob/master/lib/debride.rb) (Candidate filtering), [`bin/debride_rails_whitelist`](https://github.com/seattlerb/debride/blob/master/bin/debride_rails_whitelist) (Rails whitelist CLI), [`bin/debride`](https://github.com/seattlerb/debride/blob/master/bin/debride) (Debride CLI), [`bin/debride_rm`](https://github.com/seattlerb/debride/blob/master/bin/debride_rm) (Auto-removal CLI)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_analysis["Analysis"]
  node_options["Option parsing<br/>[debride.rb]"]
  node_path_expander["Path expansion<br/>[debride.rb]"]
  node_ruby_parser["Ruby parser<br/>[debride.rb]"]
  node_method_scan["Method scan<br/>[debride.rb]"]
  node_rails_rules["Rails rules<br/>[debride.rb]"]
  node_method_sets[("Method sets<br/>[debride.rb]")]
  node_candidate_filter["Candidate filtering<br/>[debride.rb]"]
  node_whitelist_file["Whitelist file<br/>[debride.rb]"]
  node_report["Text / JSON / YAML report<br/>[debride.rb]"]
end

subgraph group_cli["CLI workflows"]
  node_debride_cli["Debride CLI"]
end

subgraph group_support["Whitelist and removal"]
  node_debride_rm["Auto-removal CLI"]
  node_rails_whitelist["Rails whitelist CLI"]
  node_plugin_support["Parser plugins<br/>[debride.rb]"]
end

node_user(("Engineer"))
node_ruby_files["Ruby files"]
node_routes["Rails routes"]
node_logs["Production logs"]
node_removed_code["Edited source"]

node_user -->|"runs"| node_debride_cli
node_debride_cli -->|"parses options"| node_options
node_debride_cli -->|"expands inputs"| node_path_expander
node_ruby_files -->|"supplies paths"| node_path_expander
node_path_expander -->|"selects files"| node_ruby_parser
node_ruby_parser -->|"parses source"| node_method_scan
node_method_scan -->|"applies Rails rules"| node_rails_rules
node_method_scan -->|"records methods"| node_method_sets
node_rails_rules -->|"records references"| node_method_sets
node_options -->|"provides options"| node_candidate_filter
node_method_sets -->|"supplies method data"| node_candidate_filter
node_whitelist_file -->|"exempts methods"| node_candidate_filter
node_candidate_filter -->|"formats candidates"| node_report
node_user -->|"runs"| node_debride_rm
node_debride_rm -->|"removes methods"| node_ruby_files
node_user -->|"runs"| node_rails_whitelist
node_routes -->|"provides routes"| node_rails_whitelist
node_logs -->|"provides usages"| node_rails_whitelist
node_rails_whitelist -->|"generates whitelist"| node_whitelist_file
node_plugin_support -.->|"extends parsing"| node_ruby_parser

click node_debride_cli "https://github.com/seattlerb/debride/blob/master/bin/debride"
click node_options "https://github.com/seattlerb/debride/blob/master/lib/debride.rb"
click node_path_expander "https://github.com/seattlerb/debride/blob/master/lib/debride.rb"
click node_ruby_parser "https://github.com/seattlerb/debride/blob/master/lib/debride.rb"
click node_method_scan "https://github.com/seattlerb/debride/blob/master/lib/debride.rb"
click node_rails_rules "https://github.com/seattlerb/debride/blob/master/lib/debride.rb"
click node_method_sets "https://github.com/seattlerb/debride/blob/master/lib/debride.rb"
click node_candidate_filter "https://github.com/seattlerb/debride/blob/master/lib/debride.rb"
click node_whitelist_file "https://github.com/seattlerb/debride/blob/master/lib/debride.rb"
click node_report "https://github.com/seattlerb/debride/blob/master/lib/debride.rb"
click node_debride_rm "https://github.com/seattlerb/debride/blob/master/bin/debride_rm"
click node_rails_whitelist "https://github.com/seattlerb/debride/blob/master/bin/debride_rails_whitelist"
click node_plugin_support "https://github.com/seattlerb/debride/blob/master/lib/debride.rb"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_options,node_path_expander,node_ruby_parser,node_method_scan,node_rails_rules,node_method_sets,node_candidate_filter,node_whitelist_file,node_report toneBlue
class node_debride_cli toneAmber
class node_debride_rm,node_rails_whitelist,node_plugin_support,node_routes toneMint
class node_user,node_ruby_files,node_logs,node_removed_code toneIndigo
```

## Components

### Analysis

- [Option parsing](https://github.com/seattlerb/debride/blob/master/lib/debride.rb): `lib/debride.rb`
- [Path expansion](https://github.com/seattlerb/debride/blob/master/lib/debride.rb): `lib/debride.rb`
- [Ruby parser](https://github.com/seattlerb/debride/blob/master/lib/debride.rb): `lib/debride.rb`
- [Method scan](https://github.com/seattlerb/debride/blob/master/lib/debride.rb): `lib/debride.rb`
- [Rails rules](https://github.com/seattlerb/debride/blob/master/lib/debride.rb): `lib/debride.rb`
- [Method sets](https://github.com/seattlerb/debride/blob/master/lib/debride.rb): `lib/debride.rb`
- [Candidate filtering](https://github.com/seattlerb/debride/blob/master/lib/debride.rb): `lib/debride.rb`
- [Whitelist file](https://github.com/seattlerb/debride/blob/master/lib/debride.rb): `lib/debride.rb`
- [Text / JSON / YAML report](https://github.com/seattlerb/debride/blob/master/lib/debride.rb): `lib/debride.rb`

### CLI workflows

- [Debride CLI](https://github.com/seattlerb/debride/blob/master/bin/debride): `bin/debride`

### Whitelist and removal

- [Auto-removal CLI](https://github.com/seattlerb/debride/blob/master/bin/debride_rm): `bin/debride_rm`
- [Rails whitelist CLI](https://github.com/seattlerb/debride/blob/master/bin/debride_rails_whitelist): `bin/debride_rails_whitelist`
- [Parser plugins](https://github.com/seattlerb/debride/blob/master/lib/debride.rb): `lib/debride.rb`

### Other components

- **Engineer**
- **Ruby files**
- **Rails routes**
- **Production logs**
- **Edited source**

## Connections

- Engineer → Debride CLI: runs
- Debride CLI → Option parsing: parses options
- Debride CLI → Path expansion: expands inputs
- Ruby files → Path expansion: supplies paths
- Path expansion → Ruby parser: selects files
- Ruby parser → Method scan: parses source
- Method scan → Rails rules: applies Rails rules
- Method scan → Method sets: records methods
- Rails rules → Method sets: records references
- Option parsing → Candidate filtering: provides options
- Method sets → Candidate filtering: supplies method data
- Whitelist file → Candidate filtering: exempts methods
- Candidate filtering → Text / JSON / YAML report: formats candidates
- Engineer → Auto-removal CLI: runs
- Auto-removal CLI → Ruby files: removes methods
- Engineer → Rails whitelist CLI: runs
- Rails routes → Rails whitelist CLI: provides routes
- Production logs → Rails whitelist CLI: provides usages
- Rails whitelist CLI → Whitelist file: generates whitelist
- Parser plugins → Ruby parser: extends parsing
