diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 9b07d2cabfcd9be14bd2674f9aa8b1ee3b4fee8d..ae27e65076b969a93fba02e43b411f5b818dc27a 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -1,5 +1,10 @@
 image: ${DEVOPS_REGISTRY}usgs/centos:latest
 
+cache:
+  paths:
+    # cache pip installed dependencies, see PIP_CACHE_DIR variable below
+    - .cache/pip
+
 stages:
   - test
   - integration
@@ -9,6 +14,7 @@ stages:
 variables:
   CI_REGISTRY: ${CODE_REGISTRY}
   CI_REGISTRY_IMAGE: ${CODE_REGISTRY_IMAGE}
+  PIP_CACHE_DIR: "$CI_PROJECT_DIR/.cache/pip"
   TRIVY_VERSION: "0.11.0"
   # docker variables
   DOCKER_DRIVER: overlay2
@@ -61,7 +67,6 @@ variables:
     - build
 
 .check_code:
-  cache: {}
   image: ${DEVOPS_REGISTRY}usgs/conda:latest
   script:
     - export PYTHON_VERSION=${PYTHON_VERSION:-3.8}
@@ -98,11 +103,29 @@ variables:
     - deploy
     - swarm
 
-.mage:
+.deploy-library:
+  cache: {}
+  image: "docker:stable-git"
+  script:
+    - PREFIX_LENGTH=${#REQUIRED_PREFIX};
+    - if [[ "${APP_DEPLOY_DIR:0:${PREFIX_LENGTH}}" != "${REQUIRED_PREFIX}" ]]; then
+        echo "APP_DEPLOY_DIR does not contain correct path";
+        exit 255;
+      fi
+    - if [ ! -d "${APP_DEPLOY_DIR}" ]; then
+        cd "$(dirname "${APP_DEPLOY_DIR}")";
+        git clone "${CI_REPOSITORY_URL}" "$(basename "${APP_DEPLOY_DIR}")";
+      fi
+    - cd "${APP_DEPLOY_DIR}";
+    - git checkout "${CI_COMMIT_REF_NAME}" || git checkout -b "${CI_COMMIT_REF_NAME}";
+    - git pull --ff-only "${CI_REPOSITORY_URL}" "${CI_COMMIT_REF_NAME}";
+  stage: deploy
+  tags:
+    - deploy
+    - swarm
   variables:
-    DATA_HOST: "cwbpub.cr.usgs.gov"
-    DATA_PORT: "2060"
-    DATA_TYPE: "edge"
+    APP_DEPLOY_DIR: '/geomag/geomag-algorithms'
+    REQUIRED_PREFIX: '/geomag'
 
 .staging:
   only:
@@ -182,7 +205,18 @@ Scan Docker Image:
 # Deploy Stage
 ## --------------------------------------------------
 
-Deploy Mage01:
+Deploy Mage01 Library:
+  extends:
+    - .deploy-library
+    - .staging
+  tags:
+    - deploy
+    - swarm
+    - mage01
+  variables:
+    APP_NAME: geomag-algorithms
+
+Deploy Mage01 Web Service:
   extends:
     - .deploy
     - .staging
@@ -193,7 +227,7 @@ Deploy Mage01:
   variables:
     APP_NAME: geomag-algorithms
 
-Deploy Mage02:
+Deploy Mage02 Web Service:
   extends:
     - .deploy
     - .production
@@ -204,7 +238,7 @@ Deploy Mage02:
   variables:
     APP_NAME: geomag-algorithms
 
-Deploy Algorithms Production01:
+Deploy Production01 Web Service:
   extends:
     - .deploy
     - .production
@@ -215,7 +249,7 @@ Deploy Algorithms Production01:
   variables:
     APP_NAME: geomag-algorithms
 
-Deploy Algorithms Production02:
+Deploy Production02 Web Service:
   extends:
     - .deploy
     - .production
@@ -226,7 +260,7 @@ Deploy Algorithms Production02:
   variables:
     APP_NAME: geomag-algorithms
 
-Deploy Algorithms Staging01:
+Deploy Staging01 Web Service:
   extends:
     - .deploy
     - .staging
@@ -237,7 +271,7 @@ Deploy Algorithms Staging01:
   variables:
     APP_NAME: geomag-algorithms
 
-Deploy Algorithms Staging02:
+Deploy Staging02 Web Service:
   extends:
     - .deploy
     - .staging
diff --git a/Pipfile b/Pipfile
index 4414bbc32ff2ce27c7927bb5c3fb7bcb6ec3ce37..0fe36b7372e7751b47a890c4f3f186d06c68deba 100644
--- a/Pipfile
+++ b/Pipfile
@@ -21,7 +21,7 @@ pycurl = "==7.43.0.5"
 # web service dependencies
 authlib = "*"
 cryptography = "*"
-databases = {extras=["postgresql", "sqlite"], version = "*"}
+databases = {extras=["postgresql", "sqlite"], version = "==0.3.2"}
 fastapi = "*"
 gunicorn = "*"
 httpx = "==0.11.1"