User creates an account in the app. The logged-in user provides a long URL and returns a short URL. The user can provide their own alias for the long url, the server accepts the alias if it's not already taken by someone else. When you hit the shortened URL, the database checks the shortcode and redirects you to the main URL. The user can see their own shorten urls.
- Server authenticates the users using JWT Authentication
- Server validates the URL
- Shorten request returns the encoded short url
- Server need not encode the duplicate destination urls for the same user
- User can provide their own alias for the long url, the server only accepts the alias if it's not already taken by someone else
- Server should redirect the user to destination url if a valid proxy/alias is sent
- Server should throw an exception if incorrect proxy/alias is sent.
- logged-in user can see their own shorten urls.
- Admin user can list all the users and shorten urls and cannot access user specific endpoints
- Server checks the shortened url is password protected or not. Returns a html page asking for password and then validates it.
- Server checks the expiration time of shortened url, returns a json saying expired.
After starting the application, run the tests in test package to check the functionality.
Two tables are used, "user" for storing user specific information. "shortUrl" for storing encoded string/alias corresponding to long urls.
Find the entity-relationship diagram here.
- cd docker
- docker compose up
- Run UrlShortenerApplication.java
Java, Spring boot, Spring Security, JWT, REST APIs, MySQL, Docker
Consider a scenario where the marketing/ sales team wants to get feedback on a product demo from a registered user. In the response, all they want to collect is one feedback whether the customer liked the product demo or not. For it to be meaningfully analyzed and uniquely identify the customer, they need to collect the registered details again - for example: name, phone and email.
So, the requirement is to convert the long URL to a text friendly URL which can be sent over SMS and when the customer opens the link - his registered info is pre-filled.
Default short URL - https://forms.gle/rLSRXJDhswwu3ybh9 pointing to https://docs.google.com/forms/d/e/1FAIpQLSdF8g-Jw08ny_UhyqCvEBmZcdtpS53_1pP_kTPELS6lh_AQlA/viewform
Maps to a custom unique URL like: nexturl.in/x48tr which contains the pre-filled information as well. Basically, for every customer, there will be a new and unique short URL created.