Skip to content

dipeshguptaa/RouteCompare

Repository files navigation

Rails Routes Comparator

A full-stack web application for comparing Ruby on Rails routes.rb files between any two Rails projects. Analyze routing differences, identify common routes, and export detailed comparison reports.

Rails Routes Comparator TypeScript React Node.js

Features

  • βœ… Dynamic Project Names: Compare any two Rails applications with custom project names
  • πŸ”„ Route Parsing: Comprehensive Ruby routes parser supporting resources, namespaces, custom routes
  • πŸ“Š Visual Comparison: Interactive results with filtering, search, and tabbed views
  • πŸ“ CSV Export: Export comparison results to CSV format
  • 🎯 Smart Analysis: Identifies common routes, project-specific routes, and differences
  • πŸ” Advanced Filtering: Filter by HTTP method, route type, and search functionality

Demo

Upload your routes.rb files and see instant analysis:

  • Common Routes: Routes present in both projects
  • Project-Specific Routes: Routes unique to each project
  • Side-by-Side Comparison: Code view comparing both route structures
  • Export Options: Download detailed CSV reports

Tech Stack

Frontend

  • React 18 with TypeScript
  • Tailwind CSS for styling
  • Radix UI components with shadcn/ui design system
  • TanStack Query for server state management
  • React Hook Form with Zod validation
  • Wouter for client-side routing

Backend

  • Node.js with Express.js
  • TypeScript with ES modules
  • Multer for file upload processing
  • Custom Ruby Route Parser for analyzing Rails routes files
  • In-memory storage with database-ready schema

Database (Ready for Production)

  • PostgreSQL with Neon Database
  • Drizzle ORM for type-safe database operations
  • Drizzle Kit for migrations

Quick Start

Prerequisites

  • Node.js 20+
  • npm or yarn

Installation

  1. Clone the repository:
git clone https://github.com/yourusername/rails-routes-comparator.git
cd rails-routes-comparator
  1. Install dependencies:
npm install
  1. Start the development server:
npm run dev
  1. Open your browser to http://localhost:5000

Usage

Basic Comparison

  1. Enter Project Names: Add custom names for your Rails projects (e.g., "MyApp v1.0", "MyApp v2.0")

  2. Upload Routes Files: Drop or select your routes.rb files for each project

  3. Analyze: Click "Analyze & Compare Routes" to process the files

  4. Review Results: Explore the comparison in multiple views:

    • Common: Routes present in both projects
    • Project A Only: Routes unique to the first project
    • Project B Only: Routes unique to the second project
    • Side-by-Side: Code comparison view
  5. Export: Download CSV reports for further analysis

Advanced Features

  • Search: Find specific routes using the search bar
  • Filter by Method: Show only GET, POST, PATCH, or DELETE routes
  • Filter by Type: Focus on resources, custom routes, or namespaces
  • CSV Export: Generate detailed spreadsheet reports

Route Parser Capabilities

The application supports comprehensive Rails routing patterns:

Resource Routes

resources :users do
  member do
    patch 'activate'
  end
  collection do
    get 'search'  
  end
end

Custom Routes

get 'login', to: 'sessions#new'
post 'api/webhooks/stripe', to: 'webhooks#stripe'

Namespaces

namespace :admin do
  resources :users
end

Nested Resources

resources :articles do
  resources :comments, only: [:index, :create]
end

API Endpoints

Method Endpoint Description
POST /api/upload Upload a routes.rb file
POST /api/compare Compare two uploaded files
GET /api/comparison/:id Get comparison results
GET /api/comparison Get latest comparison
GET /api/export/csv/:id Export comparison as CSV

Project Structure

β”œβ”€β”€ client/                 # React frontend
β”‚   β”œβ”€β”€ src/
β”‚   β”‚   β”œβ”€β”€ components/     # UI components
β”‚   β”‚   β”œβ”€β”€ pages/          # Application pages
β”‚   β”‚   β”œβ”€β”€ lib/            # Utilities
β”‚   β”‚   └── hooks/          # Custom hooks
β”œβ”€β”€ server/                 # Express backend
β”‚   β”œβ”€β”€ services/           # Business logic
β”‚   β”œβ”€β”€ routes.ts           # API routes
β”‚   └── storage.ts          # Data layer
β”œβ”€β”€ shared/                 # Shared types
β”‚   └── schema.ts           # Database schema
└── sample_*.rb             # Example route files

Development

Available Scripts

  • npm run dev - Start development server
  • npm run build - Build for production
  • npm run type-check - Run TypeScript checks

Database Setup (Optional)

For production use with PostgreSQL:

  1. Set up a PostgreSQL database
  2. Configure environment variables:
DATABASE_URL=postgresql://user:password@host:port/database
  1. Run migrations:
npm run db:migrate

Contributing

  1. Fork the repository
  2. Create a feature branch: git checkout -b feature-name
  3. Make your changes
  4. Add tests if applicable
  5. Commit your changes: git commit -am 'Add feature'
  6. Push to the branch: git push origin feature-name
  7. Submit a pull request

License

MIT License - see LICENSE file for details.

Acknowledgments

  • Originally built for comparing Desidime and Pepper platform routes
  • Inspired by the need for better Rails application migration analysis
  • Built with modern web technologies for optimal developer experience

Support

For questions or issues, please open a GitHub issue or contact the maintainers.


Made with ❀️ for Rails developers

Releases

No releases published

Packages

No packages published