Skip to content

Commit

Permalink
[#59] improving documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
ferigis committed Aug 29, 2018
1 parent c5525e8 commit 2bede60
Show file tree
Hide file tree
Showing 32 changed files with 2,732 additions and 49 deletions.
41 changes: 37 additions & 4 deletions README.md
Expand Up @@ -19,23 +19,56 @@ mix docs

That command will create a `doc/` folder with the actual Documentation.

## Run Tests
## Configuring Databases for first time

`POABackend` uses many Databases. For Authentication we use [Mnesia](http://erlang.org/doc/man/mnesia.html) as a local database and for some receivers which require storage we use Postgres. All databases are managed on top of [Ecto](https://hexdocs.pm/ecto/Ecto.html) a widly used database wrapper for Elixir projects.

For this reason we have to set the databases before running the `POABackend` for the first time.

`POABackend` uses [Mnesia](http://erlang.org/doc/man/mnesia.html) as a local database with [Ecto](https://hexdocs.pm/ecto/Ecto.html). In order to have this running we have to create a folder where `Mnesia` will store our data. In order to do that we have to define it in the `config/test.exs` file like this:
- Auth Database (Mnesia): Setting up Mnesia is easy since it is working localy and is built in the Erlang Virtual Machine. We only have to say "where" we are going to store the database's files. In order to do that we have to add the configuration to the config file (`prod.exs` or `test.exs` depending if you want to run tests or production)

```
config :mnesia,
dir: 'your/local/path' # make sure this directory exists!
```

once we have the path defined we have to create the database (those commands must be run only once if you are going to use always this same path for testing). In your root folder run:
- Receivers Database (Postgres): This is a little more complex than Mnesia. We need a Postgres instance running somewhere and we have to add the config to the config files

```
config :poa_backend, POABackend.Receivers.Repo,
priv: "priv/receivers", # this value is not changed
adapter: Ecto.Adapters.Postgres,
database: "poabackend_stats",
username: "postgres",
password: "postgres",
hostname: "localhost"
```

The important fields here are `database`, `username`, `password` and `hostname`. The rest of values must remain exactly as the example.

Once we have set the database configuration we have to create and migrate the databases, in order to do that we should be in the root of the project and run:

- for production

```
MIX_ENV=prod mix ecto.create
MIX_ENV=prod mix ecto.migrate
```

- for test

```
MIX_ENV=test mix ecto.create
MIX_ENV=test mix ecto.migrate
```

Now the environment is set. We can run the tests with:
Now the environment is ready for running `POABackend`

## Run Tests

The first time you run the tests you will need having the Database's environment set up. Check the previous section and set the configuration in the `config/test.exs` file.

Once the environment is set. We can run the tests with:

```
mix test
Expand Down
8 changes: 8 additions & 0 deletions config/config.exs
Expand Up @@ -23,4 +23,12 @@ config :poa_backend, POABackend.Auth.Repo,
config :mnesia,
dir: 'priv/data/mnesia' # make sure this directory exists!

config :poa_backend, POABackend.Receivers.Repo,
priv: "priv/receivers", # this value is not changed
adapter: Ecto.Adapters.Postgres,
database: "poabackend_stats",
username: "postgres",
password: "postgres",
hostname: "localhost"

import_config "#{Mix.env}.exs"
2 changes: 1 addition & 1 deletion config/prod.exs
Expand Up @@ -85,7 +85,7 @@ config :mnesia,
dir: 'priv/data/mnesia' # make sure this directory exists!

config :poa_backend, POABackend.Receivers.Repo,
priv: "priv/receivers",
priv: "priv/receivers", # this value is not changed
adapter: Ecto.Adapters.Postgres,
database: "poabackend_stats",
username: "postgres",
Expand Down
5 changes: 4 additions & 1 deletion doc/.build
Expand Up @@ -4,12 +4,13 @@ fonts/icomoon.eot
fonts/icomoon.svg
fonts/icomoon.ttf
fonts/icomoon.woff
dist/sidebar_items-3739fd4c82.js
dist/sidebar_items-3d14d8fe9b.js
api-reference.html
initial_architecture.html
search.html
404.html
POABackend.html
POABackend.Receivers.Repo.html
POABackend.Auth.html
POABackend.Auth.Guardian.Plug.html
POABackend.Auth.Models.Token.html
Expand All @@ -24,4 +25,6 @@ POABackend.CustomHandler.REST.html
POABackend.Receiver.html
POABackend.Receivers.Dashboard.html
POABackend.Receivers.DynamoDB.html
POABackend.Receivers.Eth.Stats.html
POABackend.Receivers.System.Stats.html
index.html
2 changes: 1 addition & 1 deletion doc/404.html
Expand Up @@ -8,7 +8,7 @@
<title>404 – poa_backend v0.1.0</title>
<link rel="stylesheet" href="dist/app-480ffdc169.css" />

<script src="dist/sidebar_items-3739fd4c82.js"></script>
<script src="dist/sidebar_items-3d14d8fe9b.js"></script>



Expand Down
2 changes: 1 addition & 1 deletion doc/POABackend.Auth.Guardian.Plug.html
Expand Up @@ -8,7 +8,7 @@
<title>POABackend.Auth.Guardian.Plug – poa_backend v0.1.0</title>
<link rel="stylesheet" href="dist/app-480ffdc169.css" />

<script src="dist/sidebar_items-3739fd4c82.js"></script>
<script src="dist/sidebar_items-3d14d8fe9b.js"></script>



Expand Down
2 changes: 1 addition & 1 deletion doc/POABackend.Auth.Models.Token.html
Expand Up @@ -8,7 +8,7 @@
<title>POABackend.Auth.Models.Token – poa_backend v0.1.0</title>
<link rel="stylesheet" href="dist/app-480ffdc169.css" />

<script src="dist/sidebar_items-3739fd4c82.js"></script>
<script src="dist/sidebar_items-3d14d8fe9b.js"></script>



Expand Down
2 changes: 1 addition & 1 deletion doc/POABackend.Auth.Models.User.html
Expand Up @@ -8,7 +8,7 @@
<title>POABackend.Auth.Models.User – poa_backend v0.1.0</title>
<link rel="stylesheet" href="dist/app-480ffdc169.css" />

<script src="dist/sidebar_items-3739fd4c82.js"></script>
<script src="dist/sidebar_items-3d14d8fe9b.js"></script>



Expand Down
2 changes: 1 addition & 1 deletion doc/POABackend.Auth.REST.html
Expand Up @@ -8,7 +8,7 @@
<title>POABackend.Auth.REST – poa_backend v0.1.0</title>
<link rel="stylesheet" href="dist/app-480ffdc169.css" />

<script src="dist/sidebar_items-3739fd4c82.js"></script>
<script src="dist/sidebar_items-3d14d8fe9b.js"></script>



Expand Down
22 changes: 11 additions & 11 deletions doc/POABackend.Auth.html
Expand Up @@ -8,7 +8,7 @@
<title>POABackend.Auth – poa_backend v0.1.0</title>
<link rel="stylesheet" href="dist/app-480ffdc169.css" />

<script src="dist/sidebar_items-3739fd4c82.js"></script>
<script src="dist/sidebar_items-3d14d8fe9b.js"></script>



Expand Down Expand Up @@ -318,7 +318,7 @@ <h1 class="section-heading">
</a>
<span class="signature">authenticate_admin(admin_name, password)</span>

<a href="https://github.com/poanetwork/poa-netstats-wharehouse/blob/v0.1.0/lib/poa_backend/auth.ex#L97" class="view-source" rel="help" title="View Source">
<a href="https://github.com/poanetwork/poa-netstats-wharehouse/blob/v0.1.0/lib/poa_backend/auth.ex#L98" class="view-source" rel="help" title="View Source">
<span class="icon-code" aria-hidden="true"></span>
<span class="sr-only">View Source</span>
</a>
Expand Down Expand Up @@ -378,7 +378,7 @@ <h1 class="section-heading">
</a>
<span class="signature">create_banned_token(jwt_token)</span>

<a href="https://github.com/poanetwork/poa-netstats-wharehouse/blob/v0.1.0/lib/poa_backend/auth.ex#L157" class="view-source" rel="help" title="View Source">
<a href="https://github.com/poanetwork/poa-netstats-wharehouse/blob/v0.1.0/lib/poa_backend/auth.ex#L158" class="view-source" rel="help" title="View Source">
<span class="icon-code" aria-hidden="true"></span>
<span class="sr-only">View Source</span>
</a>
Expand Down Expand Up @@ -409,7 +409,7 @@ <h1 class="section-heading">
</a>
<span class="signature">create_banned_token(token, expires)</span>

<a href="https://github.com/poanetwork/poa-netstats-wharehouse/blob/v0.1.0/lib/poa_backend/auth.ex#L171" class="view-source" rel="help" title="View Source">
<a href="https://github.com/poanetwork/poa-netstats-wharehouse/blob/v0.1.0/lib/poa_backend/auth.ex#L172" class="view-source" rel="help" title="View Source">
<span class="icon-code" aria-hidden="true"></span>
<span class="sr-only">View Source</span>
</a>
Expand Down Expand Up @@ -504,7 +504,7 @@ <h1 class="section-heading">
</a>
<span class="signature">generate_password()</span>

<a href="https://github.com/poanetwork/poa-netstats-wharehouse/blob/v0.1.0/lib/poa_backend/auth.ex#L132" class="view-source" rel="help" title="View Source">
<a href="https://github.com/poanetwork/poa-netstats-wharehouse/blob/v0.1.0/lib/poa_backend/auth.ex#L133" class="view-source" rel="help" title="View Source">
<span class="icon-code" aria-hidden="true"></span>
<span class="sr-only">View Source</span>
</a>
Expand Down Expand Up @@ -533,7 +533,7 @@ <h1 class="section-heading">
</a>
<span class="signature">generate_user_name()</span>

<a href="https://github.com/poanetwork/poa-netstats-wharehouse/blob/v0.1.0/lib/poa_backend/auth.ex#L111" class="view-source" rel="help" title="View Source">
<a href="https://github.com/poanetwork/poa-netstats-wharehouse/blob/v0.1.0/lib/poa_backend/auth.ex#L112" class="view-source" rel="help" title="View Source">
<span class="icon-code" aria-hidden="true"></span>
<span class="sr-only">View Source</span>
</a>
Expand Down Expand Up @@ -562,7 +562,7 @@ <h1 class="section-heading">
</a>
<span class="signature">generate_user_name(user_name)</span>

<a href="https://github.com/poanetwork/poa-netstats-wharehouse/blob/v0.1.0/lib/poa_backend/auth.ex#L121" class="view-source" rel="help" title="View Source">
<a href="https://github.com/poanetwork/poa-netstats-wharehouse/blob/v0.1.0/lib/poa_backend/auth.ex#L122" class="view-source" rel="help" title="View Source">
<span class="icon-code" aria-hidden="true"></span>
<span class="sr-only">View Source</span>
</a>
Expand Down Expand Up @@ -620,7 +620,7 @@ <h1 class="section-heading">
</a>
<span class="signature">purge_banned_tokens()</span>

<a href="https://github.com/poanetwork/poa-netstats-wharehouse/blob/v0.1.0/lib/poa_backend/auth.ex#L203" class="view-source" rel="help" title="View Source">
<a href="https://github.com/poanetwork/poa-netstats-wharehouse/blob/v0.1.0/lib/poa_backend/auth.ex#L204" class="view-source" rel="help" title="View Source">
<span class="icon-code" aria-hidden="true"></span>
<span class="sr-only">View Source</span>
</a>
Expand Down Expand Up @@ -678,7 +678,7 @@ <h1 class="section-heading">
</a>
<span class="signature">token_banned?(token)</span>

<a href="https://github.com/poanetwork/poa-netstats-wharehouse/blob/v0.1.0/lib/poa_backend/auth.ex#L220" class="view-source" rel="help" title="View Source">
<a href="https://github.com/poanetwork/poa-netstats-wharehouse/blob/v0.1.0/lib/poa_backend/auth.ex#L221" class="view-source" rel="help" title="View Source">
<span class="icon-code" aria-hidden="true"></span>
<span class="sr-only">View Source</span>
</a>
Expand Down Expand Up @@ -736,7 +736,7 @@ <h1 class="section-heading">
</a>
<span class="signature">valid_token?(jwt_token)</span>

<a href="https://github.com/poanetwork/poa-netstats-wharehouse/blob/v0.1.0/lib/poa_backend/auth.ex#L185" class="view-source" rel="help" title="View Source">
<a href="https://github.com/poanetwork/poa-netstats-wharehouse/blob/v0.1.0/lib/poa_backend/auth.ex#L186" class="view-source" rel="help" title="View Source">
<span class="icon-code" aria-hidden="true"></span>
<span class="sr-only">View Source</span>
</a>
Expand Down Expand Up @@ -765,7 +765,7 @@ <h1 class="section-heading">
</a>
<span class="signature">valid_user_name?(user_name)</span>

<a href="https://github.com/poanetwork/poa-netstats-wharehouse/blob/v0.1.0/lib/poa_backend/auth.ex#L141" class="view-source" rel="help" title="View Source">
<a href="https://github.com/poanetwork/poa-netstats-wharehouse/blob/v0.1.0/lib/poa_backend/auth.ex#L142" class="view-source" rel="help" title="View Source">
<span class="icon-code" aria-hidden="true"></span>
<span class="sr-only">View Source</span>
</a>
Expand Down
2 changes: 1 addition & 1 deletion doc/POABackend.CustomHandler.REST.html
Expand Up @@ -8,7 +8,7 @@
<title>POABackend.CustomHandler.REST – poa_backend v0.1.0</title>
<link rel="stylesheet" href="dist/app-480ffdc169.css" />

<script src="dist/sidebar_items-3739fd4c82.js"></script>
<script src="dist/sidebar_items-3d14d8fe9b.js"></script>



Expand Down
2 changes: 1 addition & 1 deletion doc/POABackend.CustomHandler.html
Expand Up @@ -8,7 +8,7 @@
<title>POABackend.CustomHandler – poa_backend v0.1.0</title>
<link rel="stylesheet" href="dist/app-480ffdc169.css" />

<script src="dist/sidebar_items-3739fd4c82.js"></script>
<script src="dist/sidebar_items-3d14d8fe9b.js"></script>



Expand Down
2 changes: 1 addition & 1 deletion doc/POABackend.Protocol.DataType.html
Expand Up @@ -8,7 +8,7 @@
<title>POABackend.Protocol.DataType – poa_backend v0.1.0</title>
<link rel="stylesheet" href="dist/app-480ffdc169.css" />

<script src="dist/sidebar_items-3739fd4c82.js"></script>
<script src="dist/sidebar_items-3d14d8fe9b.js"></script>



Expand Down
2 changes: 1 addition & 1 deletion doc/POABackend.Protocol.Message.html
Expand Up @@ -8,7 +8,7 @@
<title>POABackend.Protocol.Message – poa_backend v0.1.0</title>
<link rel="stylesheet" href="dist/app-480ffdc169.css" />

<script src="dist/sidebar_items-3739fd4c82.js"></script>
<script src="dist/sidebar_items-3d14d8fe9b.js"></script>



Expand Down
2 changes: 1 addition & 1 deletion doc/POABackend.Protocol.MessageType.html
Expand Up @@ -8,7 +8,7 @@
<title>POABackend.Protocol.MessageType – poa_backend v0.1.0</title>
<link rel="stylesheet" href="dist/app-480ffdc169.css" />

<script src="dist/sidebar_items-3739fd4c82.js"></script>
<script src="dist/sidebar_items-3d14d8fe9b.js"></script>



Expand Down
2 changes: 1 addition & 1 deletion doc/POABackend.Protocol.html
Expand Up @@ -8,7 +8,7 @@
<title>POABackend.Protocol – poa_backend v0.1.0</title>
<link rel="stylesheet" href="dist/app-480ffdc169.css" />

<script src="dist/sidebar_items-3739fd4c82.js"></script>
<script src="dist/sidebar_items-3d14d8fe9b.js"></script>



Expand Down
2 changes: 1 addition & 1 deletion doc/POABackend.Receiver.html
Expand Up @@ -8,7 +8,7 @@
<title>POABackend.Receiver – poa_backend v0.1.0</title>
<link rel="stylesheet" href="dist/app-480ffdc169.css" />

<script src="dist/sidebar_items-3739fd4c82.js"></script>
<script src="dist/sidebar_items-3d14d8fe9b.js"></script>



Expand Down
2 changes: 1 addition & 1 deletion doc/POABackend.Receivers.Dashboard.html
Expand Up @@ -8,7 +8,7 @@
<title>POABackend.Receivers.Dashboard – poa_backend v0.1.0</title>
<link rel="stylesheet" href="dist/app-480ffdc169.css" />

<script src="dist/sidebar_items-3739fd4c82.js"></script>
<script src="dist/sidebar_items-3d14d8fe9b.js"></script>



Expand Down
2 changes: 1 addition & 1 deletion doc/POABackend.Receivers.DynamoDB.html
Expand Up @@ -8,7 +8,7 @@
<title>POABackend.Receivers.DynamoDB – poa_backend v0.1.0</title>
<link rel="stylesheet" href="dist/app-480ffdc169.css" />

<script src="dist/sidebar_items-3739fd4c82.js"></script>
<script src="dist/sidebar_items-3d14d8fe9b.js"></script>



Expand Down

0 comments on commit 2bede60

Please sign in to comment.