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

Public:

createShortUrl(longUrl)

lookupLongUrl(shortUrl)

Private:

doesShortUrlExist(shortUrl)




High-Level Design

Loopup if something is used based on a db index

  • First shot-> UUID -> hash -> first x characters
  • Loop if it already exists in db
  • Maybe keep a sequence as a random seed



Detailed Component Design

Scaling is based on the number of collisions and creation tries

Lookups are in a db as a map or kv (k being a primary indexed key)