π― Comprehensive Rails Application Architecture Visualization Tool
Rails Flow Map is a powerful gem that analyzes your Rails application structure and generates beautiful, interactive visualizations to help understand architecture, dependencies, and data flow patterns.
- π Mermaid Diagrams - GitHub-friendly markdown diagrams
- ποΈ PlantUML - Detailed UML class diagrams
- π GraphViz - Network-style relationship graphs
- β‘ Interactive D3.js - Zoomable, draggable web visualizations
- π Metrics Reports - Code quality and complexity analysis
- π Sequence Diagrams - API endpoint flow visualization
- π OpenAPI Specs - Auto-generated API documentation
- π ERD Diagrams - Database schema visualization
- π Git Diff Views - Architecture change comparisons
- Path Traversal Protection - Prevents malicious file access
- XSS Prevention - Sanitizes all HTML outputs
- Input Validation - Comprehensive parameter checking
- Security Event Logging - Tracks potential threats
- Structured Logging - Performance metrics and debugging info
- Error Handling - Robust exception management with context
- Retry Logic - Automatic recovery from transient failures
- Memory Optimization - Efficient processing for large applications
- Zero Configuration - Works out of the box
- Flexible Integration - Rake tasks, Ruby API, CI/CD support
- Comprehensive Documentation - Examples and best practices
- VS Code Integration - Built-in task definitions
Add to your Gemfile:
gem 'rails-flow-map'bundle install
rails generate rails_flow_map:install# Generate architecture overview
graph = RailsFlowMap.analyze
RailsFlowMap.export(graph, format: :mermaid, output: 'docs/architecture.md')
# Create interactive visualization
RailsFlowMap.export(graph, format: :d3js, output: 'public/architecture.html')
# Generate API documentation
RailsFlowMap.export(graph, format: :openapi, output: 'docs/api.yaml')# Generate all visualizations
rake flow_map:generate
# Specific format
rake flow_map:generate FORMAT=mermaid OUTPUT=docs/flow.md
# Analyze API endpoint
rake flow_map:endpoint ENDPOINT=/api/v1/users FORMAT=sequencegraph TD
User[User] --> Post[Post]
User --> Comment[Comment]
Post --> Comment
UsersController --> User
PostsController --> Post
API["API: /api/v1/users"] --> UsersController
Features: Zoom, drag, filter by component type, search functionality
openapi: 3.0.0
info:
title: Rails API Documentation
version: 1.0.0
paths:
/api/v1/users:
get:
summary: List all users
responses:
200:
description: Successful response- π Documentation - Auto-generate always up-to-date architecture docs
- π Code Reviews - Visualize architectural changes in PRs
- π Onboarding - Help new team members understand the codebase
- ποΈ Refactoring - Identify dependencies before making changes
- π Monitoring - Track architecture complexity over time
- π Automation - Generate docs automatically on deployment
- π Metrics - Collect code quality and dependency metrics
- π¨ Alerts - Detect breaking architectural changes
- π API Docs - Auto-generate OpenAPI specifications
- π Flow Diagrams - Visualize request/response flows
- π§ͺ Testing - Understand endpoint dependencies
- π Client SDKs - Provide clear API structure documentation
# config/initializers/rails_flow_map.rb
RailsFlowMap.configure do |config|
config.output_directory = 'doc/flow_maps'
config.exclude_paths = ['vendor/', 'tmp/']
config.default_format = :mermaid
endRailsFlowMap.configure do |config|
# Analysis options
config.include_models = true
config.include_controllers = true
config.include_routes = true
# Performance options
config.streaming_mode = true
config.memory_limit = 512.megabytes
# Security options
config.sanitize_output = true
config.allow_system_paths = false
end- π Usage Examples - Comprehensive usage guide
- β‘ Quick Reference - Common commands and patterns
- π§ API Documentation - YARD documentation
- π CI/CD Integration - GitHub Actions, GitLab CI
- π» VS Code Integration - Editor setup and tasks
- π³ Docker Integration - Containerized workflows
- π Basic Examples - Getting started code samples
- π¬ Advanced Patterns - Complex use cases
| Format | Description | Best For | Output |
|---|---|---|---|
mermaid |
GitHub-friendly diagrams | Documentation, README | .md |
plantuml |
Detailed UML diagrams | Technical documentation | .puml |
d3js |
Interactive visualizations | Exploration, presentations | .html |
openapi |
API specifications | API documentation | .yaml |
sequence |
Request flow diagrams | API analysis | .md |
erd |
Database schemas | Data modeling | .md |
metrics |
Code quality reports | Code reviews, monitoring | .md |
graphviz |
Network diagrams | Complex relationships | .dot |
name: Generate Architecture Docs
on: [push]
jobs:
docs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: ruby/setup-ruby@v1
- run: bundle exec rake flow_map:generate_all{
"label": "Generate Architecture Docs",
"type": "shell",
"command": "bundle exec rake flow_map:generate_all"
}#!/bin/bash
bundle exec rake flow_map:diff > ARCHITECTURE_CHANGES.md
git add ARCHITECTURE_CHANGES.mdWe welcome contributions! Please see our Contributing Guide for details.
git clone https://github.com/railsflowmap/rails-flow-map.git
cd rails-flow-map
bundle install
rake spec# Run all tests
bundle exec rspec
# Run specific test
bundle exec rspec spec/rails_flow_map/formatters/mermaid_formatter_spec.rb
# Run with coverage
COVERAGE=true bundle exec rspecRails Flow Map is released under the MIT License.
- Thanks to all contributors
- Inspired by the Rails community's need for better architecture visualization
- Built with β€οΈ for the Rails ecosystem
- π Documentation
- π Bug Reports
- π¬ Discussions
- π¦ Twitter
β Star us on GitHub if Rails Flow Map helps your team! β