{"id":19483525,"url":"https://github.com/librity/ignite_rockelivery","last_synced_at":"2025-09-10T10:33:09.499Z","repository":{"id":99704072,"uuid":"350533464","full_name":"librity/ignite_rockelivery","owner":"librity","description":"Rocket Seat - Ignite - Elixir - A food delivery backend made with Elixir and Phoenix.","archived":false,"fork":false,"pushed_at":"2022-02-25T12:01:34.000Z","size":237,"stargazers_count":2,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-01-08T07:39:01.911Z","etag":null,"topics":["elixir","phoenix-framework","rockelivery","rocketseat-ignite"],"latest_commit_sha":null,"homepage":"https://rockelivery.gigalixirapp.com","language":"Elixir","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/librity.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-03-23T00:45:32.000Z","updated_at":"2024-09-27T16:11:28.000Z","dependencies_parsed_at":null,"dependency_job_id":"dc179214-8bc9-4147-b010-345273bc43f0","html_url":"https://github.com/librity/ignite_rockelivery","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/librity%2Fignite_rockelivery","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/librity%2Fignite_rockelivery/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/librity%2Fignite_rockelivery/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/librity%2Fignite_rockelivery/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/librity","download_url":"https://codeload.github.com/librity/ignite_rockelivery/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":240718943,"owners_count":19846482,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["elixir","phoenix-framework","rockelivery","rocketseat-ignite"],"created_at":"2024-11-10T20:15:26.242Z","updated_at":"2025-02-25T17:45:20.882Z","avatar_url":"https://github.com/librity.png","language":"Elixir","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Rocket Seat Ignite - Rockelivery\n\n[![Elixir CI](https://github.com/librity/ignite_rockelivery/actions/workflows/elixir_ci.yml/badge.svg)](https://github.com/librity/ignite_rockelivery/actions/workflows/elixir_ci.yml)\n[![codecov](https://codecov.io/gh/librity/ignite_rockelivery/branch/main/graph/badge.svg)](https://codecov.io/gh/librity/ignite_rockelivery)\n\n- Production: https://rockelivery.gigalixirapp.com/\n\n## Table of Contents\n\n- [About](#about)\n- [Endpoints](#endpoints)\n- [Setup](#setup)\n- [Bash Commands](#bash_commands)\n- [Elixir Commands](#elixir_commands)\n- [Libs](#libs)\n- [Docs](#docs)\n- [Resources](#resources)\n\n## About \u003ca name = \"about\"\u003e\u003c/a\u003e\n\nA food delivery backend made with Elixir and Phoenix.\n\n## Endpoints \u003ca name = \"endpoints\"\u003e\u003c/a\u003e\n\nBuilt-in:\n\n- `GET` http://localhost:4000/dashboard\n\n`Welcome`\n\n- `GET` http://localhost:4000/api/welcome/:test\n\n`Users`\n\n- `GET` http://localhost:4000/api/users\n- `GET` http://localhost:4000/api/users/:id\n- `POST` http://localhost:4000/api/users\n- `PUT` http://localhost:4000/api/users/:id\n- `DELETE` http://localhost:4000/api/users/:id\n\n`Items`\n\n- `POST` http://localhost:4000/api/items\n\n## Setup \u003ca name = \"setup\"\u003e\u003c/a\u003e\n\n1. Install `asdf`, an extensible version manager for node, clojure, elixir\n   and ruby:\n\n```bash\n# Install apt-get packages\n$ sudo apt install curl git\n\n# Clone asdf\n$ git clone https://github.com/asdf-vm/asdf.git ~/.asdf --branch v0.8.0\n\n# Add it to your path\n$ echo '# asdf version manager' \u003e\u003e ~/.bashrc\n$ echo '. $HOME/.asdf/asdf.sh' \u003e\u003e ~/.bashrc\n$ echo '. $HOME/.asdf/completions/asdf.bash' \u003e\u003e ~/.bashrc\n```\n\n- SOURCE: https://asdf-vm.com/#/core-manage-asdf\n\n2. Install `Erlang`, `Elixir` and `Phoenix`:\n\n```bash\n# Install apt-get packages\n$ sudo apt-get -y install build-essential autoconf m4 libncurses5-dev \\\n  libwxgtk3.0-gtk3-dev libgl1-mesa-dev libglu1-mesa-dev libpng-dev libssh-dev \\\n  unixodbc-dev xsltproc fop libxml2-utils libncurses-dev openjdk-11-jdk\n\n# Add plugins\n$ asdf plugin-add erlang\n$ asdf plugin-add elixir\n\n# Install and set Elixir\n$ asdf install elixir 1.11.3\n$ asdf global elixir 1.11.3\n\n# Install and set Erlang\n$ asdf install erlang 23.2\n$ asdf global erlang 23.2\n\n# Verify installation\n$ erl --version\n$ elixir --version\n\n# Install Phoenix\n$ mix archive.install hex phx_new 1.5.8\n```\n\n### Postgres\n\nCreate a postgress docker container with:\n\n```bash\n$ docker run --name postgres -e POSTGRES_PASSWORD=postgres -p 5432:5432 -d postgres\n```\n\n## Bash Commands \u003ca name = \"bash_commands\"\u003e\u003c/a\u003e\n\n```bash\n# Create phoenix app without webpacker or html views\n$ mix phx.new app_name --no-webpack --no-html\n\n# Intall dependencies\n$ mix deps.get\n\n# Compile project\n$ mix compile\n\n# Generate linter config file\n$ mix credo.gen.config\n\n# Run linter\n$ mix credo --strict\n\n# Start Phoenix dev server on http://localhost:4000\n$ mix phx.server\n\n# Start your project as an Interactive Elixir session\n$ iex -S mix\n\n# List all configured routes\n$ mix phx.routes\n\n# Generate JWT secret\n$ mix guardian.gen.secret\n```\n\n### Ecto\n\n```bash\n# Create and migrate database\n$ mix ecto.setup\n\n# Create a migration\n$ mix ecto.gen.migration migration_name\n\n# Run pending migrations\n$ mix ecto.migrate\n\n# Drop and migrate databases\n$ mix ecto.reset\n\n# Drop databases\n$ mix ecto.drop\n\n# Create databases\n$ mix ecto.create\n```\n\n### Tests\n\n```bash\n# Run tests\n$ mix test\n\n# Run tests w/ coverage report\n$ mix test --cover\n\n# Generate coverage report w/ excoveralls\n$ mix coveralls\n\n# Generate and save coverage report as html\n$ mix coveralls.html\n```\n\n### Local release\n\n```bash\nexport SECRET_KEY_BASE=\"$(mix phx.gen.secret)\"\nexport DATABASE_URL=\"postgresql://postgres:postgres@localhost:5432/rockelivery_dev\"\nMIX_ENV=prod mix release\nMIX_ENV=prod APP_NAME=rockelivery PORT=4000 _build/prod/rel/rockelivery/bin/rockelivery start\n```\n\n### Gigalixir deploy\n\n```bash\nAPP_NAME=$(gigalixir create --name rockelivery)\ngigalixir apps\ngit remote -v\necho \"elixir_version=1.11.2\" \u003e elixir_buildpack.config\necho \"erlang_version=23.2\" \u003e\u003e elixir_buildpack.config\ngigalixir pg:create --free\ngigalixir pg\ngigalixir config\n\n# Deploy\ngit push gigalixir\ngigalixir ps\ngigalixir open\ngigalixir logs -a rockelivery\n\n# Database\ngigalixir account:ssh_keys:add \"$(cat ~/.ssh/id_rsa.pub)\"\ngigalixir ps:migrate\n```\n\n### Remote console\n\n`gigalixir ps:remote_console`\n\n```elixir\nSystem.cmd(\"whoami\", [])\nSystem.cmd(\"echo\", [\"hello\"], into: IO.stream(:stdio, :line))\nseed_script = Path.join([\"#{:code.priv_dir(:rockelivery)}\", \"repo\", \"seeds.exs\"])\nCode.eval_file(seed_script)\n```\n\n## Elixir Commands \u003ca name = \"elixir_commands\"\u003e\u003c/a\u003e\n\n### Users\n\nCreate a user:\n\n```elixir\n\u003e user_params = %{\n  name: \"Luisito\",\n  age: 40,\n  email: \"luisito@example.com\",\n  cpf: \"12345678910\",\n  address: \"paper street 123\",\n  cep: \"01001000\",\n  password: \"password\"\n}\n\u003e Rockelivery.Users.Create.call(user_params)\n```\n\nFetch users:\n\n```elixir\n\u003e Rockelivery.Repo.all(Rockelivery.User)\n\u003e Rockelivery.Repo.get(Rockelivery.User, \"8623cdd8-7cad-43cc-953b-c30260a349f4\")\n\n\u003e Rockelivery.Users.Get.by_id(\"8623cdd8-7cad-43cc-953b-c30260a349f4\")\n\u003e Rockelivery.Users.Get.by_id(\"8623cdd8-7cad-43cc-953b-c30260a349f8\")\n\u003e Rockelivery.Users.Get.by_id(\"8623cdd8\")\n\n\u003e Rockelivery.Users.GetV2.by_id(\"8623cdd8-7cad-43cc-953b-c30260a349f4\")\n\u003e Rockelivery.Users.GetV2.by_id(\"8623cdd8-7cad-43cc-953b-c30260a349f8\")\n\u003e Rockelivery.Users.GetV2.by_id(\"8623cdd8\")\n\n\u003e Rockelivery.Users.GetV3.by_id(\"8623cdd8-7cad-43cc-953b-c30260a349f4\")\n\u003e Rockelivery.Users.GetV3.by_id(\"8623cdd8-7cad-43cc-953b-c30260a349f8\")\n\u003e Rockelivery.Users.GetV3.by_id(\"8623cdd8\")\n```\n\nUpdate a user:\n\n```elixir\n\u003e updated_user_params = %{\n  \"id\" =\u003e \"9a519870-ff34-40ff-b24d-a0a387c8e73a\",\n  \"name\" =\u003e \"UPDATEDDDDDD\",\n  \"age\" =\u003e 40,\n  \"email\" =\u003e \"UPDATEDDDDDD@UPDATEDDDDDD.com\",\n  \"cpf\" =\u003e \"UPDATEDDDDD\",\n  \"address\" =\u003e \"UPDATEDDDDDD\",\n  \"cep\" =\u003e \"UPDATEDD\"\n}\n\u003e Rockelivery.Users.Update.call(updated_user_params)\n```\n\nDelete a user:\n\n```elixir\n\u003e Rockelivery.Users.Delete.call(\"8623cdd8-7cad-43cc-953b-c30260a349f4\")\n\u003e Rockelivery.Users.GetV3.by_id(\"8623cdd8-7cad-43cc-953b-c30260a349f8\")\n\u003e Rockelivery.Users.GetV3.by_id(\"8623cdd8\")\n```\n\nVerify password:\n\n```elixir\n\u003e {:ok, %{password_hash: hash}} = Rockelivery.Users.Get.by_id(\"a2a60a12-1c03-4357-b370-c78ed28a9e38\")\n\u003e Pbkdf2.verify_pass(\"password\", hash)\ntrue\n\u003e Pbkdf2.verify_pass(\"badddddd\", hash)\nfalse\n\n\u003e params = %{\n\t\"id\" =\u003e \"a2a60a12-1c03-4357-b370-c78ed28a9e38\",\n\t\"password\" =\u003e \"password\"\n}\n\u003e RockeliveryWeb.Auth.Guardian.authenticate(params)\n\u003e bad_params = %{\n\t\"id\" =\u003e \"a2a60a12-1c03-4357-b370-c78ed28a9e38\",\n\t\"password\" =\u003e \"badddddd\"\n}\n\u003e RockeliveryWeb.Auth.Guardian.authenticate(bad_params)\n```\n\n### Orders\n\nOrders report:\n\n```elixir\n\u003e Rockelivery.Orders.Report.create()\n```\n\n### Misc\n\nTesla HTTP client:\n\n```elixir\n\u003e Tesla.get(\"https://api.github.com/users/danilo-vieira/repos\")\n\u003e Tesla.get(\"https://viacep.com.br/ws/01001000/json/\")\n\u003e Tesla.get(\"https://viacep.com.br/ws/01001-000/json/\")\n\u003e Tesla.get(\"https://viacep.com.br/ws/00000000/json/\")\n\u003e Tesla.get(\"https://viacep.com.br/ws/123/json/\")\n```\n\nViaCep client:\n\n```elixir\n\u003e ViaCEP.Client.get_cep_info(\"01001000\")\n\u003e ViaCEP.Client.get_cep_info(\"01001-000\")\n\u003e ViaCEP.Client.get_cep_info(\"00000000\")\n\u003e ViaCEP.Client.get_cep_info(\"123\")\n```\n\nStack server:\n\n```elixir\n\u003e {:ok, pid} = Rockelivery.Stack.start_link()\n\u003e Rockelivery.Stack.push(pid, :world)\n\u003e Rockelivery.Stack.push_async(pid, :world)\n\u003e Rockelivery.Stack.pop(pid)\n\u003e Rockelivery.Stack.pop_async(pid)\n```\n\nEnum:\n\n```elixir\n\u003e Enum.chunk_every([1, 2, 3, 4, 5, 6, 7, 8], 3) |\u003e Enum.flat_map(fn [_head | tails] -\u003e tails end)\n```\n\n## Libs \u003ca name = \"libs\"\u003e\u003c/a\u003e\n\n- https://github.com/phoenixframework/phoenix\n- https://github.com/rrrene/credo\n- https://github.com/avdi/dotenv_elixir\n- https://github.com/elixir-plug/plug\n- https://github.com/riverrun/pbkdf2_elixir\n- https://github.com/elixir-plug/plug\n- https://github.com/parroty/excoveralls\n- https://github.com/thoughtbot/ex_machina\n- https://github.com/teamon/tesla\n- https://github.com/PSPDFKit-labs/bypass\n- https://github.com/dashbitco/mox\n- https://github.com/ueberauth/guardian\n\n## Docs \u003ca name = \"docs\"\u003e\u003c/a\u003e\n\n- https://elixir-lang.org/crash-course.html\n- https://elixir-lang.org/getting-started/sigils.html\n- https://elixir-lang.org/getting-started/mix-otp/genserver.html\n- https://hexdocs.pm/elixir/master/typespecs.html\n- https://hexdocs.pm/elixir/master/GenServer.html\n- https://hexdocs.pm/elixir/master/Supervisor.html\n- https://hexdocs.pm/elixir/System.html#cmd/3\n- https://hexdocs.pm/phoenix/installation.html#content\n- https://github.com/inotify-tools/inotify-tools/wiki\n- https://hexdocs.pm/phoenix/deployment.html\n- https://hexdocs.pm/plug/readme.html\n- https://hexdocs.pm/ecto/Ecto.Changeset.html\n- https://hexdocs.pm/ecto/Ecto.Schema.html\n- https://hexdocs.pm/ecto/Ecto.Repo.html#c:stream/2\n- https://hexdocs.pm/pbkdf2_elixir/Pbkdf2.html\n- https://hexdocs.pm/plug/readme.html\n- https://hexdocs.pm/iex/master/IEx.html#pry/0\n- https://hexdocs.pm/ecto/2.2.11/associations.html#content\n- https://hexdocs.pm/tesla/readme.html\n- https://hexdocs.pm/bypass/Bypass.html\n- https://hexdocs.pm/mox/Mox.html\n\n### CI\n\n- https://github.com/actions\n- https://github.com/actions/starter-workflows\n- https://github.com/actions/starter-workflows/blob/fc65e636f2a8e8dcc0048090ca715cd6b5d76e40/ci/elixir.yml\n- https://github.com/mijailr/actions_sample/blob/master/.github/workflows/elixir.yml\n- https://docs.github.com/en/actions/learn-github-actions/migrating-from-gitlab-cicd-to-github-actions#databases-and-service-containers\n- https://docs.github.com/en/actions/guides\n- https://docs.github.com/en/actions/managing-workflow-runs\n- https://docs.github.com/en/actions/learn-github-actions\n- https://docs.github.com/en/actions\n- https://docs.codecov.io/docs\n\n### Deploy\n\n- https://hexdocs.pm/mix/master/Mix.Tasks.Release.html\n- https://elixir-lang.org/getting-started/mix-otp/config-and-releases.html#releases\n- https://gigalixir.readthedocs.io/en/latest/getting-started-guide.html\n- https://gigalixir.readthedocs.io/en/latest/modify-app/releases.html#modifying-existing-app-with-elixir-releases\n- https://gigalixir.readthedocs.io/en/latest/tiers-pricing.html\n- https://gigalixir.readthedocs.io/en/latest/deploy.html?highlight=staging#how-to-set-up-a-staging-environment\n- https://gigalixir.readthedocs.io/en/latest/database.html?highlight=seeds#how-to-run-seeds\n- https://github.com/marketplace/actions/gigalixir-action\n\n## Resources \u003ca name = \"resources\"\u003e\u003c/a\u003e\n\n- https://stackoverflow.com/questions/201323/how-to-validate-an-email-address-using-a-regular-expression\n- https://stackoverflow.com/questions/31990134/how-to-convert-map-keys-from-strings-to-atoms-in-elixir\n- https://stackoverflow.com/questions/16506351/why-use-a-callback-instead-of-a-normal-function-call\n- https://stackoverflow.com/questions/9560815/how-to-get-erlangs-release-version-number-from-a-shell\n- https://stackoverflow.com/questions/22594988/run-shell-commands-in-elixir\n- https://www.tutorialspoint.com/elixir/elixir_lists_and_tuples.htm\n- https://elixirforum.com/c/phoenix-forum\n- https://www.formget.com/regular-expression-for-email/\n- https://github.com/parroty/excoveralls/blob/master/.github/workflows/tests.yml\n- https://medium.com/@diamondgfx/debugging-phoenix-with-iex-pry-5417256e1d11\n- https://elixirschool.com/en/lessons/ecto/associations/\n- https://viacep.com.br/\n- https://inquisitivedeveloper.com/lwm-elixir-18/\n- https://www.bestrandoms.com/random-address-in-br\n- https://dashbit.co/blog/mocks-and-explicit-contracts\n- https://cloudless.studio/model-callbacks-in-phoenix-ecto-and-rails\n- https://jwt.io/\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flibrity%2Fignite_rockelivery","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flibrity%2Fignite_rockelivery","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flibrity%2Fignite_rockelivery/lists"}