Requirements


Functional Requirements:


  • Create a short URL for a given long URL.
  • Return the long URL associated with a given short URL.



Non-Functional Requirements:


  • A new short url must be created withing 200ms
  • A short url must be expanded within 100ms
  • URL's live indefinitely
  • There will never be any collision - short url's will get longer over time to accomodate this.


API Design


POST `/` request to create a new URL. JSON Takes a `longURL` param and returns JSON for both long and short urls (if authorized)

GET `/{shortURL}/meta` returns the data for the url (if authorized)

GET `/{shortURL}` returns a non-permanent redirect 302 to the expanded url



High-Level Design

Uses AWS DynamoDB for storage of urls. User storage and validation. Uses AWS serverless lambda with Cloudfront wiring to the endpoints.



Detailed Component Design

Each new url added simply increments a counter which is converted to an ever growing length url-safe string of charachters. This will be case sensitive to allow the largest characterset. If say the charchterset is 64 then the first 64 urls will only be one charachter long. the next 4096 will be two charachters long and the next 262144 (64^3) urls will be 3 charachters long. The Dynamo db will be indexed on the short URL. Data wil the url can be the long url, a creation date, creation user (for metadata access permissions) and a useage count.


We may want an admin component - out of scope for now