/short_url

Based on #54 in Exercises for Programmers by Brian Hogan

Primary LanguageElixir

ShortUrl Challenge

This challenge is designed to get you out of your "comfort zone" and expose you to other libraries & patterns you may not be familiar with. This isn't going into production so have fun with it!

Requirements

Write a web application that allows users to take a long URL & convert it to a shortened URL.

Example:

http://really-long-url.com/the/page/I/am/looking/for -> http://localhost:4000/abc1234

The program should:

  1. Accept a long URL

  2. Generate a short local URL like /abc1234

  3. Store the short URL & the long URL together

  4. Redirect visitors to the long URL when the short URL is visited

  5. Track the number of times the short URL is visited

  6. Provide a statistics page for the short URL, such as /abc1234/stats

    • Visiting this URL should show:
      • short URL
      • long URL
      • number of times the short URL was accessed

Constraints

  • Data must use an in memory data store

  • Don't use the Phoenix framework. Plug, Raxx, Cowboy, or any other library are all acceptable.

Challenges

  • Don’t allow an invalid URL to be entered into the form.

  • Detect duplicate URLs. Don’t create a new short URL if one already exists

  • Record the date and time each short URL was accessed

  • Use either: GenServer, Agent, or ETS as the data store

This challenge is based on Exercise 54 in Brian P. Hogan's “Exercises for Programmers" book by PragProg.