This project is a a sample API URL shortener create like bitly.
Using all technologies down bellow, I demonstrate how can I implement a Restful API with Oauth2 to secure the API routes and how I can use Docker to instance an unlimited number of instances with a load balancer to redirect all the requests to the instances.
Visit my GitHub repository to know how I implemented this project:
For the project application architecture, Clean Architecture was chosen that makes the application separated in layers and keeps the internal layers independent of the external layers. The Clean Architecture separate the responsibility of each part of the project.
- Entities – Layer that encapsulate the business entities.
- User cases – Layer that contains the specific business rules.
- Interface – Layer that has the purpose of convert data in the most accessible and convenient way possible to the Entities and User Cases layers.
- Frameworks – Layer that contains tools like database, user interface, etc
RUN THE PROJECT
To execute the project, you will need the Docker and Docker-compose installed in your machine
# cd url-shortener # mvn clean package dockerfile:build && docker-compose -f ./docker/docker-compose-local.yml up --scale app=2 -d
The number os instances to be executed is set on the –scale command parameter –scale app=2 (Number of instances)
The application users will be create automatically when the application start.