post createUrl(longUrl,userId, vanityUrl) -> creates a shortUrl
delete deleteUrl(shortUrl,userId) -> deletes a url
update editUrl(shortUrl, customUrl, userId) -> changes a shortUrl based on account status
redirect(shortUrl) -> Directs user to the longUrl when a short url is input
user{
userId: string,
password: string,
accountStatus: String (basic, premium)
}
url {
urlId: string,
shortUrl: string,
longUrl: string,
userId: string
}
createUrl:
redirect:
For createUrl there would have to be a check to see if the user has an appropriate account in order to make custom urls. We will utilize optimistic concurrency in order to mitigate a race condition of two users inputting the same shortUrl to two different longUrls. If this happens the system will check the state of the database before one user creates the shortUrl and then also after they try to commit it to the database where the two states of the database will be compared before the commit goes through.
What are some future improvements you would make? How would you mitigate the failure scenario(s) you described above?