lukas-kratochvil / mafil-proband-safety-questionnaire

MAFIL - Proband Safety Questionnaire
https://mafil-proband-safety-questionnaire.vercel.app
The Unlicense
2 stars 0 forks source link

MAFIL - Proband Safety Questionnaire

Web application for ensuring the registration and safety of MR measurements in the MAFIL laboratory (CEITEC).

! This application relies on the central system of the MAFIL laboratory called MAFILDB !

Table of contents

Repository structure

This repository contains the following most important directories and files:

Base URL paths

Installation

Firstly, install Docker and docker-compose (see the official Docker docs) on the system you want to run this app on.

After that use the download.sh script (located in the project root directory) to download files essential to run the app.

./download.sh -d [DOWNLOAD_PATH] -e [ENV]

Edit downloaded files and transfer the directory to the server. You can use this command template:

scp -r -i SSH_PRIVATE_KEY_FILE_PATH LOCAL_DIR_PATH USER@SERVER:REMOTE_DIR_PATH

In the app root directory on the remote server create the certs directory and store there the SSL certificate certificate.pem and the corresponding private key private_key.pem.

Start all the services using this command:

docker-compose up -d

The command will start the services listed below:

These volumes will be created in the app root directory:

Populating the database with initial data

To populate the database with initial data (languages, genders, native languages, handednesses and safety questions), the command below must be run inside the server container.

docker-compose exec server npm run seed

Then users that are eligible to access the authenticated part of the app must be defined. Login to the Adminer at /adminer URL path and create accounts in the Operator table in the database.

Services update

It may be necessary to update configurations before running the commands below:

To update services run these commands in the root directory:

docker-compose pull [SERVICE]
docker-compose up -d --force-recreate --no-deps [SERVICE]
docker image prune -f

Local development

Installation

In the root directory create the following files:

Edit .env, server-config.yaml and web-config.json configuration variables with your values.

The docker-compose configuration file to use for the development is called docker-compose.local.yml. Start all the services with the command below:

docker-compose -f docker-compose.local.yml up -d

The backend and frontend package.json and the source code directory are mapped as volumes in the corresponding container filesystem.

Only node_modules are not mapped to Docker containers due to potential platform-specific code. So they must be installed and updated separately on a local machine and in the server and web Docker containers.

To install or update Node packages run the command:

npm i

Populating the database with initial data

To populate the local database with initial data (languages, genders, native languages, handednesses and safety questions), the command below must be run inside the server container.

npm run seed:local

You also need to create the user you specified in the web-config.json in the database.

Changing the database schema and applying database migrations

postgres and server services must be up and running to apply changes from the schema.prisma file.

Go into the server container terminal and in the /usr/src/app/backend directory run:

npx prisma migrate dev --name what-has-changed

This command creates a new migration and also generates a new Prisma client code that corresponds to the current state of the schema.prisma.

The new Prisma client code is generated only in the server container because local and server container node_modules are separated. To update local node_modules use this command in the backend directory to apply new migrations:

npx prisma generate

Updating i18n translations

After you change the /public/locales translations structure, you need to run the npm run i18n:generate script to get the required TypeScript support for the i18n translation keys. For example in functions like useTranslation(), t() etc.

Useful tools

Used MAFILDB API endpoints

This section describes used MAFILDB API endpoints, and whether they are used in the unauthenticated or authenticated part of this application and in what situations.

Possible issues

In this section, you can find solutions to some problems that are not directly related to the application itself.

PDF not showing on the Visit detail page

PDF may not be shown on the Visit detail page. A possible solution is to set browser settings accordingly - open the PDF directly in your browser.

For example in Firefox, you have to set it like this:

PDF view - Firefox