Slide 1

Slide 1 text

Getting Started with PHOENIX ElixirConf UY 2022

Slide 2

Slide 2 text

W ORKSHOP Montevideo, UY

Slide 3

Slide 3 text

W ORKSHOP

Slide 4

Slide 4 text

railsgirls.com.br

Slide 5

Slide 5 text

Elixir + Ruby

Slide 6

Slide 6 text

No content

Slide 7

Slide 7 text

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

Slide 8

Slide 8 text

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

Slide 9

Slide 9 text

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

Slide 10

Slide 10 text

olá

Slide 11

Slide 11 text

São Paulo / Brazil

Slide 12

Slide 12 text

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

Slide 13

Slide 13 text

No content

Slide 14

Slide 14 text

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

Slide 15

Slide 15 text

The RealReal is one of the ElixirConf UY's sponsors

Slide 16

Slide 16 text

No content

Slide 17

Slide 17 text

No content

Slide 18

Slide 18 text

therealreal.com/careers including Fully Remote opportunities

Slide 19

Slide 19 text

No content

Slide 20

Slide 20 text

DAY 1: WORKSHOP

Slide 21

Slide 21 text

No content

Slide 22

Slide 22 text

No content

Slide 23

Slide 23 text

Goal: to build a web app with Phoenix

Slide 24

Slide 24 text

No content

Slide 25

Slide 25 text

WHAT IS A WEB FRAMEWORK?

Slide 26

Slide 26 text

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

Slide 27

Slide 27 text

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

Slide 28

Slide 28 text

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

Slide 29

Slide 29 text

No content

Slide 30

Slide 30 text

WHAT IS PHOENIX?

Slide 31

Slide 31 text

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

Slide 32

Slide 32 text

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

Slide 33

Slide 33 text

ELIXIR

Slide 34

Slide 34 text

Elixir + Erlang VM Highly Scalable and Concurrent Applications

Slide 35

Slide 35 text

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

Slide 36

Slide 36 text

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

Slide 37

Slide 37 text

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

Slide 38

Slide 38 text

From 150 servers to 5!

Slide 39

Slide 39 text

Productivity and Performance for Developers

Slide 40

Slide 40 text

Convention over Configuration

Slide 41

Slide 41 text

Concurrency in all environments, including tests and development

Slide 42

Slide 42 text

With new tools to build modern web app

Slide 43

Slide 43 text

Real Time Web

Slide 44

Slide 44 text

No content

Slide 45

Slide 45 text

No content

Slide 46

Slide 46 text

EXPECTATIONS

Slide 47

Slide 47 text

Introducción a Phoenix

Slide 48

Slide 48 text

our toy program for this workshop

Slide 49

Slide 49 text

No content

Slide 50

Slide 50 text

github.com/elainenaomi/taskify

Slide 51

Slide 51 text

AGENDA

Slide 52

Slide 52 text

➔ 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

Slide 53

Slide 53 text

SETUP

Slide 54

Slide 54 text

elixir -v

Slide 55

Slide 55 text

➔ Elixir 1.14.1 ➔ Erlang 24.3.4.6

Slide 56

Slide 56 text

postgres -V

Slide 57

Slide 57 text

mix archive.install hex phx_new

Slide 58

Slide 58 text

mix phx.new -v

Slide 59

Slide 59 text

TASK #001

Slide 60

Slide 60 text

mix phx.new taskify

Slide 61

Slide 61 text

mix phx.server

Slide 62

Slide 62 text

No content

Slide 63

Slide 63 text

Live Dashboard

Slide 64

Slide 64 text

No content

Slide 65

Slide 65 text

TASK #002

Slide 66

Slide 66 text

page title new path update the content, including logo image

Slide 67

Slide 67 text

No content

Slide 68

Slide 68 text

TASK #003

Slide 69

Slide 69 text

Log in Sign Up

Slide 70

Slide 70 text

No content

Slide 71

Slide 71 text

TASK #004

Slide 72

Slide 72 text

Finally building tasks!

Slide 73

Slide 73 text

logged user

Slide 74

Slide 74 text

No content

Slide 75

Slide 75 text

Ecto != ORM

Slide 76

Slide 76 text

No content

Slide 77

Slide 77 text

TASK #005

Slide 78

Slide 78 text

Nested resource: tasks/:task_id/sub_tasks logged user

Slide 79

Slide 79 text

No content

Slide 80

Slide 80 text

TASK #006

Slide 81

Slide 81 text

No content

Slide 82

Slide 82 text

sub-tasks status on task list

Slide 83

Slide 83 text

TASK #007

Slide 84

Slide 84 text

No content

Slide 85

Slide 85 text

Deploying on Fly.io

Slide 86

Slide 86 text

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/

Slide 87

Slide 87 text

taskify.fly.dev

Slide 88

Slide 88 text

Deploying with Releases

Slide 89

Slide 89 text

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

Slide 90

Slide 90 text

mix phx.gen.release --docker

Slide 91

Slide 91 text

build time vs runtime

Slide 92

Slide 92 text

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

Slide 93

Slide 93 text

No Support to Hot Code Upgrades

Slide 94

Slide 94 text

"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

Slide 95

Slide 95 text

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

Slide 96

Slide 96 text

WRAPPING UP

Slide 97

Slide 97 text

➔ 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

Slide 98

Slide 98 text

in 2 hours!

Slide 99

Slide 99 text

REFERENCES

Slide 100

Slide 100 text

No content

Slide 101

Slide 101 text

https://elixirforum.com/

Slide 102

Slide 102 text

No content

Slide 103

Slide 103 text

ADDITIONAL REFERENCES

Slide 104

Slide 104 text

No content

Slide 105

Slide 105 text

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

Slide 106

Slide 106 text

https://ulisses.dev/

Slide 107

Slide 107 text

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

Slide 108

Slide 108 text

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

Slide 109

Slide 109 text

No content

Slide 110

Slide 110 text

No content

Slide 111

Slide 111 text

github.com/podium/elixir-secure-coding

Slide 112

Slide 112 text

github.com/podium/elixir-secure-coding

Slide 113

Slide 113 text

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

Slide 114

Slide 114 text

No content

Slide 115

Slide 115 text

https://pesquisecomelixir.com.br/

Slide 116

Slide 116 text

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

Slide 117

Slide 117 text

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

Slide 118

Slide 118 text

MY CONTRIBUTIONS

Slide 119

Slide 119 text

ELIXIR youtube.com/ElixirLabOrg

Slide 120

Slide 120 text

ELIXIR

Slide 121

Slide 121 text

ELIXIR

Slide 122

Slide 122 text

CARNIVAL EDITION ELIXIR

Slide 123

Slide 123 text

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

Slide 124

Slide 124 text

https://github.com/elainenaomi/taskify

Slide 125

Slide 125 text

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