Skip to content

truggeri/rails-url-shortener

Repository files navigation

Rails Url Shortener

Test Coverage Badge

A simple Rails application that implements an api based url shortener.

RoR Badge PostgreSQL Badge

Github Badge GitHub Actions Badge OpenAPI Badge

Docker Badge

Requirements and Design

For detailed information on the requirements and design, see our detailed design documentation.

Development

To get started, you'll need to setup dependencies.

PostgreSQL Database

This app uses PostgreSQL 13 for it's datastore. In order to configure one, provide a database URL via an environment variable.

export DATABASE_URL=postgres://<username>:<password>@<host>:<port>/rails_url_shortener

This database can be setup in any fashion that you choose. Options include local install, Docker, or as a web service. If you'd like to use Docker, we have a Docker Compose file to help,

cat docker-compose.env
 export URL_SHORTENER_DB_DATABASE=rails_url_shortener
 export URL_SHORTENER_DB_PASSWORD=somepassword
 export URL_SHORTENER_DB_USERNAME=database_user
 export URL_SHORTENER_DB_URL=postgres://$URL_SHORTENER_DB_USERNAME:$URL_SHORTENER_DB_PASSWORD@localhost:5432/$URL_SHORTENER_DB_DATABASE
source docker-compose.env
docker-compose up --detach db

Docker

If you'd like to run the application using Docker, there is a Dockerfile provided. To use, build the container first and then run it with your configured database and port settings.

docker build -t rails-url-shortener .
docker run --rm -e DATABASE_URL=$DATABASE_URL -p 3000:3000 rails-url-shortener

Future Improvements

Of course, there's always more to do. Read our documentation on ideas for improvements and future work.