Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Getting Started With Phoenix - ElixirConf UY

Elaine Naomi
November 11, 2022

Getting Started With Phoenix - ElixirConf UY

Elaine Naomi

November 11, 2022
Tweet

More Decks by Elaine Naomi

Other Decks in Programming

Transcript

  1. Getting Started with
    PHOENIX
    ElixirConf UY 2022

    View full-size slide

  2. W
    ORKSHOP
    Montevideo, UY

    View full-size slide

  3. railsgirls.com.br

    View full-size slide

  4. Elixir + Ruby

    View full-size slide

  5. Lessons Learned from Elixir Learning Paths
    https://www.youtube.com/watch?v=I1jUWz1RP2U
    https://speakerdeck.com/elainenaomi/elixir-conf-eu-lessons-learned-from-elixir-learning-paths

    View full-size slide

  6. Code Smells, Refatoração e Elixir
    https://www.youtube.com/watch?v=3-1PCurON4Q
    https://speakerdeck.com/elainenaomi/elixir-brasil-2020-code-smells-refactoring-e-elixir

    View full-size slide

  7. https://github.com/lucasvegi/Elixir-Code-Smells
    a scientific research about code smells in Elixir

    View full-size slide

  8. São Paulo / Brazil

    View full-size slide

  9. Software Engineer/Developer (since 2008)
    B.Sc. in Computer Engineering
    M.Sc. in Computer Science
    ELAINE NAOMI WATANABE
    twitter.com/elaine_nw
    speakerdeck.com/elainenaomi
    linkedin.com/in/elainenaomi

    View full-size slide

  10. The RealReal - Elixir Adoption Story
    youtube.com/watch?v=sTs_4T1ufLY

    View full-size slide

  11. The RealReal is one of the
    ElixirConf UY's sponsors

    View full-size slide

  12. therealreal.com/careers
    including Fully Remote opportunities

    View full-size slide

  13. DAY 1: WORKSHOP

    View full-size slide

  14. Goal: to build a web app with Phoenix

    View full-size slide

  15. WHAT IS A WEB FRAMEWORK?

    View full-size slide

  16. https://en.wikipedia.org/wiki/Web_framework
    Web Framework
    It is standard way to build and deploy web applications
    Automation of common activities performed in web development
    For example, providing libraries for database access, templating
    frameworks, session management, often focusing on code reuse

    View full-size slide

  17. https://en.wikipedia.org/wiki/Web_framework
    Web Framework
    It is standard way to build and deploy web applications
    Automation of common activities performed in web development
    For example, providing libraries for database access, templating
    frameworks, session management, often focusing on code reuse

    View full-size slide

  18. https://en.wikipedia.org/wiki/Web_framework
    Web Framework
    It is standard way to build and deploy web applications
    Automation of common activities performed in web development
    For example, providing libraries for database access, templating
    frameworks, session management, often focusing on code reuse

    View full-size slide

  19. WHAT IS PHOENIX?

    View full-size slide

  20. Phoenix Framework
    Web framework created in 2014 for Elixir programming language
    Creator: Chris McCord
    Latest version: 1.6.15
    Released date: 2022-10-26

    View full-size slide

  21. Phoenix Framework
    Web framework created in 2014 for Elixir programming language
    Creator: Chris McCord
    Latest version: 1.6.15
    Released date: 2022-10-26

    View full-size slide

  22. Elixir + Erlang VM
    Highly Scalable and Concurrent Applications

    View full-size slide

  23. blog.whatsapp.com/1-million-is-so-2011
    ERLANG
    2 million connections on
    a single node

    View full-size slide

  24. 2 million connections on
    a single node
    phoenixframework.org/blog/the-road-to-2-million-websocket-connections
    ELIXIR

    View full-size slide

  25. https://web.archive.org/web/20181011093614/https://www.techworld.com/apps-wearables/how-elixir-helped-bleacher-re
    port-handle-8x-more-traffic-3653957/

    View full-size slide

  26. From 150 servers to 5!

    View full-size slide

  27. Productivity and Performance
    for Developers

    View full-size slide

  28. Convention over Configuration

    View full-size slide

  29. Concurrency in all environments,
    including tests and development

    View full-size slide

  30. With new tools to build modern web app

    View full-size slide

  31. Real Time Web

    View full-size slide

  32. EXPECTATIONS

    View full-size slide

  33. Introducción a Phoenix

    View full-size slide

  34. our toy program for this workshop

    View full-size slide

  35. github.com/elainenaomi/taskify

    View full-size slide

  36. ➔ Building a landing page
    ➔ Adding the authentication system
    ➔ Creating, reading, updating, deleting user tasks
    ➔ Adding sub-tasks to user tasks
    ➔ Building the task status from sub-tasks
    ➔ Deploying on fly.io

    View full-size slide

  37. ➔ Elixir 1.14.1
    ➔ Erlang 24.3.4.6

    View full-size slide

  38. mix archive.install hex phx_new

    View full-size slide

  39. mix phx.new -v

    View full-size slide

  40. mix phx.new taskify

    View full-size slide

  41. mix phx.server

    View full-size slide

  42. Live Dashboard

    View full-size slide

  43. page title
    new path
    update the content, including logo image

    View full-size slide

  44. Log in
    Sign Up

    View full-size slide

  45. Finally building tasks!

    View full-size slide

  46. Nested resource: tasks/:task_id/sub_tasks
    logged user

    View full-size slide

  47. sub-tasks status on task list

    View full-size slide

  48. Deploying on Fly.io

    View full-size slide

  49. I'm using fly.io for this toy app
    because of the simple setup
    Installing flyctl command
    For example, via homebrew for mac os
    brew install flyctl
    Creating an account
    flyctl auth signup
    Launching the app
    cd taskify
    fly launch
    Stopping the app
    fly scale count 0
    https://fly.io/docs/hands-on/install-flyctl/
    https://fly.io/docs/elixir/getting-started/

    View full-size slide

  50. taskify.fly.dev

    View full-size slide

  51. Deploying with Releases

    View full-size slide

  52. MIX_ENV=prod mix release
    https://hexdocs.pm/mix/1.14.1/Mix.Tasks.Release.html

    View full-size slide

  53. mix phx.gen.release --docker

    View full-size slide

  54. build time vs runtime

    View full-size slide

  55. config/config.exs vs config/runtime.ex
    https://elixir-lang.org/getting-started/mix-otp/config-and-releases.html#configuration

    View full-size slide

  56. No Support to Hot Code Upgrades

    View full-size slide

  57. "Given most teams can use other techniques that are language agnostic
    to upgrade their systems, such as Blue/Green deployments, Canary
    deployments, Rolling deployments, and others, hot upgrades are rarely a
    viable option"
    https://hexdocs.pm/mix/1.14.1/Mix.Tasks.Release.html#module-hot-code-upgrades

    View full-size slide

  58. https://blog.miguelcoba.com/series/deploying-elixir

    View full-size slide

  59. ➔ Introduction to Phoenix Request Life-Cycle
    ➔ Introduction to Phoenix generators
    ➔ Introduction to Ecto: migrations, Ecto schema and validations, Ecto queries
    ➔ Introduction to authentication with mix phx.gen.auth
    ➔ An overview of data integrity :)
    ➔ Deployment with fly.io

    View full-size slide

  60. https://elixirforum.com/

    View full-size slide

  61. ADDITIONAL REFERENCES

    View full-size slide

  62. https://medium.com/very-big-things
    Clarity | Saša Jurić | ElixirConf EU 2021
    https://www.youtube.com/watch?v=6sNmJtoKDCo

    View full-size slide

  63. https://ulisses.dev/

    View full-size slide

  64. Writing extensible functional code - Renan Ranelli
    https://www.youtube.com/watch?v=1HXMUI7tiCQ

    View full-size slide

  65. SOLID Elixir • Georgina McFadyen • GOTO 2018
    https://www.youtube.com/watch?v=rmftOs2BzgU

    View full-size slide

  66. github.com/podium/elixir-secure-coding

    View full-size slide

  67. github.com/podium/elixir-secure-coding

    View full-size slide

  68. !!Con 2019- Tail Call Optimization: The Musical!! by Anjana Vakil & Natalia Margolis
    https://www.youtube.com/watch?v=-PX0BV9hGZY

    View full-size slide

  69. https://pesquisecomelixir.com.br/

    View full-size slide

  70. https://github.com/lucasvegi/Elixir-Code-Smells

    View full-size slide

  71. O Elixir do futuro, com Charlotte Lorelei Oliveira
    https://pt-br.eventials.com/locaweb/o-elixir-do-futuro-com-charlotte-lorelei-oliveira/
    ELIXIR

    View full-size slide

  72. MY CONTRIBUTIONS

    View full-size slide

  73. ELIXIR
    youtube.com/ElixirLabOrg

    View full-size slide

  74. CARNIVAL EDITION
    ELIXIR

    View full-size slide

  75. https://sourcelevel.io/code-review-ebook

    View full-size slide

  76. https://github.com/elainenaomi/taskify

    View full-size slide

  77. speakerdeck.com/elainenaomi
    elainenaomi.dev
    Muito
    obrigada
    illustrations from undraw.co
    translation: muchas gracias

    View full-size slide