Design and Deployment of TinyURL
Deep-diving into the design and deployment of the URL shortening service.
System APIs
To expose the functionality of our service, we can use REST APIs for the following features:
- Shortening a URL
- Redirecting a short URL
- Deleting a short URL
Shortening a URL
We can create new short URLs with the following definition:
shortURL(api_dev_key, original_url, custom_alias=None, expiry_date=None)
The API call above has the following parameters:
Parameter | Description |
| A registered user account’s unique identifier. This is useful in tracking a user’s activity and allows the system to control the associated services accordingly. |
| The original long URL that is needed to be shortened. |
| The optional key that the user defines as a customer short URL. |
| The optional expiration date for the shortened URL. |
A successful insertion returns the user the shortened URL. Otherwise, the system returns an appropriate error code to the user.
Redirecting a short URL
To redirect a short URL, the REST API’s definition will be:
redirectURL(api_dev_key, url_key)
With the following parameters:
Parameter | Description |
| The registered user account’s unique identifier. |
| The shortened URL against which we need to fetch the long URL from the database. |
A successful redirection lands the user to the original URL associated with the url_key
.
Deleting a short URL
Similarly, to delete a short URL, the REST API’s definition will be:
deleteURL(api_dev_key, url_key)
and the associated parameters will be:
Parameter | Description |
| The registered user account’s unique identifier. |
| The shortened URL against which we need to fetch the long URL from the database. |
A successful deletion returns a system message, URL Removed
, conveying the successful URL removal from the system.
Design
Let’s discuss the main design components required for our URL shortening service. Our design depends on each part’s functionality and progressively combines them to achieve different workflows mentioned in the functional requirements.