Back to Projects

SwiftZip
(Distributed URL Shortener)

A highly scalable, distributed URL shortener service designed to handle high throughput, complete with a modern React frontend and a real-time PostgreSQL analytics dashboard.

The Challenge

Scaling a URL shortener requires handling extreme read-heavy workloads while maintaining strict real-time analytics. Traditional databases quickly become a bottleneck under high throughput.

To solve this, I designed SwiftZip using a Redis-first architecture. It utilizes a custom probabilistic Bloom Filter built on Redis Bitsets to instantly reject queries for non-existent URLs at O(1) time complexity, saving the database from cache-penetration attacks. All read operations are served from Redis memory in sub-milliseconds.

System Architecture

graph TD
    Client[Client Browser] -->|Shorten URL| React[React / Vite UI]
    React -->|POST /api/shorten| FastAPI[FastAPI Backend]
    Client -->|Visits Short Link| FastAPI
    FastAPI -->|1. Check Bloom Filter| Redis[Redis Cache]
    FastAPI -->|2. Check Cache| Redis
    Redis -- Cache Miss --> Postgres[(PostgreSQL)]
    FastAPI -->|3. Record Analytics| Background[FastAPI Background Tasks]
    Background --> GeoIP[IP-API GeoTracking]
    Background --> Postgres
          

Key Features

Cache Penetration Protection

Implemented a custom Bloom Filter using Redis Bitsets to intercept and instantly reject queries for non-existent URLs.

Redis Rate Limiting

A fixed-window rate limiter built on Redis to prevent API abuse and throttle excessive requests (HTTP 429).

Custom Link Expiry

Users can set custom TTLs synchronized natively via Redis SETEX and persisted in PostgreSQL.

Background GeoIP Tracking

Uses httpx in a non-blocking FastAPI Background Task to capture user location without delaying the redirect.

Technology Stack

React FastAPI Redis PostgreSQL Docker Tailwind CSS v4