vdb Docs Example App

Example App

The example/ directory in the vdb repository is a self-contained Rails 8 blog application that ships with vdb pre-wired. It demonstrates every feature of the gem on a realistic seven-table schema.

Run it yourself cd example && bundle install && bin/rails db:migrate db:seed && bin/rails server — then open http://localhost:3000/dev/erd.

Schema

The blog models a content platform with authors, expert reviewers, posts, threaded comments, and taxonomy tags.

users ──< posts ──< reviews >── reviewers ──> users │ │ └──< comments (self-referential: parent_id) │ post_tags >── tags
users
namestring
emailstring
biotext
rolestring
avatar_urlstring
verified_atdatetime
posts
user_idinteger
titlestring
bodytext
statusstring
featuredboolean
published_atdatetime
reviewers
user_idinteger
specializationstring
biotext
ratingdecimal
verified_atdatetime
reviews
post_idinteger
reviewer_idinteger
ratinginteger
contenttext
approvedboolean
approved_atdatetime
comments
post_idinteger
user_idinteger
parent_idinteger
bodytext
tags
namestring
slugstring
colorstring
post_tags
post_idinteger
tag_idinteger

Notable relationship patterns this schema exercises:

  • 1:Nusers → posts, posts → reviews, posts → comments
  • 1:1users ↔ reviewers (unique index on reviewers.user_id)
  • N:M via join tableposts ↔ tags through post_tags
  • Self-referentialcomments.parent_id for threaded replies
  • Inferred FKcomments.parent_id not in add_foreign_key; vdb infers it automatically

vdb integration

Gemfile

group :development do
  gem 'vdb', path: '..'   # path reference to parent gem directory
end

config/routes.rb

Rails.application.routes.draw do
  mount Vdb::Engine, at: '/dev/erd'

  root 'posts#index'
  resources :posts,     only: %i[index show]
  resources :users,     only: %i[index show]
  resources :reviewers, only: %i[index show]
end

config/initializers/vdb.rb

return unless Rails.env.development?

Vdb.configure do |c|
  c.databases = { 'primary' => nil }   # auto-resolves to db/schema.rb
  c.title     = 'Blog ERD — vdb example'
end

Sample data

db/seeds.rb loads a realistic dataset so you can explore the app immediately after setup:

Record typeCountNotable details
Users4Alice, Bob, Carol (editor), Dave — different roles
Reviewers3Bob (Performance), Carol (Database), Dave (Security) — verified
Posts43 published, 1 draft — covering Rails, RSpec, PostgreSQL, JWT
Tags6Ruby, Rails, Performance, Database, Testing, Security
Post-tag joins123 tags per post
Reviews4Ratings 4–5, mixed approved status
Comments4Includes one threaded reply (parent_id set)

ERD screenshots

Full ERD — all tables

All 7 tables of the blog schema visible in the vdb ERD
All seven tables rendered by D3's force simulation. FK columns are highlighted in cyan. Crow's-foot and single-tick markers indicate cardinality.
Search field filtered to 'post' — matching tables are bright, others dimmed
Typing post in the search box immediately dims non-matching tables. posts and post_tags stay fully visible; everything else fades back.

Relationship highlighting

The posts table is clicked — its direct neighbours are highlighted
Clicking a table header highlights it and all its direct relationships. Unrelated tables dim so you can trace connections without distraction.

Application pages

Blog posts list page
Posts index — author, tags, review count
Single post detail with reviews and comments
Post detail — reviews with ratings, threaded comments
Users list page
Users — reviewer badge for credentialed users
Reviewers list page
Reviewers — specialization, rating, verified status

Run the example

cd example
bundle install
bin/rails db:migrate
bin/rails db:seed
bin/rails server

Then visit:

URLPage
http://localhost:3000Posts index
http://localhost:3000/usersUsers list
http://localhost:3000/reviewersReviewers list
http://localhost:3000/dev/erdDatabase ERD
vdb v0.1.0 — MIT License — GitHub