/neurorecovery

The NeuroRecovery App assists post-stroke patients with their recovery through a web application

Primary LanguageTypeScript

NeuroRecovery

The NeuroRecovery App assists post-stroke patients with their recovery through a web application

Overview

Deployment with Tilt CI/CD

The NeuroRecovery app is tested and deployed with Tilt CI/CD.

This form of deployment requires some upfront cost. Once the environment is configured with a Kubernetes cluster and tilt up is running though, the application will be automatically deployed in a consistent manner, and the developer receives immediate CI/CD feedback for any code changes.

Steps to Deploy

By completing the below steps the environment will be ready to deploy the application on a Kubernetes cluster:

  • Install Tilt CI/CD
  • Start a Kubernetes cluster on your local machine such as K3s which provides a Load Balancer by default. If using K3s, you may have to change the traefik-config.yaml to allow usage of port 80, see Load Balance Rust for more details.
  • Install kubectl, helm, podman and buildah locally, on Fedora this would be: sudo dnf install kubernetes helm podman buildah.
  • Deploy an image registry on the Kubernetes cluster, see setting up any Image Registry from Tilt, an example of deploying a registry from scratch. Ensure to apply cluster registry yaml file so Tilt identifies it.
  • Clone the repo into the deployment server: git clone git@github.com:mark-ruddy/neurorecovery.git
  • For the send_email function to work in the backend, it requires AWS credentials to use Simple Email Service(SES) to send the emails to the meeting invitee and sender, you can get those creds by following the AWS docs - https://docs.aws.amazon.com/IAM/latest/UserGuide/security-creds.html
  • Add a .env file to the backend directory, touch backend/.env, then add your tokens:
NEURORECOVERY_MONGODB_PASS=au5maduk55
AWS_ACCESS_KEY_ID=(hidden)
AWS_SECRET_ACCESS_KEY=(hidden)
  • If NEURORECOVERY_MONGODB_PASS is changed to anything other than au5maduk55, then update it in Tiltfile too: os.putenv('NEURORECOVERY_MONGODB_PASS', 'au5maduk55').
  • If this is an internet-exposed deployment, then set the backend URL in the frontends BackendService, since the Angular JS will be delivered to the users browser it must query the internet-exposed backend URL:
// NOTE: In production this URL should be the host server address
public backendBaseUrl = 'http://neurorecovery-app.xyz:8080'; 
  • Run tilt up --host 0.0.0.0 and visit localhost:10350, if the local dependencies are not installed, then there will be some failing tests - this is OK if the goal is to get the deployment up only.
  • Run kubectl get all -n neurorecovery and helm ls -a -n neurorecovery to view the deployed resources.

Once the resources have been compiled and built into container images to be deployed on the cluster, they will be available on the host node at:

To connect to MongoDB by shell: mongo --host 10.43.252.173 -u root -p <YOUR_PASS>

Production Deployment

For a production deployment some extra steps may be considered:

  • Restricting CORS settings for the backend server to only accepting requests from the frontend server:
    • Modify the layer(CorsLayer::permissive()) line in the create_router() function in main.rs of the backend code.

Report Generation

  1. pandoc report_neurorecovery.md -o dist/report_neurorecovery.docx
  2. Manually add first page from template in libreoffice
  3. Export as pdf to dist/report_neurorecovery.pdf - this is report generated