RepoPilotOpen in app →

voormedia/rails-erd

Generate Entity-Relationship Diagrams for Rails applications

Healthy

Healthy across all four use cases

Use as dependencyHealthy

Permissive license, no critical CVEs, actively maintained — safe to depend on.

Fork & modifyHealthy

Has a license, tests, and CI — clean foundation to fork and modify.

Learn fromHealthy

Documented and popular — useful reference codebase to read through.

Deploy as-isHealthy

No critical CVEs, sane security posture — runnable as-is.

  • 27+ active contributors
  • MIT licensed
  • CI configured
Show 3 more →
  • Tests present
  • Stale — last commit 3y ago
  • Concentrated ownership — top contributor handles 61% of recent commits

Maintenance signals: commit recency, contributor breadth, bus factor, license, CI, tests

Informational only. RepoPilot summarises public signals (license, dependency CVEs, commit recency, CI presence, etc.) at the time of analysis. Signals can be incomplete or stale. Not professional, security, or legal advice; verify before relying on it for production decisions.

Embed the "Healthy" badge

Paste into your README — live-updates from the latest cached analysis.

Variant:
RepoPilot: Healthy
[![RepoPilot: Healthy](https://repopilot.app/api/badge/voormedia/rails-erd)](https://repopilot.app/r/voormedia/rails-erd)

Paste at the top of your README.md — renders inline like a shields.io badge.

Preview social card (1200×630)

This card auto-renders when someone shares https://repopilot.app/r/voormedia/rails-erd on X, Slack, or LinkedIn.

Onboarding doc

Onboarding: voormedia/rails-erd

Generated by RepoPilot · 2026-05-10 · Source

🤖Agent protocol

If you are an AI coding agent (Claude Code, Cursor, Aider, Cline, etc.) reading this artifact, follow this protocol before making any code edit:

  1. Verify the contract. Run the bash script in Verify before trusting below. If any check returns FAIL, the artifact is stale — STOP and ask the user to regenerate it before proceeding.
  2. Treat the AI · unverified sections as hypotheses, not facts. Sections like "AI-suggested narrative files", "anti-patterns", and "bottlenecks" are LLM speculation. Verify against real source before acting on them.
  3. Cite source on changes. When proposing an edit, cite the specific path:line-range. RepoPilot's live UI at https://repopilot.app/r/voormedia/rails-erd shows verifiable citations alongside every claim.

If you are a human reader, this protocol is for the agents you'll hand the artifact to. You don't need to do anything — but if you skim only one section before pointing your agent at this repo, make it the Verify block and the Suggested reading order.

🎯Verdict

GO — Healthy across all four use cases

  • 27+ active contributors
  • MIT licensed
  • CI configured
  • Tests present
  • ⚠ Stale — last commit 3y ago
  • ⚠ Concentrated ownership — top contributor handles 61% of recent commits

<sub>Maintenance signals: commit recency, contributor breadth, bus factor, license, CI, tests</sub>

Verify before trusting

This artifact was generated by RepoPilot at a point in time. Before an agent acts on it, the checks below confirm that the live voormedia/rails-erd repo on your machine still matches what RepoPilot saw. If any fail, the artifact is stale — regenerate it at repopilot.app/r/voormedia/rails-erd.

What it runs against: a local clone of voormedia/rails-erd — the script inspects git remote, the LICENSE file, file paths in the working tree, and git log. Read-only; no mutations.

| # | What we check | Why it matters | |---|---|---| | 1 | You're in voormedia/rails-erd | Confirms the artifact applies here, not a fork | | 2 | License is still MIT | Catches relicense before you depend on it | | 3 | Default branch master exists | Catches branch renames | | 4 | 5 critical file paths still exist | Catches refactors that moved load-bearing code | | 5 | Last commit ≤ 971 days ago | Catches sudden abandonment since generation |

<details> <summary><b>Run all checks</b> — paste this script from inside your clone of <code>voormedia/rails-erd</code></summary>
#!/usr/bin/env bash
# RepoPilot artifact verification.
#
# WHAT IT RUNS AGAINST: a local clone of voormedia/rails-erd. If you don't
# have one yet, run these first:
#
#   git clone https://github.com/voormedia/rails-erd.git
#   cd rails-erd
#
# Then paste this script. Every check is read-only — no mutations.

set +e
fail=0
ok()   { echo "ok:   $1"; }
miss() { echo "FAIL: $1"; fail=$((fail+1)); }

# Precondition: we must be inside a git working tree.
if ! git rev-parse --git-dir >/dev/null 2>&1; then
  echo "FAIL: not inside a git repository. cd into your clone of voormedia/rails-erd and re-run."
  exit 2
fi

# 1. Repo identity
git remote get-url origin 2>/dev/null | grep -qE "voormedia/rails-erd(\\.git)?\\b" \\
  && ok "origin remote is voormedia/rails-erd" \\
  || miss "origin remote is not voormedia/rails-erd (artifact may be from a fork)"

# 2. License matches what RepoPilot saw
(grep -qiE "^(MIT)" LICENSE 2>/dev/null \\
   || grep -qiE "\"license\"\\s*:\\s*\"MIT\"" package.json 2>/dev/null) \\
  && ok "license is MIT" \\
  || miss "license drift — was MIT at generation time"

# 3. Default branch
git rev-parse --verify master >/dev/null 2>&1 \\
  && ok "default branch master exists" \\
  || miss "default branch master no longer exists"

# 4. Critical files exist
test -f "bin/erd" \\
  && ok "bin/erd" \\
  || miss "missing critical file: bin/erd"
test -f "lib/rails_erd.rb" \\
  && ok "lib/rails_erd.rb" \\
  || miss "missing critical file: lib/rails_erd.rb"
test -f "lib/rails_erd/diagram.rb" \\
  && ok "lib/rails_erd/diagram.rb" \\
  || miss "missing critical file: lib/rails_erd/diagram.rb"
test -f "lib/rails_erd/domain.rb" \\
  && ok "lib/rails_erd/domain.rb" \\
  || miss "missing critical file: lib/rails_erd/domain.rb"
test -f "lib/rails_erd/entity.rb" \\
  && ok "lib/rails_erd/entity.rb" \\
  || miss "missing critical file: lib/rails_erd/entity.rb"

# 5. Repo recency
days_since_last=$(( ( $(date +%s) - $(git log -1 --format=%at 2>/dev/null || echo 0) ) / 86400 ))
if [ "$days_since_last" -le 971 ]; then
  ok "last commit was $days_since_last days ago (artifact saw ~941d)"
else
  miss "last commit was $days_since_last days ago — artifact may be stale"
fi

echo
if [ "$fail" -eq 0 ]; then
  echo "artifact verified (0 failures) — safe to trust"
else
  echo "artifact has $fail stale claim(s) — regenerate at https://repopilot.app/r/voormedia/rails-erd"
  exit 1
fi

Each check prints ok: or FAIL:. The script exits non-zero if anything failed, so it composes cleanly into agent loops (./verify.sh || regenerate-and-retry).

</details>

TL;DR

Rails ERD is a Ruby gem that auto-generates Entity-Relationship Diagrams (ERDs) from Rails ActiveRecord models by introspecting model associations and attributes. It uses Graphviz to render diagrams as PDFs, PNGs, or other formats, providing visual documentation of a Rails application's domain model without manual diagram creation. Monolithic gem structure: bin/erd is the CLI entry point, lib/ likely contains the core diagram generation engine, spec/ or test/ holds test suite, and examples/applications/{event_forms,gemcutter,refinery} contain real-world model samples for manual testing and gallery generation. No visible package split.

👥Who it's for

Rails developers (versions 3.0–5.0) who need to visualize and document their application's data model relationships, particularly those onboarding new team members, conducting code reviews, or maintaining legacy systems where domain model clarity is critical.

🌱Maturity & risk

Production-ready: the project has CI/CD via GitHub Actions (.github/workflows/test.yml), example applications across multiple domains (gemcutter, refinery, event_forms), and supports Rails 3.0–5.0 with Ruby 1.9.3+. However, the last major update appears to be several years old based on Rails version support ceiling, suggesting stable but not actively developed state.

Low risk for mature Rails codebases, but dependency on Graphviz (external system library) creates an installation friction point. No visible npm/Gemfile dependency bloat in the file list, and the single-purpose nature reduces maintenance surface. Risk increases if targeting Rails 6.0+ (not listed in requirements)—this tool may need modernization for current Rails versions.

Active areas of work

Unknown from visible metadata—CI workflow exists (.github/workflows/test.yml) but commit history not provided. The CHANGES.md and presence of .travis.yml alongside modern GitHub Actions suggest transition period. File structure shows mature, stable state with no visible active PRs or recent work indicators in the provided data.

🚀Get running

git clone https://github.com/voormedia/rails-erd.git && cd rails-erd && bundle install && bundle exec erd

Daily commands: bundle exec erd (generates diagram in current Rails project). Optional: bundle exec erd --help for CLI options. For development: bundle exec rake test (inferred from Rakefile presence).

🗺️Map of the codebase

  • bin/erd — Entry point CLI executable that users invoke to generate diagrams; all contributors must understand the command interface
  • lib/rails_erd.rb — Core gem initialization and module that orchestrates diagram generation from Rails models
  • lib/rails_erd/diagram.rb — Primary diagram builder that introspects ActiveRecord models and constructs the relationship graph
  • lib/rails_erd/domain.rb — Domain model abstraction that represents entities and relationships discovered from Rails models
  • lib/rails_erd/entity.rb — Entity class that wraps Rails models and extracts association metadata for diagram nodes
  • README.md — Outlines gem purpose, usage patterns, and configuration options that all developers must know
  • CHANGES.md — Tracks API and behavioral changes across versions to guide backward-compatibility decisions

🧩Components & responsibilities

  • Diagram Builder (Ruby, Rails, ActiveRecord reflection) — Orchestrates Rails model loading, entity/relationship discovery, and domain graph construction
    • Failure mode: Fails if Rails app cannot be loaded or required models are not found; outputs partial diagram if some models error
  • Model Introspector (Entity/Relationship) (ActiveRecord::Reflection) — Extracts associations, attributes, and cardinality metadata from Rails models via reflection
    • Failure mode: Silently skips unknown association types; loses accuracy for dynamic associations not defined statically
  • Domain Model (Pure Ruby data structures) — In-memory graph representation of entities (nodes) and relationships (edges); applies config filters
    • Failure mode: Filters may exclude too much or too little if config is misconfigured; no validation of filter syntax
  • Generator (Graphviz) (Graphviz/dot CLI) — Converts domain graph to DOT format and invokes Graphviz to render final diagram image
    • Failure mode: Fails if Graphviz not installed; outputs broken or malformed DOT if domain contains invalid characters
  • Configuration & Options (YAML, Ruby DSL) — Parses YAML config, CLI flags, and DSL; applies user preferences to filter and style diagram
    • Failure mode: Syntax errors in config file cause startup failure; invalid option values silently ignored

🔀Data flow

  • User / CLIRake Task — User invokes rails erd command with optional format/output flags
  • Rake TaskDiagram Builder — Passes options and triggers diagram generation
  • undefinedundefined — undefined

🛠️How to make changes

Add a new output format (e.g., Mermaid, SVG)

  1. Create a new generator class inheriting from base formatter in lib/rails_erd/generators/ (lib/rails_erd/generators/your_format.rb)
  2. Implement generate method that converts domain entities and relationships to desired format (lib/rails_erd/generators/your_format.rb)
  3. Register the generator with the diagram builder (lib/rails_erd/diagram.rb)
  4. Add option parsing to allow users to select format via --format flag (lib/rails_erd/options.rb)

Customize which models and attributes appear in diagram

  1. Create erd.yml or .erdconfig in Rails app root or use DSL (config/erd.yml)
  2. Use exclude/only directives to filter entities (lib/rails_erd/config.rb)
  3. Specify attributes to show/hide via attributes block (lib/rails_erd/config.rb)
  4. Filter relationships by type (has_many, belongs_to, etc.) (lib/rails_erd/config.rb)

Add custom relationship cardinality or styling rules

  1. Inspect relationship detection in entity association extraction (lib/rails_erd/entity.rb)
  2. Extend or override association analysis to customize cardinality labels (lib/rails_erd/relationship.rb)
  3. Modify formatter to apply custom styling based on relationship metadata (lib/rails_erd/formatter.rb)

🔧Why these technologies

  • Ruby + Rails — Rails ERD is built for Rails applications and uses ActiveRecord reflection—native to Rails—to discover models and associations
  • Graphviz (DOT format) — Industry-standard graph visualization format; allows users to customize and post-process diagrams with dot utilities
  • Rake tasks + Railtie — Integrates seamlessly into Rails workflow via rails erd command; minimal user setup required

⚖️Trade-offs already made

  • Introspection via ActiveRecord reflection rather than AST parsing

    • Why: Simpler, more reliable, and directly reflects actual runtime model structure
    • Consequence: Cannot detect dynamic associations or models not loaded in memory; requires Rails environment
  • Graphviz for rendering instead of built-in canvas

    • Why: Leverages battle-tested graph layout algorithms; allows users to customize output post-generation
    • Consequence: Requires Graphviz installation; adds external dependency; output is static (not interactive)
  • Configuration via YAML + DSL instead of code annotations

    • Why: Keeps diagram concerns separate from model code; non-invasive to existing applications
    • Consequence: Configuration lives outside models; separate file to maintain; learning curve for DSL

🚫Non-goals (don't propose these)

  • Real-time or interactive diagram generation (static output only)
  • Support for non-Rails ORM frameworks (ActiveRecord-specific)
  • Automatic diagram updates on model file changes (manual re-run required)
  • Database schema introspection (uses Rails models, not raw DB schema)
  • Custom styling of individual edges/nodes via UI (post-generation editing required)

🪤Traps & gotchas

Graphviz must be installed system-wide (brew install graphviz on macOS, apt-get on Linux)—the gem cannot work without it. Rails version ceiling at 5.0 means this tool will need updates for Rails 6+, and ActiveRecord reflection API may have breaking changes. The .travis.yml and .github/workflows/test.yml coexistence suggests CI migration in progress—watch for configuration drift. YAML config lookup order (.erdconfig precedence over ~/.erdconfig) can be unintuitive for users with conflicting global + local configs.

🏗️Architecture

💡Concepts to learn

  • ActiveRecord Reflection API — Rails ERD's entire foundation: it introspects has_many, belongs_to, has_one associations at runtime without parsing Ruby code, making it resilient to syntax variations and metaprogramming
  • Entity-Relationship Model (ER Model) — The diagram grammar rails-erd outputs (entities as boxes, relationships as lines) follows Chen's 1976 ER model; understanding cardinality notation (1:N, M:M) is essential to reading generated diagrams
  • Graphviz DOT Language — Rails ERD generates DOT graph description language and delegates rendering to Graphviz; understanding DOT syntax helps debug diagram layout and customize rendering
  • Model Polymorphism (Single Table Inheritance / STI) — Rails ERD has explicit polymorphism:true config option because STI and polymorphic associations require special diagram handling to avoid visual ambiguity
  • Graph Clustering & Spline Routing — The .erdconfig cluster and splines options control Graphviz layout algorithms; understanding these improves readability of large domain models
  • YAML Configuration Convention — Rails ERD uses ~/.erdconfig and ./.erdconfig lookup (project override pattern); a common Rails tooling pattern worth understanding for building config-driven gems
  • Bidirectional Association Rendering — Rails ERD must avoid drawing duplicate relationship lines for a:b and b:a associations; understanding how the tool deduplicates edges is key to modifying edge-rendering logic
  • rails-erd/rails-erd — This is the official repo itself; link to it from mirrors or docs
  • rmosolgo/graphql-ruby — Similar problem in GraphQL ecosystem: auto-generates schema diagrams from code introspection; uses same Graphviz rendering pattern
  • ghazel/graphviz — Pure Ruby Graphviz DSL and renderer; used by or similar to rails-erd's diagram generation layer
  • amatsuda/kaminari — Another Rails utility gem with similar maturity, scope, and CI/example structure; good reference for Rails gem best practices
  • github/linguist — Demonstrates introspection-driven code analysis (detecting Rails models by file pattern); conceptually adjacent to rails-erd's reflection approach

🪄PR ideas

To work on one of these in Claude Code or Cursor, paste: Implement the "<title>" PR idea from CLAUDE.md, working through the checklist as the task list.

Add comprehensive integration tests for example applications

The repo contains 4 detailed example applications (event_forms, gemcutter, refinery, spree) with schemas and models, but there's no evidence of integration tests that verify rails-erd correctly generates diagrams for these real-world examples. This would validate the gem works with complex relationship patterns and catch regressions early.

  • [ ] Create spec/integration/examples_spec.rb to test each example application
  • [ ] For each examples/applications/*/schema.rb, load it and verify the generated ERD includes all models
  • [ ] Validate relationship detection (has_many, belongs_to, has_and_belongs_to_many) matches the schema for each example
  • [ ] Test edge cases like the spree example's STI (Single Table Inheritance) with Calculator and its subclasses
  • [ ] Add assertions for diagram output format (Graphviz DOT syntax) validity

Add Ruby 3.x and Rails 7.x compatibility tests to GitHub Actions workflow

The .github/workflows/test.yml exists but likely doesn't test against the latest Ruby (3.2+) and Rails (7.x) versions. Given Rails-ERD is a critical documentation tool, contributors should verify compatibility with modern Rails versions to prevent silent breakages.

  • [ ] Review current .github/workflows/test.yml to identify tested Ruby/Rails versions
  • [ ] Extend the test matrix to include Ruby 3.1, 3.2, and Rails 7.0, 7.1
  • [ ] Add a build status badge for 'Latest Rails/Ruby' to README.md
  • [ ] Update Gemfile with gemspec constraints that reflect supported versions
  • [ ] Document minimum supported versions in README.md if not already present

Create API documentation for custom diagram generation (referenced in README)

The README states 'If you don't like the default output, it is very easy to use the API to build your own diagrams,' but no docs/API.md or examples exist in the repo. New contributors need concrete examples of using rails-erd programmatically to extend functionality.

  • [ ] Create docs/API.md documenting the main entry points (likely in lib/ - inspect for public classes)
  • [ ] Add 3-5 code examples showing: basic diagram generation, filtering models, custom formatting, and GraphViz option customization
  • [ ] Reference the 4 example applications as templates for what the API can introspect
  • [ ] Add YARD/RDoc comments to public API methods in lib/ if missing
  • [ ] Update README.md with a link to docs/API.md in the 'Customization' or 'Advanced Usage' section

🌿Good first issues

  • Add test coverage for the refinery example application (examples/applications/refinery/)—schema.rb exists but no visible test fixtures validate that all refinery models generate correct diagrams
  • Document the .erdconfig YAML schema with inline comments in the code (currently only documented in README)—map each YAML key to the code that consumes it in lib/
  • Add a --version flag to bin/erd that reads version from gemspec and displays it—useful for debugging and CI logs

Top contributors

Click to expand
  • @kerrizor — 61 commits
  • [@Ahmed Ammar](https://github.com/Ahmed Ammar) — 4 commits
  • [@Kyle Rames](https://github.com/Kyle Rames) — 3 commits
  • [@Bohdan Pohorilets](https://github.com/Bohdan Pohorilets) — 3 commits
  • [@Sean Carroll](https://github.com/Sean Carroll) — 2 commits

📝Recent commits

Click to expand
  • 7c66258 — Merge pull request #405 from ahmedash95/support-mermaid (kerrizor)
  • 2f3950b — split relation_arrow into more methods (Ahmed Ammar)
  • e9bfc85 — cast generator to symbol (Ahmed Ammar)
  • 6da32a2 — check only for graphviz dependency when needed (Ahmed Ammar)
  • 22cfc76 — add Mermaid support (Ahmed Ammar)
  • 52cb2ce — Merge pull request #398 from voormedia/kerrizor/release-1.7.2 (kerrizor)
  • b93f6cf — Bump to 1.7.2 (kerrizor)
  • 2ed7797 — Merge pull request #397 from voormedia/pr-361 (kerrizor)
  • b764782 — Map foreign keys & current column name to symbols (kurt-mueller-osumc)
  • d4b66d0 — Merge pull request #395 from voormedia/pr-388 (kerrizor)

🔒Security observations

The rails-erd project appears to be a well-maintained utility gem with reasonable security posture. Primary concerns are: (1) lack of dependency analysis due to missing Gemfile.lock content - critical for gem security validation; (2) presence of multiple example Rails applications that could serve as templates but may not follow security best practices; (3) missing explicit security policy documentation. The codebase itself shows no evidence of hardcoded credentials, SQL injection risks, or obvious misconfigurations based on the file structure. As a code generation/analysis tool, input validation for model processing should be verified in source code analysis. No Docker configuration or exposed services detected.

  • Medium · Missing Dependency Information — Gemfile / Gemfile.lock. No Gemfile.lock or dependency file content was provided for analysis. This prevents verification of known vulnerable gem versions and dependency chains. The project appears to be a Ruby gem itself, so dependency management is critical. Fix: Provide Gemfile.lock content for analysis. Regularly run 'bundle audit' to check for vulnerable dependencies. Implement automated dependency scanning in CI/CD pipeline.
  • Low · Example Applications May Contain Vulnerable Code — examples/applications/. The repository contains multiple example applications (event_forms, gemcutter, refinery, spree) with model files and schema definitions. These are likely for demonstration purposes, but could potentially be used as templates without proper security review. Fix: Clearly mark example code as non-production-ready. Include security warnings in example README files. Ensure example models don't demonstrate insecure patterns (e.g., unsafe parameter handling).
  • Low · Incomplete Security Documentation — Repository root. No visible SECURITY.md or security policy file in the repository. This makes it difficult for security researchers to report vulnerabilities responsibly. Fix: Create a SECURITY.md file following GitHub's security policy template. Include instructions for responsible disclosure and contact information for security reports.

LLM-derived; treat as a starting point, not a security audit.


Generated by RepoPilot. Verdict based on maintenance signals — see the live page for receipts. Re-run on a new commit to refresh.

Healthy signals · voormedia/rails-erd — RepoPilot