Skip to content

A URL Shortener Microservice developed using Spring Boot and MongoDB, which is used to shorten the Long URL into Shorten URL. It provides REST API endpoints to interact with.

License

Notifications You must be signed in to change notification settings

animesh-anand-dev/URL-Shortener-Microservice

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

URL-Shortener-REST-API

A URL Shortener Microservice developed using Spring Boot and MongoDB, which is used to shorten the Long URL into Shorten URL. It provides REST API endpoints to interact with. tech-logos

Demo

Full Stack Project with React and Spring Boot where this project is used as a backend.

Screenshots

screenshot-api

Run Locally

  1. Clone the project
 git clone https://github.com/animesh-anand-dev/URL-Shortener-Microservice.git
  1. Download Spring Tool Suite or Eclipse IDE open the Parent Folder using any of thse IDE as workspace.

  2. Import the Cloned project in IDE.

  3. Create and Setup account for MongoDB Atlas on MongoDB Cloud.

  4. Create User and Password for the Database.

  5. Create Database

  6. Go to application.properties file

  7. Replace the value of key spring.data.mongodb.uri and spring.data.mongodb.database which is your coonection string and database name respectively.

  8. Now Run your project as Spring Boot App

  9. Open your favourite API testing tool like Postman for desktop and Talend API Tester

😊 Happy Coding 🎉

API Reference

Get all urls

  GET /urls
  http://localhost:5000/urls

Get a url details

  GET /${id}/details
  http://localhost:5000/random_id/details
Parameter Type Description
id string Required. Id of Shorten Url to fetch details

Post a url

  POST /urls
  http://localhost:5000/urls
Request body Type Description
originalUrl string Required. originalUrl of Long URL to create shorten link.

Get request to shorten link which redirects to its original URL

  GET /${id}
  http://localhost:5000/random_id

Dependencies Used

  • Spring Web Build web, including RESTful, applications using Spring MVC. Uses Apache Tomcat as the default embedded container.
<dependency>
   <groupId>org.springframework.boot</groupId>
   <artifactId>spring-boot-starter-web</artifactId>
</dependency>
  • Spring Data MongoDB Store data in flexible, JSON-like documents, meaning fields can vary from document to document and data structure can be changed over time.
<dependency>
   <groupId>org.springframework.boot</groupId>
   <artifactId>spring-boot-starter-data-mongodb</artifactId>
</dependency>
  • Guava: Google Core Libraries For Java Guava is a suite of core and expanded libraries that include utility classes, Google's collections, I/O classes, and much more.
<dependency>
   <groupId>com.google.guava</groupId>
   <artifactId>guava</artifactId>
   <version>31.1-jre</version>
</dependency>
  • Apache Commons Validator Apache Commons Validator provides the building blocks for both client side validation and server side data validation. It may be used standalone or with a framework like Struts.
<dependency>
   <groupId>commons-validator</groupId>
   <artifactId>commons-validator</artifactId>
   <version>1.7</version>
</dependency>
  • SpringDoc OpenAPI Starter WebMVC UI The springdoc-openapi generates API documentation as per OpenAPI 3 specification. Moreover, it also handles the Swagger UI configuration for us, making API document generation a fairly simple task.
<dependency>
   <groupId>org.springdoc</groupId>
   <artifactId>springdoc-openapi-starter-webmvc-ui</artifactId>
   <version>2.0.0</version>
</dependency>
  • Spring Boot Starter HATEOAS Starter for building hypermedia-based RESTful web application with Spring MVC and Spring HATEOAS.
<dependency>
   <groupId>org.springframework.boot</groupId>
   <artifactId>spring-boot-starter-hateoas</artifactId>
</dependency>
  • Spring Boot DevTools Provides fast application restarts, LiveReload, and configurations for enhanced development experience.
<dependency>
   <groupId>org.springframework.boot</groupId>
   <artifactId>spring-boot-devtools</artifactId>
   <scope>runtime</scope>
   <optional>true</optional>
</dependency>

Author

animesh-anand Animesh Anand

Show your support

Give a ⭐️ if this project helped you!

📝 License

Copyright © 2023 Animesh Anand.
This project is MIT License licensed.

About

A URL Shortener Microservice developed using Spring Boot and MongoDB, which is used to shorten the Long URL into Shorten URL. It provides REST API endpoints to interact with.

Topics

Resources

License

Stars

Watchers

Forks

Languages