Skip to content

Commit 0e0335e

Browse files
committed
Improve README
1 parent 7422a26 commit 0e0335e

5 files changed

Lines changed: 47 additions & 20 deletions

File tree

.circleci/config.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ version: 2.1
33
defaults: &defaults
44
working_directory: ~/listify
55
docker:
6-
- image: circleci/elixir:1.9.4
6+
- image: circleci/elixir:1.10.1
77
- image: postgres:latest
88
environment:
99
POSTGRES_USER: postgres

README.md

Lines changed: 37 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,45 @@
22

33
# Listify
44

5-
To start your Phoenix server:
5+
This repository contains the implementation of a simple shopping list. It has both a UI built with LiveView and a REST API.
66

7-
* Setup the project with `mix setup`
8-
* Start Phoenix endpoint with `mix phx.server`
7+
## Dependencies
98

10-
Now you can visit [`localhost:4000`](http://localhost:4000) from your browser.
9+
To run the project and its tests, the following dependencies are required:
10+
* Elixir 1.10
11+
* Postgres 11+
1112

12-
Ready to run in production? Please [check our deployment guides](https://hexdocs.pm/phoenix/deployment.html).
13+
## Running the project
1314

14-
## Learn more
15+
To run the project, first export the following environment variables regarding your database configuration:
16+
* `DATABASE_USERNAME` - Defaults to `postgres`
17+
* `DATABASE_PASSWORD` - Defaults to `postgres`
18+
* `DATABASE_NAME` - Defaults to `listify_dev`
19+
* `DATABASE_POOL_SIZE` - Defaults to `10`
1520

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
21+
Then, navigate to the cloned repository and run the following commands:
22+
```shell
23+
mix deps.get
24+
mix ecto.setup
25+
mix phx.server
26+
```
27+
28+
The project will be available on `localhost:4000`. The list is under the route `/items`.
29+
30+
## Running unit tests
31+
32+
The library used to build unit tests was `ExUnit`. In assistance to it, `ExMachina` was used to build factories.
33+
34+
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`.
35+
36+
## Static code analysis
37+
38+
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
39+
```shell
40+
mix credo
41+
mix dialyzer
42+
```
43+
44+
## Architecture
45+
46+
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)