Skip to content

[WIP] Chore/revive repo #7

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .tool-versions
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
elixir 1.16.1-otp-26
erlang 26.2.1
elixir 1.18.1-otp-27
erlang 27.2
4 changes: 2 additions & 2 deletions lib/mix/tasks/all_tasks.ex
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ defmodule Mix.Tasks.AllTasks do

@requirements [
"compile --force",
"format",
"spell_check"
"format"
# "spell_check"
]

alias Utils.Notebooks.Tasks
Expand Down
24 changes: 11 additions & 13 deletions livebooks/day1.livemd
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ Today we will learn basics of Elixir language covering all the topics from the A
Each livebook consists of reading part with examples for the given topic and later it challenges you with the exercise to do on your own.
Each exercise has some basic story written to help you feel more engaged in the task. Exercsises are divided in to smaller parts and for all of that we have prepared a bunch of tests to check your solution.


Today, we'll dig into the fundamentals of the Elixir language, encompassing all the topics outlined in the agenda.
Each livebook includes a reading segment with examples relevant to the topic at hand, followed by exercises designed to challenge your understanding and application of the concepts.

Expand All @@ -15,15 +14,14 @@ Furthermore, the exercises are broken down into manageable segments, and to ensu

### Agenda

- [Introduction](presentation/001-introduction.livemd)
- [Booleans](presentation/002-booleans.livemd)
- [Integer & FLoats](presentation/003-integer_floats.livemd)
- [Lists](presentation/004-lists.livemd)
- [Atoms & Cond](presentation/005-atoms_cond.livemd)
- [Guards](presentation/006-guards.livemd)
- [Pattern matching](presentation/007-tuples_pattern_matching.livemd)
- [Recursion](presentation/008-recursion.livemd)
- [Keyword lists & maps](presentation/009-keyword_list_maps.livemd)
- [Struct & Pipe operator](presentation/010-structs_pipe.livemd)
- [Enum](presentation/011-enum.livemd)

* [Introduction](presentation/001-introduction.livemd)
* [Booleans](presentation/002-booleans.livemd)
* [Integer & FLoats](presentation/003-integer_floats.livemd)
* [Lists](presentation/004-lists.livemd)
* [Atoms & Cond](presentation/005-atoms_cond.livemd)
* [Guards](presentation/006-guards.livemd)
* [Pattern matching](presentation/007-tuples_pattern_matching.livemd)
* [Recursion](presentation/008-recursion.livemd)
* [Keyword lists & maps](presentation/009-keyword_list_maps.livemd)
* [Struct & Pipe operator](presentation/010-structs_pipe.livemd)
* [Enum](presentation/011-enum.livemd)
36 changes: 18 additions & 18 deletions livebooks/day2.livemd
Original file line number Diff line number Diff line change
Expand Up @@ -7,33 +7,33 @@ Today our schedule is to dig into Elixir project tooling, Phoenix, and Ecto. Mor

### This course assumptions

- Target group - people who have previous programming experience in different languages. We won't cover fundamentals like what is **API** or **DB** or how to use them. But if you'd like us to cover something additional let us know.
- Practical exercises with explanation of most important theoretical foundations.
- Aims to consolidate basic Elixir knowledge from Day 1.
- You will work with **git** repo to commit your progress. That will allow you to come back to the course later, revise knowledge and learn further things based on existing exercises.
- Interrupt us as much as you need, don't be afraid to ask even stupid questions, and don't give up, remember:
* Target group - people who have previous programming experience in different languages. We won't cover fundamentals like what is **API** or **DB** or how to use them. But if you'd like us to cover something additional let us know.
* Practical exercises with explanation of most important theoretical foundations.
* Aims to consolidate basic Elixir knowledge from Day 1.
* You will work with **git** repo to commit your progress. That will allow you to come back to the course later, revise knowledge and learn further things based on existing exercises.
* Interrupt us as much as you need, don't be afraid to ask even stupid questions, and don't give up, remember:

> The master has failed more times than the beginner has even tried.

We will start with [Environment setup](./presentation/environment_setup.livemd). Please ensure you have completed before starting the actual course.

### Agenda

