a long URL and receive a shortened URL
after which they no longer work.
In terms of database and storage:
Total size per URL = 20 + 10 + 10 = 40 bytes
If we expect that each request to the URL shortening service would require:
POST /shorten{ "longUrl": "http://example.com/some/very/long/url", "customAlias": "myCustomAlias" // optional
}
{ "shortUrl": "http://short.ly/abc123"}
GET /{shortCode}GET /analytics/{shortCode}{ "shortUrl": "http://short.ly/abc123", "clickCount": 150,
"createdAt": "2023-01-01T00:00:00Z", "lastAccessedAt": "2023-01-15T12:00:00Z"
}
PUT /shorten/{shortCode}{ "longUrl": "http://example.com/new/long/url"}
{ "message": "URL updated successfully"}
DELETE /shorten/{shortCode}Here's a proposed ERD to illustrate the relationships between these entities
short_code and long_url in the URL_MAPPING table for faster lookups.Here's a conceptual diagram to visualize the high-level components and their interactions:
When a user submits a long URL to be shortened, the following flow occurs:
When a user accesses a shortened URL, the flow looks like this:
When a user wants to see analytics for a shortened URL, the flow is as follows:
When a user wants to delete a previously shortened URL:
The communication between these components can be summarized as follows:
Here's a diagram that outlines these components and their interactions: