Open Source Rails Engine

👁️ DBViewer

The fastest way to visualize and explore your database

DBViewer is built for developer happiness, making it effortless to explore and understand your data structure. Simple, intuitive, and enjoyable to use. Because database tools should bring joy, not frustration.

10+
Key Features
100%
Read-Only
Multiple
Databases

✨ Key Features

Interactive Dashboard

Comprehensive overview with database statistics, analytics, and quick access to all tables and relationships.

SQL Query Editor

Write and execute SQL queries with syntax highlighting, auto-completion, and paginated results display.

Schema Browser

Navigate your database schema visually. Explore tables, columns, relationships, and indexes without writing SQL.

Entity Relationship Diagrams

Interactive ERD visualization showing table relationships, foreign keys, and database structure at a glance.

Secure & Production Ready

Read-only operations, HTTP Basic Authentication, SQL injection protection, and query logging with audit trails.

PII Data Masking

Protect sensitive data with configurable masking rules. Automatically mask emails, phone numbers, SSNs, and custom fields while preserving data structure for development.

Multiple Database Support

Connect to multiple databases simultaneously, switch between connections, and manage different database environments.

🚀 Quick Installation

Get DBViewer up and running in your Rails application in just a few steps.

1

Add to Gemfile

Add DBViewer to your application's Gemfile:

ruby
gem "dbviewer"
2

Install Dependencies

Run bundle to install the gem:

bash
bundle install
3

Mount the Engine

Add the engine to your routes file:

ruby
Rails.application.routes.draw do
  # Your application routes...

  # Mount the DBViewer engine
  mount Dbviewer::Engine, at: "/dbviewer"
end
4

Configure (Optional)

Generate configuration file for customization:

bash
rails generate dbviewer:install

🔧 Advanced Configuration

Customize DBViewer with the generated configuration file:

ruby
# config/initializers/dbviewer.rb
Dbviewer.configure do |config|
  # Datatable Pagination Settings
  config.per_page_options = [ 10, 20, 50, 100, 250 ] # Default pagination options
  config.default_per_page = 50                       # Default records per page

  # SQL Query Settings
  config.max_query_length = 10000                    # Maximum SQL query length
  config.cache_expiry = 300                          # Cache expiration in seconds
  config.max_records = 10000                         # Maximum records to display
  config.query_timeout = 30                          # SQL query timeout in seconds

  # Export Options
  config.enable_data_export = false                  # Whether to allow data exporting

  # Query Logging options (Disabled by default on Non Development Environments)
  config.enable_query_logging = true                 
  config.query_logging_mode = :file                  
  config.query_log_path = "log/dbviewer.log"         
  config.max_memory_queries = 1000                   
  
  # Basic Authentication (Recommended for production)
  config.admin_credentials = {
    username: "admin",
    password: "your_secure_password"
  }
  
  # Multiple Database Support
  config.database_connections = {
    primary: {
      connection_class: "ActiveRecord::Base",
      name: "Primary Database"
    },
    secondary: {
      connection_class: "SecondaryBaseModel",
      name: "Secondary Database (Blog)"
    }
  }
  config.current_connection = :primary
end

🔐 PII Data Masking Configuration

Protect sensitive data with configurable masking rules:

ruby
# config/initializers/dbviewer.rb
Dbviewer.configure do |config|
  config.enable_pii_masking = true                   # Enable PII masking (default: true)
end

# Define PII masking rules
Dbviewer.configure_pii do |pii|
  # Built-in masking types
  pii.mask 'users.email', with: :email              # john@example.com → jo***@example.com
  pii.mask 'users.phone', with: :phone              # +1234567890 → +1***90
  pii.mask 'users.ssn', with: :ssn                  # 123456789 → ***-**-6789
  pii.mask 'payments.card_number', with: :credit_card # 1234567890123456 → ****-****-****-3456
  pii.mask 'users.api_key', with: :full_redact      # any_value → ***REDACTED***

  # Custom masking with lambda
  pii.mask 'users.salary', with: ->(value) { value ? '$***,***' : value }

  # Define reusable custom masks
  pii.custom_mask :ip_mask, ->(value) {
    return value if value.nil?
    parts = value.split('.')
    "#{parts[0]}.#{parts[1]}.***.***.***"
  }
  pii.mask 'logs.ip_address', with: :ip_mask
end

✨ Try the Live Demo

Experience DBViewer's full capabilities with our interactive demo featuring real sample data.

Access Live Demo

📖 Open Source & Documentation

DBViewer is completely open source. Explore the code, contribute to the project, or deploy it in your own applications with full documentation and examples.

MIT Licensed
🚀 Production Ready
🔒 Security Focused