{"id":19483533,"url":"https://github.com/librity/ignite_dexlivery","last_synced_at":"2026-06-12T06:02:02.841Z","repository":{"id":99703838,"uuid":"348059916","full_name":"librity/ignite_dexlivery","owner":"librity","description":"Rocket Seat - Ignite - Elixir - A food delivery manager w/ Structs and Agents.","archived":false,"fork":false,"pushed_at":"2022-02-25T12:07:06.000Z","size":39,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-02-25T17:46:13.424Z","etag":null,"topics":["demo-app","elixir","exlivery","rocketseat-ignite"],"latest_commit_sha":null,"homepage":"","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-15T17:18:44.000Z","updated_at":"2022-02-25T12:07:10.000Z","dependencies_parsed_at":"2023-05-24T00:30:56.187Z","dependency_job_id":null,"html_url":"https://github.com/librity/ignite_dexlivery","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/librity/ignite_dexlivery","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/librity%2Fignite_dexlivery","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/librity%2Fignite_dexlivery/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/librity%2Fignite_dexlivery/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/librity%2Fignite_dexlivery/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/librity","download_url":"https://codeload.github.com/librity/ignite_dexlivery/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/librity%2Fignite_dexlivery/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34231212,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-12T02:00:06.859Z","response_time":109,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["demo-app","elixir","exlivery","rocketseat-ignite"],"created_at":"2024-11-10T20:15:28.079Z","updated_at":"2026-06-12T06:02:02.825Z","avatar_url":"https://github.com/librity.png","language":"Elixir","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Dexlivery\n\n## Table of Contents\n\n- [About](#about)\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 demo Elixir program that uses `Structs` as `Data Transfer Objects`, and `Agents` to persist\nstate between precesses.\n\n## Bash Commands \u003ca name = \"bash_commands\"\u003e\u003c/a\u003e\n\n```bash\n# Create new Elixir project\n$ mix new project_name\n# Intall dependencies\n$ mix deps.get\n# Generate linter config\n$ mix credo gen.config\n# Run linter\n$ mix credo --strict\n# Start your project as an Interactive Elixir session\n$ iex -S mix\n# Run console on test environment\n$ MIX_ENV=test iex -S mix\n# Run tests\n$ mix test\n```\n\n## Elixir Commands \u003ca name = \"elixir_commands\"\u003e\u003c/a\u003e\n\nStructs (named maps that belong to a module):\n\n```elixir\n\u003e %Dexlivery.Users.User{}\n%Dexlivery.Users.User{email: nil, name: nil, cpf: nil, age: nil}\n\u003e alias Dexlivery.Users.User\n\u003e %User{}\n%Dexlivery.Users.User{email: nil, name: nil, cpf: nil, age: nil}\n\u003e huey = %User{email: \"hueylewis@andthenews.com\", name: \"Huey Lewis\"}\n%Dexlivery.Users.User{\n  age: nil,\n  cpf: nil,\n  email: \"hueylewis@andthenews.com\",\n  name: \"Huey Lewis\"\n}\n\u003e Map.put(huey, :age, 70)\n%Dexlivery.Users.User{\n  age: 70,\n  cpf: nil,\n  email: \"hueylewis@andthenews.com\",\n  name: \"Huey Lewis\"\n}\n\u003e %{huey | cpf: \"1234567\"}\n%Dexlivery.Users.User{\n  age: nil,\n  cpf: \"1234567\",\n  email: \"hueylewis@andthenews.com\",\n  name: \"Huey Lewis\"\n}\n\u003e %{huey | ssn: \"1234567\"}\n** (KeyError) key :ssn not found in: %Dexlivery.Users.User{age: nil, cpf: nil, email: \"hueylewis@andthenews.com\", name: \"Huey Lewis\"}\n\u003e %User{name: username} = huey\n\u003e username\n\"Huey Lewis\"\n```\n\nDecimal lib (to accurately deal with money):\n\n```elixir\n\u003e Decimal.cast(\"42.42\")\n{:ok, #Decimal\u003c42.42\u003e}\n\u003e Decimal.cast(42.42)\n{:ok, #Decimal\u003c42.42\u003e}\n\u003e Decimal.new(\"42.42\")\n#Decimal\u003c42.42\u003e\n\u003e Decimal.new(42.42)\n** (FunctionClauseError) no function clause matching in Decimal.new/1\n```\n\nCreating an Order:\n\n```elixir\n\u003e {:ok, item1} = Dexlivery.Orders.Item.build(40.42, 1, \"Penne Arrabiata\", :italian, \"Spicy, good cold.\")\n\u003e {:ok, item2} = Dexlivery.Orders.Item.build(22.3, 2, \"Cheese Pizza\", :pizza, \"Tasty\")\n\u003e {:ok, user} = Dexlivery.Users.User.build(\"Tony Soprano\", \"tony@jerseyoutfit.org\", \"14 Aspen Drive, North Caldwell\", \"123-45-6789\", 34)\n\u003e Dexlivery.Orders.Order.build(user, [item1, item2])\n{:ok,\n %Dexlivery.Orders.Order{\n   delivery_address: \"14 Aspen Drive, North Caldwell\",\n   items: [\n     %Dexlivery.Orders.Item{\n       category: :italian,\n       description: \"Spicy, good cold.\",\n       name: \"Penne Arrabiata\",\n       quantity: 1,\n       unit_price: #Decimal\u003c40.42\u003e\n     },\n     %Dexlivery.Orders.Item{\n       category: :pizza,\n       description: \"Tasty\",\n       name: \"Cheese Pizza\",\n       quantity: 2,\n       unit_price: #Decimal\u003c22.3\u003e\n     }\n   ],\n   total_price: #Decimal\u003c85.02\u003e,\n   user_cpf: \"123-45-6789\"\n }}\n\u003e Dexlivery.Orders.Order.build(\"bad\", [item1, item2])\n{:error, \"Invalid parameters.\"}\n\u003e Dexlivery.Orders.Order.build(user, \"bad\")\n{:error, \"Invalid parameters.\"}\n```\n\nExMachina Lib (like Factory Bot):\n\n```elixir\n\u003e ExMachina.sequence(:email, \u0026\"email-#{\u00261}@example.com\")\n\"email-0@example.com\"\n\u003e ExMachina.sequence(:role, [\"admin\", \"user\", \"other\"])\n\"admin\"\n```\n\nAgents (processes that persist data):\n\n```elixir\n\u003e {:ok, agent} = Agent.start_link(fn -\u003e %{} end)\n{:ok, #PID\u003c0.215.0\u003e}\n\u003e Process.alive?(agent)\ntrue\n\u003e Agent.update(agent, fn previous_state -\u003e Map.put(previous_state, :money, \"Good\") end)\n:ok\n\u003e Agent.get(agent, fn previous_state -\u003e previous_state end)\n%{money: \"Good\"}\n\u003e Agent.update(agent, fn previous_state -\u003e Map.put(previous_state, :foo, \"BAR\") end)\n:ok\n\u003e Agent.get(agent, fn previous_state -\u003e previous_state end)\n%{foo: \"BAR\", money: \"Good\"}\n```\n\nUser Agent:\n\n```elixir\n\u003e Dexlivery.start_agents()\n{:ok, #PID\u003c0.264.0\u003e}\n\u003e user_params = %{\n    name: \"Tony Soprano\",\n    email: \"tony@jerseyoutfit.org\",\n    address: \"14 Aspen Drive, North Caldwell\",\n    cpf: \"123-45-6789\",\n    age: 34\n  }\n\u003e Dexlivery.create_or_update_user(user_params)\n:ok\n\u003e Dexlivery.create_or_update_user(%{})\n** (FunctionClauseError) no function clause matching in Dexlivery.Users.CreateOrUpdate.call/1\n\u003e Dexlivery.get_users\n%{\n  \"123-45-6789\" =\u003e %Dexlivery.Users.User{\n    address: \"14 Aspen Drive, North Caldwell\",\n    age: 34,\n    cpf: \"123-45-6789\",\n    email: \"tony@jerseyoutfit.org\",\n    name: \"Tony Soprano\"\n  }\n}\n```\n\nElixir UUID lib:\n\n```elixir\n\u003e UUID.uuid4()\n\"dfe79f96-ddbf-4bdc-9ed9-e6b869e9d64e\"\n```\n\nOrders Agent:\n\n```elixir\n\u003e Dexlivery.start_agents()\n\u003e user_params = Dexlivery.Factory.build(:user)\n\u003e Dexlivery.create_or_update_user(user_params)\n\u003e item = %{\n    category: :italian,\n    description: \"Spicy, good cold.\",\n    name: \"Penne Arrabiata\",\n    quantity: 1,\n    unit_price: 40.42\n  }\n\u003e {:ok, order_id} = Dexlivery.create_order(%{user_cpf: \"123-45-6789\", items: [item]})\n{:ok, \"ae6b8960-a972-487b-9900-8f3c5b48a2f2\"}\n\u003e Dexlivery.update_order(%{user_cpf: \"123-45-6789\", items: [item]}, order_id)\n{:ok, \"ae6b8960-a972-487b-9900-8f3c5b48a2f2\"}\n\u003e Dexlivery.get_orders\n%{\n  \"ae6b8960-a972-487b-9900-8f3c5b48a2f2\" =\u003e %Dexlivery.Orders.Order{\n    delivery_address: \"14 Aspen Drive, North Caldwell\",\n    items: [\n      %Dexlivery.Orders.Item{\n        category: :italian,\n        description: \"Spicy, good cold.\",\n        name: \"Penne Arrabiata\",\n        quantity: 1,\n        unit_price: #Decimal\u003c40.42\u003e\n      }\n    ],\n    total_price: #Decimal\u003c40.42\u003e,\n    user_cpf: \"123-45-6789\"\n  }\n}\n```\n\nOrders Report:\n\n```elixir\n\u003e Dexlivery.start_agents()\n\u003e user_params = Dexlivery.Factory.build(:user)\n\u003e Dexlivery.create_or_update_user(user_params)\n\u003e item1 = Dexlivery.Factory.build(:italian_item_params)\n\u003e item2 = Dexlivery.Factory.build(:pizza_item_params)\n\u003e Dexlivery.create_order(%{user_cpf: \"123-45-6789\", items: [item1]})\n\u003e Dexlivery.create_order(%{user_cpf: \"123-45-6789\", items: [item2]})\n\u003e Dexlivery.create_order(%{user_cpf: \"123-45-6789\", items: [item1, item2]})\n\u003e Dexlivery.Orders.Report.generate()\n[\"123-45-6789,pizza,2,22.3,44.6\",\n \"123-45-6789,italian,1,40.42pizza,2,22.3,85.02\",\n \"123-45-6789,italian,1,40.42,40.42\"]\n```\n\n## Libs \u003ca name = \"libs\"\u003e\u003c/a\u003e\n\n- https://github.com/rrrene/credo\n- https://github.com/ericmj/decimal\n- https://github.com/thoughtbot/ex_machina\n- https://github.com/zyro/elixir-uuid\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/mix-otp/agent.html\n- https://github.com/christopheradams/elixir_style_guide#modules\n- https://hexdocs.pm/decimal/readme.html\n- https://hexdocs.pm/ex_machina/readme.html\n\n## Resources \u003ca name = \"resources\"\u003e\u003c/a\u003e\n\n- https://marketplace.visualstudio.com/items?itemName=pantajoe.vscode-elixir-credo\n- https://www.tutorialspoint.com/elixir/elixir_structs.htm\n- https://www.tutorialspoint.com/elixir/elixir_lists_and_tuples.htm\n- https://inquisitivedeveloper.com/lwm-elixir-25/\n- https://stackoverflow.com/questions/36330010/elixir-how-to-deal-with-optional-default-parameters-in-functions-and-nil-valu\n- https://stackoverflow.com/questions/36512627/elixir-convert-struct-to-map\n- https://stackoverflow.com/questions/38778054/how-to-generate-a-random-number-in-elixir\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flibrity%2Fignite_dexlivery","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flibrity%2Fignite_dexlivery","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flibrity%2Fignite_dexlivery/lists"}