- [Setting up Mix project](./presentation/mix_introduction.livemd)
- [Mix deeper dive](./presentation/mix_deeper_dive.livemd)
- [Phoenix overview](./presentation/phoenix_overview.livemd)
- [Phoenix app setup](./exercise/phoenix_app_setup.livemd)
- [Ecto introduction](./presentation/ecto_introduction.livemd)
- [Ecto in action](./exercise/ecto_in_action.livemd)
* [Setting up Mix project](./presentation/mix_introduction.livemd)
* [Mix deeper dive](./presentation/mix_deeper_dive.livemd)
* [Phoenix overview](./presentation/phoenix_overview.livemd)
* [Phoenix app setup](./exercise/phoenix_app_setup.livemd)
* [Ecto introduction](./presentation/ecto_introduction.livemd)
* [Ecto in action](./exercise/ecto_in_action.livemd)

### Extras

We might cover the following topics if there is enough time or some of you would like to discuss later

- [Advanced HTTP API](./presentation/phoenix_http_api.livemd)
- [Integrating third-party HTTP API with Tesla](./presentation/integrating_third_party_http_api_with_tesla.livemd)
- Simple UI with LiveView and generators
- Oban introduction and async work
- Reactive UI with LV and PubSub
- Advanced domain models - implementing a reservation system
- Metaprogramming with Elixir (macro, AST)
* [Advanced HTTP API](./presentation/phoenix_http_api.livemd)
* [Integrating third-party HTTP API with Tesla](./presentation/integrating_third_party_http_api_with_tesla.livemd)
* Simple UI with LiveView and generators
* Oban introduction and async work
* Reactive UI with LV and PubSub
* Advanced domain models - implementing a reservation system
* Metaprogramming with Elixir (macro, AST)
11 changes: 11 additions & 0 deletions livebooks/docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
services:
postgres:
image: postgres:bullseye
#image: postgres:17.2
ports:
- "127.0.0.1:5432:5432"
environment:
- POSTGRES_DB=postgres
- POSTGRES_USER=postgres
- POSTGRES_PASSWORD=postgres

