Page cover image

🗄️Server

Tech stack

  • Git

  • Java 17.x

  • Apache Maven 3.8.x

  • Docker 20.10.xx

  • Docker-compose 1.29.x

GitHub

The code for the server can be found in this repository: SPICE Server

Installation

To bring the Spice back-end up and running, there are few prerequisite that has to be done. You can either follow the commands or access the official documentation by clicking the hyperlink.

sudo apt install git
sudo apt install openjdk-17-jdk
nano ~/.bashrc
nano ~/.bashrc
  • Paste the following lines in .bashrc file.

MAVEN_HOME='/home/ubuntu/Downloads/apache-maven-3.8.8'
PATH="$MAVEN_HOME/bin:$PATH"
export PATH
  • Then save the .bashrc file.

  • To apply the changes in the .bashrc file run the following command.

 . ~/.bashrc

Note: Once you have executed the script mentioned above, please restart the machine.

  • To verify the maven installation, run the following command and check the version

  mvn -v

Setup

  • Clone the spice-opensource repository.

git clone https://github.com/Medtronic-LABS/spice-server.git

Configuration

To run the application, you should pass the necessary configuration via environment properties. To achieve this, create a .env file and pass your own values for the following properties.

Note: Please paste the .env file inside the specified directory.

/spice-opensource/spice-server/

.env file

PROJECT_PATH=/home/ubuntu/spice-opensource/spice-server
DATABASE_URL=jdbc:postgresql://mypostgres:5432/spice_open_source?serverTimezone=UTC
DATABASE_USERNAME=postgres
DATABASE_PASSWORD=postgres
DATABASE_NAME=spice_open_source
NOTIFICATION_PROJECT_PATH=/home/ubuntu/spice-opensource/spice-server
REDIS_PASSWORD=password
REDIS_HOST=192.169.33.10
REDIS_PORT=6379
HERE_MAP_API_KEY=sAmpleKeYSTexT
IS_CLOUD=false
API_KEY_PATH=Dev/HERE_MAP
SERVER_REGION=us-east-1
MAIL_SEND=false
ENABLE_SMS_NOTIFICATION=false
SHEDLOCK_EMAIL_START=PT30S
SHEDLOCK_EMAIL_STOP=PT02M
IS_NEXT_MEDICAL_REVIEW_JOB=false
IS_NEXT_BP_JOB=false
IS_NEXT_BG_JOB=false
SHEDLOCK_OUTBOUND_START=PT24H
SHEDLOCK_OUTBOUND_STOP=PT25H
SHEDLOCK_SMS_START=PT30S
SHEDLOCK_SMS_STOP=PT02M
SWAGGER_ENABLED=true
LOCAL_FILE_SYSTEM_PATH=/Prescription_Signatures
IS_PRESCRIPTION_SIGNATURE_UPLOADED_TO_S3=false

.env

The .env file is used to store environment variables for the project. These variables are used to configure the application and contain sensitive information such as passwords, API keys, and other credentials.

Please note that the .env file should never be committed to version control, as it contains sensitive information that should not be shared publicly. Instead, you should add the .env file to your .gitignore file to ensure that it is not accidentally committed.

To use the application, you will need to create a .env file in the root directory of the project and add the necessary environment variables. You can refer to the above file for an example of the required variables and their format.

The values provided in the instructions are for demonstration purposes only and will not work as-is. You will need to replace them with actual values that are specific to your environment.

Note: After checking out the project, please ensure that you update the relevant properties and values in env.example, and then rename it to .env.

.env description

PROJECT_PATH: This property specifies the file path to the project's backend directory in the server.

DATABASE_URL: This property contains the JDBC connection URL for the PostgreSQL database server with the server timezone set to UTC, with the database name.

DATABASE_USERNAME: This property contains the username used to connect to the PostgreSQL database server.

DATABASE_PASSWORD: This property contains the password to connect to the PostgreSQL database server.

DATABASE_NAME: This property contains the name of the PostgreSQL database used by the project.

NOTIFICATION_PROJECT_PATH: This property specifies the file path to the notification project.

REDIS_PASSWORD: This property contains the password used to authenticate with the Redis server.

REDIS_HOST: This property contains the IP address of the Redis server.

REDIS_PORT: This property contains the port number used by the Redis server.

HERE_MAP_API_KEY: This property contains the API key required to access the HERE Maps API.

IS_CLOUD: This property indicates whether the project should retrieve the API Key from the cloud to use it with the HERE Maps API.

API_KEY_PATH: This property specifies the path to the API key required to access the HERE Maps API.

SERVER_REGION: This property specifies the region where the Amazon S3 buckets should create.

MAIL_SEND: The Application uses this property to indicate whether it sends emails.

ENABLE_SMS_NOTIFICATION: This property indicates whether SMS notifications are enabled in the Application.

SHEDLOCK_EMAIL_START: This property specifies the start time for the email shedlock job.

SHEDLOCK_EMAIL_STOP: This property specifies the stop time for the email shedlock job.

IS_NEXT_MEDICAL_REVIEW_JOB: This property indicates whether the next medical review job is enabled.

IS_NEXT_BP_JOB: This property indicates whether the next blood pressure job is enabled.

IS_NEXT_BG_JOB: This property indicates whether the next blood glucose job is enabled.

SHEDLOCK_OUTBOUND_START: This property specifies the start time for the outbound shedlock job.

SHEDLOCK_OUTBOUND_STOP: This property specifies the stop time for the outbound shedlock job.

SHEDLOCK_SMS_START: This property specifies the start time for the SMS shedlock job.

SHEDLOCK_SMS_STOP: This property specifies the stop time for the SMS shedlock job.

SWAGGER_ENABLED: This property indicates whether Swagger UI is enabled in the project.

LOCAL_FILE_SYSTEM_PATH: This property specifies the path to the directory on the server where prescription signatures are stored.

IS_PRESCRIPTION_SIGNATURE_UPLOADED_TO_S3: This property indicates whether prescription signatures uploaded to S3 bucket.

Alternative solution to AWS services using open-source and free service.

For more information refer link.

Deployment

Run the following commands in the below path.

Build a clean-install using maven /spice-opensource/spice-server

mvn clean install

Build docker images by the following command.

docker compose build

Once the images are built, run the docker containers by the following docker command.

docker compose up

Validation

Once the deployment of the application is successful, you can confirm the connectivity of the Back-end by logging into the application. To accomplish this, you may choose any API Testing tool. In this particular case, the Postman API Platform was utilized as an example.

Endpoint

POST {{ipAdd}}:8762/auth-service/session

Request Body

This endpoint allows users to sign-in into the application. The request body should be in the form-data format and include the following fields:

  • username: superuser@test.com

  • password: 1be35bc75f8316c2b5e48203d93ab3043b4774a7ab4a9e9eebf963c283cde32ddfb95aa843aee3d345f78a551a069200f013cd98904011ea6fb0cd08087d4841

Response Body
Response Headers

The response contains two values: Authorization and TenantId. You must use these values in the subsequent requests.

Swagger:

Access the Swagger UI documentation in the project using the following URL.

http://localhost:8762/webjars/swagger-ui/index.html?configUrl=/v3/api-docs/swagger-config

Note: The credentials displayed in the tables are for demonstration purposes only and should not be used in a production environment. If you need to remove, modify, or add new user credentials, you can create a new script file containing the necessary DDL or DML queries in the below specified location. It's important to note that attempting to update the existing script file may result in a checksum error.

user-service/src/main/resources/db/migration

Last updated

@2024 Medtronic LABS