Skip to content

Deployment

Installation

Repositories

There are three repositories that power the Trieste application:

Databases & Storage

There are two databases used by the system, both of which live in the DigitalOcean Ayima account.

  • Trieste-v2-main-db-mysql-lon1-35921 - The main MySQL database
  • Db-redis-lon1-01 - The redis database used for workers and job queues.

The app also stores email content and attachments using DigitalOcean spaces, identical to aws buckets.

  • Trieste - contains all the email content, attachments etc from the active email accounts in the system
  • Serps-trieste - Used to cache Serp results from the batches created in the system.

Envs

Backend Env

dotenv
NODE_ENV="production"
ACCESS_REFRESH_TOKEN_EXPIRY_HOUR=24
DB_ENCRYPTION_KEY=
USE_HTTPS="true"
LOG=true
SERVER_IP=0.0.0.0
SERVER_PORT=443
AYIMA_API_ENDPOINT=
AYIMA_API_AUTH=
LEADS_DB_TABLE=
LEADS_DB_USERNAME=
LEADS_DB_PASSWORD=
LEADS_DB_HOST=
LEADS_DB_DIALECT="mysql"
LEADS_DB_PORT=25060
ENV=local
AWS_KEY=
AWS_ACCESS_KEY_ID=
AWS_SECRET=
AWS_SECRET_ACCESS_KEY=
AWS_BUCKET=
SECRET_KEY=
REDIS_PORT=25061
REDIS_HOST=
REDIS_PASS=
TRIESTE_SERP_API=
TRIESTE_API_USERNAME=
TRIESTE_SERP_API_PASSWORD=
QUEUE_JOBS_MAX_ATTEMPTS=
QUEUE_JOBS_DELAY_SECONDS=
TRIESTE_EMAIL_SERVICE=
TRIESTE_HUNTER_API=
TRIESTE_EMAIL_FETCHER=
HOME_URL=https://app.trieste.io
RATES_API=https://www.ecb.europa.eu/stats/eurofxref/eurofxref-daily.xml
RATES_API_ACCESS_KEY=
EMAIL_FETCH_MAX_ERROR_COUNT=10
EMAIL_FETCH_RECHECK_MINUTES=10
ACCESS_TOKEN_EXPIRY_HOUR=1440
MAX_CONTENT_ITEM_STORAGE=15
DB_LOGGING=false
D4S_API_ENDPOINT=
D4S_API_USER=
D4S_API_PASSWORD=
TRANCO_ENDPOINT=
TRANCO_USERNAME=
TRANCO_PASSWORD=

Frontend Env

dotenv
VUE_APP_TRIESTE_API=https://app.trieste.io

Backend Configuration and deployment

  1. Clone the https://github.com/Ayima/trieste-api-v2 repository
  2. Copy the backend .env values from the 'backend env' section and complete with production values
  3. To pull the submodule, run: git submodule update --init --recursive
  4. To run the backend, run: node app/start
  5. The project uses typescript, so to render changes either run tsc --build on completion or tsc -w to auto watch for changes
  6. To deploy, push any code changes to the git repository.
  7. To push to production, login to Buddy and deploy the production instances of the Trieste API project

Any changes in the app/Core must be pushed to the node-boilerplate-core repository. This is done by simply going to the app/Core directly and performing a git add/push. It is vital that you consider changes here as no changes made here should be specific to the Trieste app only. It is important to also add the app/Core directly to the git push in the root directly so that the kubernetes pipeline is aware to pull changes from the submodule.

Frontend Configuration and deployment

  1. Clone the https://github.com/Ayima/trieste-vue repository
  2. Copy the frontend .env values from the 'frontend env' section and complete with production values
  3. To run the frontend, run: npm run serve
  4. To deploy, push any code changes to the git repository.
  5. To push to production, login to Buddy and deploy the production instance of the Trieste API project

Backend methodology and structure

The backend of Trieste is built using a custom layer over fastify, a NodeJS framework. The backend is split into the following folders:

  • App
    • Controllers - An MVC approach that splits the logic of the application into controllers. Each file represents the entity it affects and each route is defined as a function
    • Config - Configuration files for the application stored in one place
      • Clients.ts - Initiates all third party API clients using axios).
      • config.ts - Core configuration values such as logs, name/endpoint etc
      • database.ts - Database configuration
      • pm2.js - Config that defines separate workers that can run indefinitely outside of the main app
      • server.js - Server configuration
      • storage.js - Config for storage adapters such as file storage, S3 or redis
    • Core - Shared Ayima library that powers that app and can be shared across a variety Ayima projects
    • Database - All database scheme and models
    • Email - Email templates used by the system (e.g. sign up / forgotten password)
    • Jobs - Location for all worker files / logic
    • Json - JSON files used by the app, e.g. lead states
    • Modules - Business code that is written in a way that can be easily copied across projects
    • Routes - All available API routes are defined here. This can also be used to easily map each route to its controller
    • Services - Functions that intiate each module and defines specific logic for the app
    • SSL - SSL certificate files
    • Subscribers - Event listener files