- Spring Boot
- Swagger v2
- Clone the repo:
git clone https://github.com/thecoducer/url-shortener-api.git
- Create a database in MYSQL Workbench:
create database shortenurl_db;
- Open the project in IntelliJ or Eclipse. Set configurations in IDE to run a Maven project.
- Edit the application.properties file and set your own MYSQL username and password.
# Connection to Database
spring.datasource.url= jdbc:mysql://localhost:3306/shortenurl_db
spring.datasource.username= <your username here>
spring.datasource.password= <your password here>
- And, now run the application.
- Built REST API endpoints like /storeurl, /count, /get and /list.
- Used MySQL as database to persist data.
- Used @ControllerAdvice annotation to build a global exception handler.
- Have written test classes.
- Used MD5 hash and Base64 encoder to generate the short key.
- Integrated Swagger framework for REST API documentation.
- Paid attention to modular design, and have written readable and maintanable code.
Using this technique we can generate around 280 Trillion unique short keys.