- Shortify is a distributed and highly available URL Shortening service, following the guidelines of efficient System Design and builting on the Reactjs as front-end and Spring boot as back-end.
- It uses Redis as a cache, and MongoDB as a NoSQL database.
- It uses Nginx that acts as a load balancer, and a reverse proxy for the backend server.
- It uses an Unique ID generator inspired by Twitter snowflake for id and hash generation.
- The application is containerized by Docker.
- This is a project demonstrating the entire development process and is meant to be run in a local environment.
- Install Docker Desktop for a quick setup.
- Clone this repository
- Open the terminal and start the container with docker compose:
docker compose up --build
# We can also scale instances of an image for higher scalability or distribution.
Example: docker compose up --build --scale spring-boot-server=3
Screen.Recording.2023-12-29.at.6.14.21.AM.mov
You can read about Twitter snowflake and this blog (Generating unique IDs in a distributed environment at high scale) to understand the Id generator I used in this application
I use the base 62 convention which is referred to in System Design Interview by Alex Xu to convert Id to shortURL.
Base 62 conversion is used as there are 62 possible characters for hashValue. Let us use an example to explain how the conversion works: Convert 1115710 to base 62 representation (1115710 represents 11157 in a base 10 system).
• From its name, base 62 is a way of using 62 characters for encoding. The mappings are: 0-0, ..., 9-9, 10-a, 11-b, ..., 35-z, 36-A, ..., 61-Z, where ‘a’ stands for 10, ‘Z’ stands for 61, etc.
• 1115710 = 2 x 62^2 + 55 x 62^1 + 59 x 62^0 = [2, 55, 59] -> [2, T, X] in base 62 representation.
• Thus, the short URL is https://tinyurl.com/2TX
URL shortening
URL redirecting