Skip to content

Commit ac1367e

Browse files
committed
Improve README
1 parent 7422a26 commit ac1367e

4 files changed

Lines changed: 46 additions & 21 deletions

File tree

README.md

Lines changed: 37 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,44 @@
1-
![Continuous Integration](https://github.com/pedroperrone/listify/workflows/Continuous%20Integration/badge.svg)
2-
31
# Listify
42

5-
To start your Phoenix server:
3+
This repository contains the implementation of a simple shopping list. It has both a UI built with LiveView and a REST API.
4+
5+
## Dependencies
6+
7+
To run the project and its tests, the following dependencies are required:
8+
* Elixir 1.10
9+
* Postgres 11+
10+
11+
## Running the project
12+
13+
To run the project, first export the following environment variables regarding your database configuration:
14+
* `DATABASE_USERNAME` - Defaults to `postgres`
15+
* `DATABASE_PASSWORD` - Defaults to `postgres`
16+
* `DATABASE_NAME` - Defaults to `listify_dev`
17+
* `DATABASE_POOL_SIZE` - Defaults to `10`
18+
19+
Then, navigate to the cloned repository and run the following commands:
20+
```shell
21+
mix deps.get
22+
mix ecto.setup
23+
mix phx.server
24+
```
25+
26+
The project will be available on `localhost:4000`. The list is under the route `/items`.
27+
28+
## Running unit tests
29+
30+
The library used to build unit tests was `ExUnit`. In assistance to it, `ExMachina` was used to build factories.
631

7-
* Setup the project with `mix setup`
8-
* Start Phoenix endpoint with `mix phx.server`
32+
To run the tests, first export the database credentials and name (here the default name changed to `listify_test`) and then use the command `mix test`.
933

10-
Now you can visit [`localhost:4000`](http://localhost:4000) from your browser.
34+
## Static code analysis
1135

12-
Ready to run in production? Please [check our deployment guides](https://hexdocs.pm/phoenix/deployment.html).
36+
Two tools were set in the project: `Credo`, which is focused on code consistency and refactor opportunities, and `Dialyzer`, which is focused on identifying software discrepancies, such as definite type errors, code that has become dead or unreachable because of programming error. To run them, use the commands
37+
```shell
38+
mix credo
39+
mix dialyzer
40+
```
1341

14-
## Learn more
42+
## Architecture
1543

16-
* Official website: https://www.phoenixframework.org/
17-
* Guides: https://hexdocs.pm/phoenix/overview.html
18-
* Docs: https://hexdocs.pm/phoenix
19-
* Forum: https://elixirforum.com/c/phoenix-forum
20-
* Source: https://github.com/phoenixframework/phoenix
44+
In order to avoid code duplication in the full stack application and in the API, the concept of [use cases](http://www.plainionist.net/Implementing-Clean-Architecture-UseCases/) was implemented. The use cases are the intermediate between the business rules and the presenters, which are the controllers and the LiveView modules.

config/dev.exs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@ use Mix.Config
22

33
# Configure your database
44
config :listify, Listify.Repo,
5-
username: "postgres",
6-
password: "postgres",
7-
database: "listify_dev",
5+
username: System.get_env("DATABASE_USERNAME", "postgres"),
6+
password: System.get_env("DATABASE_PASSWORD", "postgres"),
7+
database: System.get_env("DATABASE_NAME", "listify_dev"),
88
hostname: "localhost",
99
show_sensitive_data_on_connection_error: true,
10-
pool_size: 10
10+
pool_size: String.to_integer(System.get_env("DATABASE_POOL_SIZE", "10"))
1111

1212
# For development, we disable any cache and enable
1313
# debugging and code reloading.

config/test.exs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,10 @@ use Mix.Config
66
# to provide built-in test partitioning in CI environment.
77
# Run `mix help test` for more information.
88
config :listify, Listify.Repo,
9-
username: "postgres",
10-
password: "postgres",
11-
database: "listify_test#{System.get_env("MIX_TEST_PARTITION")}",
9+
username: System.get_env("DATABASE_USERNAME", "postgres"),
10+
password: System.get_env("DATABASE_PASSWORD", "postgres"),
11+
database:
12+
System.get_env("DATABASE_NAME", "listify_test#{System.get_env("MIX_TEST_PARTITION")}"),
1213
hostname: "localhost",
1314
pool: Ecto.Adapters.SQL.Sandbox
1415

mix.exs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ defmodule Listify.MixProject do
88
plt_file: {:no_warn, "priv/plts/dialyzer.plt"}
99
],
1010
version: "0.1.0",
11-
elixir: "~> 1.7",
11+
elixir: "~> 1.10",
1212
elixirc_paths: elixirc_paths(Mix.env()),
1313
compilers: [:phoenix, :gettext] ++ Mix.compilers(),
1414
start_permanent: Mix.env() == :prod,

0 commit comments

Comments
 (0)