Installing the Backend System

Follow these instructions to install, build, and verify the backend system.

System Requirements

To operate the backend system, you must have one of the following:

  • A 64-bit Mac OS (Intel or ARM)
  • A 64-bit Linux machine (Ubuntu or Debian)

Prerequisites

I. Update the Environment

  1. Open a Terminal window; if using Linux or Mac.

  2. If you are using Linux, make sure your environment system packages are up to date.

    sudo apt update
    sudo apt upgrade
    

II. Install Java 17

  1. Install the OpenJDK package.
    Mac:

    Go to https://www.oracle.com/java/technologies/javase/jdk17-archive-downloads.html. Download the kit based on your system requirements. Install the JDK.

    Linux:

    sudo apt install -y openjdk-17-jdk-headless unzip
    
  2. Verify that you have successfully installed version 17.

    java -version
    

    Make sure it is:

    java version "17.0.8" 2023-07-18 LTS Java(TM) SE Runtime Environment (build 17.0.8+9-LTS-211) Java HotSpot(TM) 64-Bit Server VM (build 17.0.8+9-LTS-211, mixed mode, sharing)

III. Install Docker and Docker Compose

  1. Download Docker Desktop to get all the necessary packages for this installation: https://www.docker.com/products/docker-desktop/

  2. Open the Docker Desktop.

  3. Confirm successful installation.

    MAC:

    docker info
    

    Linux:

    sudo docker --version
    sudo systemctl status docker  `
    

VI. Clone Backend System

  1. If you do not have Git, install it using the instruction here: Git - Installing Git (git-scm.com)

  2. If you wish to iterate and develop on the backend, please fork the repo and then clone it from your own account. You can find steps to fork here: https://docs.github.com/en/get-started/quickstart/fork-a-repo

  3. Download the latest implementation of the Samsung Health Stack backend system from GitHub.

    git clone https://github.com/S-HealthStack/backend-system.git
    

The folder in which you cloned the backend-system will be referred to as <install_path> within this document.

V. Firebase Service

  1. If you do not have an account, create a Firebase account and a project with default settings by visiting: Firebase (google.com)

  2. Go to the [Firebase console](Firebase console) and select your project.

  3. Click on the gear icon in the top left corner to access your project settings.

  4. Click on the Service accounts tab.

  5. Click the Generate new private key button to generate a new service account key file (we used Node.js on our Mac test).

    NOTE: You don't need to follow any further instructions on Firebase at this point - all you had to do was generate the key.

  6. Return to the terminal and create a Firebase service-account-key.json file.

    cd backend-system/platform
    touch service-account-key.json
    
  7. Update the service-account-key.json file with the private key generated in step 5 so service-account-key.json looks like the key you created/downloaded from Firebase.

  8. .gitignore this service-account-key.json file as it includes sensitive info about your Firebase account.

Installation

Method 1: Using Docker Compose

I. backend-config-files-v1.zip

  1. Download backend-config-files-v1.zip from https://github.com/S-HealthStack/S-HealthStack.github.io/blob/main/files/installing-the-backend/backend-config-files-v1.zip

  2. Extract the files and place them at the level of backend-system. Your file structure should look as follows for <install_path>:

    backend-system
    docker-compose.yml
    haproxy
    multi_db
    rule-update
    trino
    ref.tgz
    .env
    

II. Database (Optional)

  1. If you don't want to use our provided sample database, following the Configuring the Database page instructions if you want to connect to the running Postgres container.

  2. (Optional) Update PostgreSQL root user password and SMTP relay server host, username, port, and password. We use SMTP service to send account invitation/activation/password reset emails.

    POSTGRES_PASSWORD=<new-value-here>
    SMTP_HOST=<new-value-here>
    SMTP_PORT=<new-value-here>
    MAIL_USER=<new-value-here>
    MAIL_USER_PASSWORD= <new-value-here>
    
  3. (Required if performing Step 2) Sync password with Trino PostgreSQL catalog file downloaded located at: <install_path>/trino/etc/catalog/postgresql/postgresql.properties

    connector.name=postgresql
    connection-url=jdbc:postgresql://hrp-postgres:5432/healthstack
    connection-user=postgres
    connection-password= <new-value-here>
    

III. Compile

  1. Move into the backend-system directory.

    cd backend-system
    
  2. Compile and package the backend-related microservices:

    Mac & Linux:

    ./gradlew clean
    ./gradlew build -x detekt