SnapURL — Next-Gen Serverless URL Shortener
A highly scalable, serverless URL shortening platform built in TypeScript with Express.js and Turso (LibSQL). Features instant QR code generation, zero cold-start latency, custom aliases, real-time analytics, and a bespoke glassmorphic UI.
The Problem
Traditional URL shorteners rely on monolithic servers and centralized databases, introducing high geographic latency, difficult scaling during viral traffic spikes, and expensive idle compute costs.
Architecture & Approach
Engineered a 100% Serverless Edge Architecture wrapping an Express.js API in Vercel Serverless Functions. Adopted Turso (LibSQL) for distributed edge data replication, ensuring microsecond read latencies globally. Developed a zero-dependency Vanilla JS/CSS frontend with a bespoke glassmorphic design system and fluid typography, communicating via a RESTful API with recursive collision resolution and atomic SQL updates.
Engineering Challenges & Solutions
- Handling base62 collision resolution in a serverless environment through recursive SQL retry algorithms
- Preventing race conditions in real-time analytics by offloading atomic increments natively to the database
- Adapting an Express.js monolith to run flawlessly within Vercel's ephemeral Serverless Functions using strategic vercel.json rewrites
- Designing a strict Layered (N-Tier) Architecture with comprehensive Jest unit testing and repository mocking for LibSQL
Outcome & Results
A production-ready, infinitely scalable URL shortener capable of handling viral traffic spikes from 0 to 10,000+ concurrent requests with zero cold-start latency and ultra-low geographic latency.
Lessons Learned
Stateless, edge-distributed architectures fundamentally change how we think about scale. Decoupling the business logic from the database layer via the Repository pattern not only makes testing trivial but allows swapping underlying infrastructure (like migrating from local SQLite to edge Turso) with zero downtime.