A URL Shortening Service
A URL shortening service (like bit.ly). Application hosted on littleshorty.link.
- Shortens a given URL to a
shorty
URL - Decodes
shorty
URL - Redirects from
shorty
URL if stored in database
-
Frontend
- Angular
- Particles.js
-
Backend
- Express.js
- Postgresql
-
DevOps
- Docker
- Terraform
Application is hosted on two AWS EC2 instances. One of which is running the frontend client and the other is backend + database (Too poor for AWS RDS). Frontend endpoint littleshorty.link
- Docker
- Docker Compose
docker compose up deploy/docker/docker-compose.yml
Name | Check |
---|---|
Responsive Layout | ✓ |
Persistent Storage | ✓ |
Push to Production | ✓ |
Test Cases | |
Containers | ✓ |
Cron task to remove URL not used for 30 days | ✓ |
Consideration | Analysis |
---|---|
Shortening the URL to be short, maintain ACID properties and able to scale | 1) Use a hashing algorithm + Quick with existing libraries and don't strain server resources - URL becomes long due to fix-sized hash - Will run out of links as hash is fix-sized 2) Use server logic + Can do complex shortening logic - Not easy to identify method to change URL to decimal, then to another base eg. 64 - shorty URL can still be very long if just encode the given URL 3) Use database function + ACID properties confirmed + Database can optimise queries for better runtime + Generated URL is definitely collision resistant - Strain database resources - Hard to do encoding logic in SQL queries I chose to use database function with slight server logic. The idea is to use the lowest available ID (primary key) and encode them to get the new URL. However, as there is a need to have ACID properties, the record needs to be created first so no other URL is encoded with the same ID. The given ID is then encoded with base 62 (a-zA-Z0-9 in random order) and the record is updated. This makes the URL look random and also is the shortest URL possible. Only con is that it strains the database so it is hard to scale. |
Work Done after deadline
- Ability to redirect using
shorty
URL - Write Docs