Skip to content

URL Shortener

Short links with cached redirects, distributed rate limiting and queued analytics.

ClientNginxAPIRedisMySQLBullMQ worker

system sketch

00 · system architecture

Overview

A full-stack URL shortening platform with a React dashboard and an Express/TypeScript API. It supports custom aliases, link expiry, click limits and bcrypt-hashed password-protected links, secured by JWT authentication with per-user ownership enforcement.

Problem

Redirects are the hot path: they have to stay fast under load, stay correct when the API is scaled horizontally, and keep working even when click analytics fail.

Architecture

Nginx sits in front of horizontally scaled API containers. Redirects read through a Redis cache before MySQL, and click analytics are pushed onto a BullMQ queue that a separate worker drains into the database. The full stack (app, worker, MySQL, Redis, Nginx) runs in Docker Compose.

Key decisions

  1. 01

    Cache-aside on the redirect path

    A Redis cache-aside layer with TTL-based expiry and write-through invalidation, so cached redirects stay fresh when a link changes.

  2. 02

    Distributed rate limiting

    Redis-backed rate limiting shared by every instance, verified correct across 3 horizontally scaled containers behind Nginx.

  3. 03

    Analytics off the critical path

    Click analytics are decoupled into a BullMQ worker queue with exponential-backoff retries, so redirects are unaffected by analytics failures and queued events survive worker downtime.

  4. 04

    Protected links and ownership

    Password-protected links are bcrypt-hashed, and JWT authentication enforces per-user ownership of links.

Results

  • 31msp95 latency on cached redirects (k6, 20 concurrent users)
  • 114msp95 on password-protected links, isolating bcrypt's verification cost
  • 3horizontally scaled containers with rate limiting verified correct

Containerized with Docker Compose; builds validated with GitHub Actions CI.

.other projects

.say hello

Hiring for a backend role? Drop me an email and let's talk.