Having implemented URL shorteners multiple times as technical assessments during interviews, I was intimately familiar with their architectural patterns and common pitfalls. These technical tests typically focus on the basic mechanics: generate a short code, store a mapping, and handle redirects. However, building a production-ready URL shortener for real-world use presents a different set of challenges and considerations.
My primary motivation was practical: I needed a reliable way to share and track links to my blog posts and technical articles across various platforms. While commercial solutions exist, having complete control over the analytics and infrastructure made more sense for my use case.
The service is hosted at dmt.dev/url, built as a lightweight Lambda function that integrates with DynamoDB. One of the key achievements was keeping the entire package size under 5MB, ensuring quick cold starts and efficient deployment. This was accomplished through:
Nothing groundbreaking here - but the implementation does reflect lessons learned from previous projects:
The system provides:
The Lambda function is remarkably efficient:
interface UrlMapping {
shortCode: string; // Partition key
longUrl: string; // Original URL
created: number; // Timestamp
clicks: number; // Counter
lastAccessed: number; // Last click timestamp
}
Unlike typical tech test implementations, this production version includes comprehensive analytics:
The service is integrated into my main domain at dmt.dev/url, leveraging existing infrastructure and SSL certificates. This integration provides:
The transition from technical test to production system highlighted several key differences:
While the current implementation serves its purpose effectively, planned improvements include:
Firstly; this implementation is built with cost in mind - utilising serverless this costs nothing to run. Building a production URL shortener has been an interesting journey from technical test implementations to a real-world service. The sub-5MB package size and efficient architecture demonstrate that lightweight solutions can effectively serve production needs. While the basic concept of URL shortening remains simple, the addition of analytics, security measures, and production-grade reliability transforms it into a genuinely useful tool for tracking and managing shared links.