Rails URL Shortener


# URL Shortener

https://github.com/lucassherwin/rails-url-shortener

Stack: Ruby on Rails 8 · React 19 · TypeScript · PostgreSQL · Solid Queue · Docker · Kamal


# Task

Build a full-stack URL shortener that lets authenticated users and guests shorten links, track click analytics, and manage their URLs through a modern web interface.

Include features such as:


# Solution

# Architecture

The application follows a Rails 8 API + React frontend pattern, with React components embedded in ERB views via React on Rails and Shakapacker. Background work is offloaded to Solid Queue, a database-backed job queue shipped with Rails 8 that eliminates the need for Redis or Sidekiq in production.

# Backend

# Frontend

# Data Model

User ──< Session
User ──< ShortUrl ──< Click
         (guest_token on ShortUrl for unauthenticated users)

Key indexes include a composite (short_url_id, clicked_at) index on clicks for analytics queries and unique indexes on short_urls.alias and users.email_address.

# Infrastructure