SURL is a URL Shortener System which is horizontally scalable unlimitedly.
In order to develop a new feature for the high traffic messaging service of the company, new URL Shortener system is needed. System should be designed such that it should respond very quickly to millions of requests. In addition, it should be unlimitedly scaled horizontally to meet increasing request traffic in the future.
You can see the message flow diagram to indicate messaging flow from client to backend systems as below
Key Components Following will be the key components in the URL shortening application:
- Clients- Web Browsers/Mobile app. It will communicate with the backend servers via HTTP protocol
- Load Balancer- To distribute the load evenly among the backend servers
- Web Servers- Multiple instances of web servers will be deployed for horizontal scaling
- Database - It will be used to store the mapping of long URLs to short URLs
- Caching - We know that our database is going to be read heavily. So we have to find some way to speed up the reading process.
- Java 8
- Spring Boot
- Spring Data MongoDB
- Spring Security
- JUnit
- Mockito
- Maven
- Docker
- Redis
- MongoDB
- NGINX (Load Balancer)
- Elasticsearch * has a issue in feature branch
- Logstash * has a issue in feature branch
- Kibana * has a issue in feature branch
You need to have Java 8 jdk installed on you system.
-
Clone this repository
-
To package jar file and create the app image execute the following command in surl directory:
mvn clean package docker:build
-
To run the system:
docker-compose up -d
-
To shorten a long url:
curl -v -H "Content-Type: application/json" -X POST -d '{"longUrl":"www.google.com"}' http://localhost:8080/api/v1/shortener
-
To access your short url: (SURL is the shorted code generated in the 4th step)
curl -v -X GET http://localhost:8080/api/v1/{SURL}
-
To access statistics for a short url with its key:
curl -v -H "Content-Type: application/json" -X GET http://localhost:8080/api/v1/stat/{SURL}