Skip to main content

Infrastructure Overview

Production deployment topology for the TrickBook platform.

System Diagram

EC2 Instance

PropertyValue
Instance IDi-00a7cac777c3b3a4e
Public IP174.129.64.158
OSUbuntu
App directory/home/ubuntu/TB-Backend/
Env file/home/ubuntu/TB-Backend/.env

PM2 Processes

Three Node.js processes run under PM2:

Process NamePortPurpose
TB-Backend9000Main Express.js API server (REST + Socket.IO)
kaori-bot3001ElizaOS agent for Kaori AI companion
kith-voice3040Voice processing service

SSH Access

ssh -i ~/.ssh/weshuber.pem ubuntu@174.129.64.158
danger

The SSH private key (weshuber.pem) must never be committed to any repository or shared in plaintext. Store it in ~/.ssh/ with permissions set to 600.

PM2 Commands

NVM must be sourced before running PM2 commands on the server:

# Source NVM (required in non-interactive shells / scripts)
. ~/.nvm/nvm.sh

# Restart the backend
pm2 restart TB-Backend

# View logs
pm2 logs TB-Backend

# View logs for all processes
pm2 logs

# Check process status
pm2 status

# Restart all processes
pm2 restart all

DNS Configuration

DomainTargetService
api.thetrickbook.comEC2 (174.129.64.158)Backend API
thetrickbook.comAWS AmplifyWebsite (Next.js)
docs.thetrickbook.comDocusaurus hostingDocumentation site

External Services

MongoDB Atlas

Cloud-hosted MongoDB cluster. Connection string is stored in the ATLAS_URI environment variable on the EC2 instance.

danger

The ATLAS_URI connection string contains database credentials. It must only be stored in the server's .env file or in platform secret managers, never in source code.

PostgreSQL (pgvector)

Runs directly on the EC2 instance. Used by the kaori-bot process for RAG (Retrieval-Augmented Generation) -- storing and querying vector embeddings for Kaori's knowledge base.

AWS S3

Used for image storage (profile photos, trick media). Access credentials (AWS_KEY, AWS_SECRET) are configured in the backend .env file.

Bunny.net CDN

Handles video streaming for trick clips. The backend uploads videos to Bunny.net's stream library and serves playback URLs to clients. Configured via BUNNY_API_KEY, BUNNY_LIBRARY_API_KEY, and BUNNY_STREAM_TOKEN_KEY.

AWS Amplify

Hosts the Next.js website at thetrickbook.com. Deployments are triggered by pushes to the website repository.

EAS Build

Expo Application Services builds the React Native mobile app for distribution:

  • iOS: Builds are submitted to Apple App Store / TestFlight
  • Android: Builds are submitted to Google Play Store

Deployment Flow

Backend

Step-by-step:

# 1. SSH into the server
ssh -i ~/.ssh/weshuber.pem ubuntu@174.129.64.158

# 2. Navigate to the app directory
cd /home/ubuntu/TB-Backend

# 3. Pull latest changes
git pull origin main

# 4. Install any new dependencies
npm install

# 5. Source NVM and restart
. ~/.nvm/nvm.sh && pm2 restart TB-Backend

# 6. Verify the process is running
pm2 status

# 7. Check logs for errors
pm2 logs TB-Backend --lines 50

Website

Pushes to the website repository trigger automatic deployment via AWS Amplify.

Mobile App

Builds are triggered manually via EAS CLI:

# iOS (TestFlight)
eas build --profile testflight --platform ios

# Android (Play Store)
eas build --profile playstore --platform android

See App Store Deployment and Google Play Deployment for detailed submission guides.