Author: Jason Thai
Table of Contents
After I wrote some of my thoughts about my URL shortener service TinayAlias and others here in Things I’ve Learned Hosting a URL Shortener Service. It occured to me I did not mention much about what my service had to offer. Even though TinyAlias is no longer operational, I feel the service did provide some interesting features compared to others. This post will lay out its design and highlight a few interesting things with respect to both backend and front end implementations.
- The Main app handles the main logic of creating shortened URL and its metadata, user authentication, and other blocking operations.
- The Worker service receives a job from the job queue and executes tasks such as parsing request’s geolocation, detecting spam, expiring URL, and other non-blocking operations.
- The Scheduler service runs as a cron to delegate jobs to the worker service.
Some function and feature highlights
I added a user authentication flow that let you sign up, sign in, reset your password. Building this from scratch is quite fun. Sessions are Cookie-based and passwords are encrypted by
bcrypt and stored in DB.
Password protected links and link expiration
Link passwords are encrypted securely and stored in DB. Scheduler service periodically sends expiration job to worker service to detect if any links have expired and marked them as invalid.
Spam detection flow
This is one of the more interesting backend features I added. Whenever a URL is shortened, the main app will dispatch a spam detection job to the worker service. Worker service then calls Google safebrowsing API to detect if a URL is safe and update that URL status. The scheduler also periodically dispatch spam detection jobs to recheck existing URLs.
Whenever a link is clicked, the service will parse the location based on the user’s IP address. This is then aggregated to show where the links are accessed geographically.
This is a fun feature that I added that makes the user wait for a few seconds before redirecting them to the original URL. The page also displays some quotes of the day provided by https://favqs.com
I also added a page to allow users to view trending news and get the shortened URL within the app. News is provided by News API.
Designing and implementing TinyAlias from scratch is a fun side project for me.