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:


    List the key non-functional requirements (eg low latency, scalability, reliability, etc.)...


API Design

Define the APIs expected from the system. This is your chance to analyze and define the read and write paths so that you can come up with the high-level design...




High-Level Design

API with 1 main endpoint:

  • Generate short url

It would be:

  • ${server}/short-url


As a input payload API would receive:

  • {longUrl: ${longUrl}}


As response:

  • { shortUrl: ${generatedShortUrl}, id: ${id} }

Where the generatedShortUrl would be the new generated url and the id would be to uniquely identify this object (might be useful if API scales in future to offer list of short urls generated by a certain user, for instance or to give capability of deleting the url)


Detailed Component Design


I would use AWS Serverless resources:

  • Api Gateway
  • Lambda
  • DynamoDB

The API Gateway would serve as the entry point coming from the internet. It would trigger the lambda where I would have the logic to generate new short urls and store the mapping of the id, long url and short url in there.


And that is it.