A URL shortener, built with Phoenix, Elixir, Genservers, ETS, and Postgres
All URLs are saved to our Postgres DB, with concurrency through Genservers and an :ets table connected to our database instance.
You will need the following pieces to run the application:
- Elixir/Erlang
- Phoenix
- Postgres
- PNPM/NPM/Yarn
- There is a production version of the application that can be seen here: https://pocket-url.fly.dev/ (It may take a moment to load as it only has one machine assigned and it hibernates)
- There is a workflow that is designed to show a simple CI/CD workflow for the app from dev to production, that runs testing and formatting.
- All instructions below assume you are working with an Apple environment
If you are missing any of the prerequisites, please follow the instructions at the bottom of this document.
If you have all the prerequisites, follow the steps below to get the site running on local:
- Run
touch config/local.secret.exs
(or manually add thelocal.secret.exs
file to the config folder) - Inside the
local.secret.exs
, add the following and replace the prompts:
import Config
config :pocket_url, PocketUrl.Repo,
username: "REPLACE_ME_WITH_YOUR_POSTGRES_USERNAME",
password: "REPLACE_ME_WITH_YOUR_POSTGRES_PASSWORD"
- Run each of the following:
mix deps.get
mix ecto.setup
mix tailwind.install
mix esbuild.install
cd
in the/assets
folder and runpnpm install
(or, npm or yarn, depending on your choice)cd
back into the root and runmix phx.server
and visit the url at the localhosthttps://localhost:4001
- You can also run
mix test
to run the validation tests.
You can skip any of the following steps if you already have the target downloaded.
- Homebrew
- https://brew.sh/
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
- Elixir
brew install elixir
- Erlang
brew install erlang
If you wish to user a version manager for Elixir and Erlang, I would recommend asdf
- Phoenix
- https://hexdocs.pm/phoenix/installation.html
mix local.hex
mix archive.install hex phx_new
- Postgres
brew install postgresql
- Follow the commands from brew post-installation
- PNPM/NPM/Yarn
- If you wish to use any of the following, you can install them through brew as well. I would recommend PNPM, but for simplicity, NPM works