Skip to content

URL Shortener written in Java 8, Spring Boot, Spring MVC, Spring Data JPA and H2DB

License

Notifications You must be signed in to change notification settings

marcusberro/url-shortener

Repository files navigation

url-shortener

This is an URL Shortener written in Java 8, Spring Boot, Spring MVC, Spring Data JPA and H2DB

  • Generate a hexa code based url
  • Save information related to redirections: user-agent, source-host, requets-date...
  • List all available shorten urls

Usage & Installation

Under construction version: it's better run it in idea IDE with Gradle plugin

There are 2 database options: mysql or h2 in memory. To run with a specific db inform spring.profiles.active property calling gradle:

gradle bootRun -Pspring.profiles.active=mysql

or

gradle bootRun -Pspring.profiles.active=h2

If it doesn't find this property, default property is h2

Once you start the application, the following endpoints are available so far:

Home (Future single-page app)

[GET] http://localhost:8080

Shorten url

[POST] http://localhost:8080
{url-to-be-shortened-in-body}

List all shorten urls

[GET] http://localhost:8080/shorten-urls

Redirects url

[GET] http://localhost:8080/{code}

H2 Console (if you need to check in-memory database content)

[GET] http://localhost:8080/h2-console/

To be continued...

Development

Project Details

  • REST based API
  • Single Jar Application
  • Embedded Application server Undertown
  • In-memory H2 and Mysql Relational Databases using Gradle and Spring profiles
  • Springboot schema.sql and data.sql auto running

Tech

Url Sortener uses a number of open source projects to work properly:

Future Releases

  • Improve url code generation (choose an algoritm)
  • Url validation before shorten
  • Single-page application frontend

Todos/Enhancements

Strong desirable:

  • Dockerize
  • Refactor Spring and gradle build Profile integration
  • Tuning: undertown and HikariCP
  • Support for other Embedded Application server options (Tomcat/Jetty)
  • Multiple Relational Database support: Mysql and H2 supported, Postgres needed
  • Generate tables with ddl scripts: springboot database initialization supported, Flyway integration needed
  • Light footprint, can run on very constrained systems

Maybe, someday...

  • Refuses abusive Phishing and Malware Urls
  • Actively scans short Urls to identify possible threats

About

URL Shortener written in Java 8, Spring Boot, Spring MVC, Spring Data JPA and H2DB

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages