Port is a research tool that enables individuals to donate their digital trace data for academic research in a secure, transparent, and privacy-preserving way.
The D3i project is funded by the PDI-SSH and is a collaboration between six Dutch universities and Eyra.
The consortium is composed of researchers from:
- University of Amsterdam
- Radboud University Nijmegen
- VU Amsterdam
- Utrecht University
- Tilburg University
- Erasmus University Rotterdam
The first phase of the project ended in December 2022 and resulted in an MVP solution to run one Port app on top of a Next bundle (see: README.md). This Next + Port combi can be released as a Docker image and deployed on Azure Web App Service.
-
Pre-requisite
- Install asdf
- Install PostgreSQL Server
- Fork and clone branch
d3i/latest
of this Mono repo.
-
Create a PostgreSQL database and replace the configurated values in
core/config/dev.exs
with your own:# Configure your database config :core, Core.Repo, username: "postgres", password: "postgres", database: "next_dev",
-
Link Port app in
core/assets/package.json
See https://github.com/eyra/port-poc/blob/master/README.md on how to create your own Port app.
Go to package.json and replace
github:eyra/port
with a reference to your Port app. -
Install tools:
$ asdf plugin-add erlang $ asdf plugin-add elixir $ asdf plugin-add nodejs $ asdf install
See
.tool-versions
for the exact versions that will be installed -
Install dependencies:
$ cd core $ make install
-
Build Next (from core folder):
$ BUNDLE=next make build
-
Run database migrations (from core folder)
$ mix ecto.migrate
-
Run Next locally (from core folder):
$ BUNDLE=next make run
-
Go to browser
The Port app is running at: http://localhost:4000/data-donation/port. To start a donation session complete the url with:
- App id (aka flow id). Currently we have only one Port app running with id
1
. - Participant id. Can be any alpha numeric string).
- App id (aka flow id). Currently we have only one Port app running with id
Source file | Description |
---|---|
port.js | Javascript hook responsible for starting the Port app and implementing the Port app System callback interface |
port_page.ex | Elixir/Phoenix web page running on endpoint /data-donation/port/:appid/:participantid |
port_model.ex | Port app configuration (id and storage configuration) |
port_model_data.ex | Contains configuration for Port app with id 1 |
delivery.ex | Asynchronous delivery of donated data backed by Oban |
azure_storage_backend.ex | Integration with Azure Blob Storage. |
Note: if you created an alternative processing worker file, don't forget to import this file port.js:
import Worker from "port/dist/framework/processing/my_new_worker.js";
When testing your work it is useful to link your cloned Port app instance to your cloned Mono instance.
-
Register Port app locally
In the Port app:
$ npm link
-
Link Port app locally
In Mono:
$ cd core/assets $ npm link port
-
Unlink
In Mono:
$ cd core/assets $ npm unlink --no-save port
To prevent users from exhausting system resources, Next uses rate limiters. The local configuration of rate limiters for Azure Blob Service can be found in core/config/dev.exs
:
config :core, :rate,
prune_interval: 5 * 1000,
quotas: [
[service: :azure_blob, limit: 1, unit: :call, window: :second, scope: :local],
[service: :azure_blob, limit: 100, unit: :byte, window: :second, scope: :local]
]
.. and the production configuration can be found in core/config/config.exs
:
config :core, :rate,
prune_interval: 60 * 60 * 1000,
quotas: [
[service: :azure_blob, limit: 1000, unit: :call, window: :minute, scope: :local],
[service: :azure_blob, limit: 10_000_000, unit: :byte, window: :day, scope: :local],
[service: :azure_blob, limit: 1_000_000_000, unit: :byte, window: :day, scope: :global]
]
- Create a Docker image
$ cd core
$ docker build --build-arg VERSION=1.0.0 --build-arg BUNDLE=next . -t next:latest
$ docker image save next -o next.zip
- Run the Docker image
Several environment variables are required for running:
Variable | Description | Example value |
---|---|---|
BUNDLE_DOMAIN | domain name | my-datadonation-study.azurewebsites.net |
DB_USER | username | <my-username> |
DB_PASS | password | <my-password> |
DB_HOST | hostname | domain.where.database.lives |
DB_NAME | name of the database in the PostgreSQL | next_dev |
SECRET_KEY_BASE | 64-bit sequence of random characters | <long-sequence-of-characters> |
AZURE_BLOB_STORAGE_USER | name of the storage account donated data gets stored in | <name-of-storage-account> |
AZURE_BLOB_CONTAINER | name of the storage container | <name-of-storage-container> |
AZURE_SAS_TOKEN | token generated by Azure for tempraroy write only access to the storage account | <sas-token> |
STATIC_PATH | should be /static | /static |
SSL_DISABLED | SSL is handle by Azure app services should be set to true | true |