37 changes: 19 additions & 18 deletions livebooks/exercise/phoenix_app_setup.livemd
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@ Mix.install([

## Review Questions

- How does router, controller and Plug interact to fulfill the job?
- How to add additional endpoint to web app?
- How to expose list of JSONs in controller?
- How to add resource creation to the controller?
- How Plug can be leveraged to implement basic authentication?
- Can I implement pagination?
- Can I plan whole flow of typical CRUD scenario? (router + controller + context + DB)
* How does router, controller and Plug interact to fulfill the job?
* How to add additional endpoint to web app?
* How to expose list of JSONs in controller?
* How to add resource creation to the controller?
* How Plug can be leveraged to implement basic authentication?
* Can I implement pagination?
* Can I plan whole flow of typical CRUD scenario? (router + controller + context + DB)

## Bootstrap Phoenix

Expand All @@ -38,6 +38,7 @@ mix phx.new pokemon --umbrella --binary-id --database postgres
and tap `y` when prompted. You should have:

<!-- livebook:{"break_markdown":true} -->

<!-- livebook:{"force_markdown":true} -->

```elixir
Expand Down Expand Up @@ -195,17 +196,17 @@ More reading about Phoenix Contexts available [here](https://hexdocs.pm/phoenix/

Enough talking, let's do some stuff! Remember the `Pokedex.random_pack/1` function? Our job now is expose it via API in Phoenix. Requirements break down:

- add context `Pokemon.Pokedex`
- add `Pokemon.Pokedex.random_pack/1` function
- it returns 5 random pokemons
- it accepts 1 argument called `size`, which has default value of `5`
- list contains `%Pokemon.Pokedex.Pokemon{name: "name"}` structs
- you can generate pokemon name as you want
- no duplicates
- expose endpoint `/api/pokemons/random`
- it accepts query param `size`, like `/api/pokemons/random?size=10`, which is optional
- `size` can't be greater than 20 or negative
- it renders response as follows:
* add context `Pokemon.Pokedex`
* add `Pokemon.Pokedex.random_pack/1` function
* it returns 5 random pokemons
* it accepts 1 argument called `size`, which has default value of `5`
* list contains `%Pokemon.Pokedex.Pokemon{name: "name"}` structs
* you can generate pokemon name as you want
* no duplicates
* expose endpoint `/api/pokemons/random`
* it accepts query param `size`, like `/api/pokemons/random?size=10`, which is optional
* `size` can't be greater than 20 or negative
* it renders response as follows:

```json
"data": [
Expand Down
2 changes: 1 addition & 1 deletion livebooks/presentation/environment_setup.livemd
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ You can download it here: https://code.visualstudio.com/download

After installation, please add extensions:

- [ElixirLS: Elixir support and debugger](https://marketplace.visualstudio.com/items?itemName=JakeBecker.elixir-ls)
* [ElixirLS: Elixir support and debugger](https://marketplace.visualstudio.com/items?itemName=JakeBecker.elixir-ls)

### Prepare projects directory

Expand Down
39 changes: 20 additions & 19 deletions livebooks/presentation/mix_deeper_dive.livemd
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ Mix.install([

Upon completing this lesson, a student should be able to answer the following questions.

- What is mix umbrella application and how to create it?
- How does mix manage umbrella dependencies?
- How to configure apps?
- How to cover simple module with unit-tests?
* What is mix umbrella application and how to create it?
* How does mix manage umbrella dependencies?
* How to configure apps?
* How to cover simple module with unit-tests?

## Umbrella apps

Expand Down Expand Up @@ -54,6 +54,7 @@ mix new pokemon_umbrella --umbrella
```

<!-- livebook:{"break_markdown":true} -->

<!-- livebook:{"force_markdown":true} -->

```elixir
Expand Down Expand Up @@ -188,10 +189,10 @@ It's your turn, make it happen in your `pokemon_umbrella` project.
Now we are going to implement its first feature, returning a random pack of pokemons.
Specification outline for `Pokedex.random_pack/1`:

- it returns list of structs `%Pokedex.Pokemon{name: "name"}`
- it accepts 1 argument called `size`, which has default value of `5`
- it returns unique pokemons (no duplicates)
- it uses `PokemonProfile.Name.random/0` to generate names
* it returns list of structs `%Pokedex.Pokemon{name: "name"}`
* it accepts 1 argument called `size`, which has default value of `5`
* it returns unique pokemons (no duplicates)
* it uses `PokemonProfile.Name.random/0` to generate names

You can start as follows:

Expand Down Expand Up @@ -251,11 +252,11 @@ flowchart LR

Umbrella apps can be used for the following use cases:

- Multiple teams working on modular monolith application.
- Logical modularization for bigger apps
- Separating frontend from backend
- Flexible deployments scenarios
- Phoenix app: web + domain
* Multiple teams working on modular monolith application.
* Logical modularization for bigger apps
* Separating frontend from backend
* Flexible deployments scenarios
* Phoenix app: web + domain

In the repository that implements precard service v2, we also employed umbrella project pattern. It looks like this:

Expand Down Expand Up @@ -407,18 +408,18 @@ Now the challenge for you:
1. Write another implementation of `PokemonProfile.Greeter` -> `PokemonProfile.Greeter.Pirate`, that greets pokemons with "Ahoy pokemon_name !!!"
2. Pick "adapter" on the fly, based on module 3 operation on the number of letters in pokemon name as follows:

- "Blastoise" -> 9 letters -> mod 3 -> 0 -> `PokemonProfile.Greeter.Default`
- "Pikachu" -> 7 letters -> mod 3 -> 1 -> `PokemonProfile.Greeter.Formal`
- "Sewaddle" -> 8 letters -> mod 3 -> 2 -> `PokemonProfile.Greeter.Pirate`
* "Blastoise" -> 9 letters -> mod 3 -> 0 -> `PokemonProfile.Greeter.Default`
* "Pikachu" -> 7 letters -> mod 3 -> 1 -> `PokemonProfile.Greeter.Formal`
* "Sewaddle" -> 8 letters -> mod 3 -> 2 -> `PokemonProfile.Greeter.Pirate`

3. (more difficult) - write unit tests for that
1. (more difficult) - write unit tests for that

## Further Reading

For more on [Mix](https://hexdocs.pm/mix/Mix.html), consider reading the following.

- [elixir-lang: Intro to Mix](https://elixir-lang.org/getting-started/mix-otp/introduction-to-mix.html)
- [HexDocs: Mix](https://hexdocs.pm/mix/Mix.html#content)
* [elixir-lang: Intro to Mix](https://elixir-lang.org/getting-started/mix-otp/introduction-to-mix.html)
* [HexDocs: Mix](https://hexdocs.pm/mix/Mix.html#content)

## Commit Your Progress

Expand Down
30 changes: 14 additions & 16 deletions livebooks/presentation/mix_introduction.livemd
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@ Mix.install([

Upon completing this lesson, a student should be able to answer the following questions.

- What is the purpose of Mix?
- Where should our application go inside of a mix project?
- How do we compile a mix project and explore it using the IEx shell?
- How do we run tests?
- How do we add and manage dependencies in mix project?
- What is Elixir formatter and how to use it?
* What is the purpose of Mix?
* Where should our application go inside of a mix project?
* How do we compile a mix project and explore it using the IEx shell?
* How do we run tests?
* How do we add and manage dependencies in mix project?
* What is Elixir formatter and how to use it?

## Mix

Expand Down Expand Up @@ -425,8 +425,8 @@ The locally installed dependency may not exactly match the version requirement,

The `~>` symbol you see in dependencies means it will never go above its upper bound.

- `~> 2.1` would allow any version below `3.0.0` and above or equal to `2.1.0`.
- `~> 2.1.2` would allow any version below `2.2.0` and above or equal to `2.1.2`.
* `~> 2.1` would allow any version below `3.0.0` and above or equal to `2.1.0`.
* `~> 2.1.2` would allow any version below `2.2.0` and above or equal to `2.1.2`.

The [Version documentation](https://hexdocs.pm/elixir/Version.html) goes into further depth.

Expand Down Expand Up @@ -465,10 +465,10 @@ Most projects include a README.md file which contains basic information about th

There is no universal README structure however it's common to include:

- The repository name.
- The project purpose.
- Setup instructions.
- Collaborators on the project.
* The repository name.
* The project purpose.
* Setup instructions.
* Collaborators on the project.

GitHub pages display the README on the front of the repository page for the project.

Expand All @@ -483,8 +483,6 @@ Mix projects can run in different environments. The default environment is your

Run your `pokemon` project in the IEx shell and call `Mix.env()` to see that `:dev` is the current environment.

<!-- livebook:{"force_markdown":true} -->

```bash
iex -S mix
iex> Mix.env()
Expand All @@ -500,8 +498,8 @@ For example, if you had SMS (text) notifications in your project, you might want

For more on [Mix](https://hexdocs.pm/mix/Mix.html), consider reading the following.

- [elixir-lang: Intro to Mix](https://elixir-lang.org/getting-started/mix-otp/introduction-to-mix.html)
- [HexDocs: Mix](https://hexdocs.pm/mix/Mix.html#content)
* [elixir-lang: Intro to Mix](https://elixir-lang.org/getting-started/mix-otp/introduction-to-mix.html)
* [HexDocs: Mix](https://hexdocs.pm/mix/Mix.html#content)

## Commit Your Progress

Expand Down
14 changes: 7 additions & 7 deletions livebooks/presentation/phoenix_http_api.livemd
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@ Mix.install([

## Review Questions

- How does router, controller and Plug interact to fulfill the job?
- How to add additional endpoint to web app?
- How to expose list of JSONs in controller?
- How to add resource creation to the controller?
- How Plug can be leveraged to implement basic authentication?
- Can I implement pagination?
- Can I plan whole flow of typical CRUD scenario? (router + controller + context + DB)
* How does router, controller and Plug interact to fulfill the job?
* How to add additional endpoint to web app?
* How to expose list of JSONs in controller?
* How to add resource creation to the controller?
* How Plug can be leveraged to implement basic authentication?
* Can I implement pagination?
* Can I plan whole flow of typical CRUD scenario? (router + controller + context + DB)

## Overview

Expand Down
Loading