Skip to content

Installation Guide

Setting Up Your Development Machine

Introduction

This guide is designed to help you prepare your development machine for Tailor development. You have two primary options for setting up the necessary dependencies:

  • Using Docker: Services like PostgreSQL and Redis are managed through Docker Compose, simplifying the setup process.
  • Manual Setup: This approach requires manually installing and configuring the necessary services.

General Prerequisites

Before you begin, ensure you have the following installed:

Setup Using Docker

  1. Install Docker.
  2. Start the required services with Docker Compose:
sh
docker compose -f docker-compose.dev.yaml up -d
  1. Initialize the development environment:
sh
pnpm setup:dev
  1. Launch the backend and frontend applications in development mode:
sh
pnpm dev

Manual Setup (Native Prerequisite Services)

  1. Install and configure PostgreSQL (version 9.4 or higher).
  2. Initialize the development environment:
sh
pnpm setup:dev
  1. Launch the backend and frontend applications in development mode:
sh
pnpm dev

Running the Application in Production Mode

  1. The application's configuration is managed through environment variables in a .env file. Start by copying the .env.example file to .env and entering your configuration details:
sh
cp .env.example .env
  1. Build the application:
sh
pnpm build
  1. Migrate the database:
sh
pnpm db:migrate
  1. Start the application:
sh
pnpm start

Environment Configuration

The development environment setup script (setup:dev) automatically configures default environment variables and populates the .env file in the project root. For a complete list of configuration options, refer to the .env.example file. Use this file as a template to create your .env file and customize the configuration details as necessary.

sh
# Logger
LOG_LEVEL=info

# -------------------------------------------------------------------
# Server configuration
# -------------------------------------------------------------------
# Set to page DNS record once deployed
HOSTNAME=localhost
# Server port
PORT=3000
# Protocol is used to generate the app URL.
# If omitted, if HOSTNAME is set to local address it will be set to http,
# otherwise it will be set to https.
PROTOCOL=http
# Port on which the app is available to the end user. In development
# mode, this configures the vite dev server which servers the application
# frontend. In production, this configures the port on which the app is
# available to the end user (443, if app is deployed with https configured).
REVERSE_PROXY_PORT=8080
# If the app is behind a reverse proxy and rate limiting is enabled
# See https://expressjs.com/en/guide/behind-proxies.html
REVERSE_PROXY_TRUST=false

# -------------------------------------------------------------------
# Database configuration
# -------------------------------------------------------------------
# You can pass the database connection string
DATABASE_URI=postgres://user:pass@hostname:port/database
# or individual database connection parameters
# DATABASE_NAME=tailor_author
# DATABASE_USER=tailor
# DATABASE_PASSWORD=tailor
# DATABASE_HOST=localhost
# DATABASE_PORT=5432
# DATABASE_ADAPTER=postgres

# Migrations are run on startup by default
# DATABASE_DISABLE_MIGRATIONS_ON_STARTUP=

# -------------------------------------------------------------------
# In-memory store configuration
# -------------------------------------------------------------------
# If KV_STORE_URL is omitted, in-memory store is used
# Example config:
# redis://user:pass@localhost:6379
# See https://github.com/jaredwray/keyv/blob/main/packages/keyv/README.md#usage
KV_STORE_URL=
# ttl - time to live measured in seconds
# records do not expire by default
KV_STORE_DEFAULT_TTL=0

# -------------------------------------------------------------------
# Security and authentication
# -------------------------------------------------------------------
# Origins allowed in CORS requests. Multiple origins can be listed by using
# comma as a separator. In development, this matches vite dev server address:
CORS_ALLOWED_ORIGINS=http://localhost:8080
# Bcrypt salt rounds for password hashing
# For more information see https://www.npmjs.com/package/bcrypt
AUTH_SALT_ROUNDS=10
# JWT tokens are used to authenticate requests to the API.
# For more information see https://www.npmjs.com/package/jsonwebtoken.
AUTH_JWT_SECRET=example_secret123!
AUTH_JWT_ISSUER=tailor
AUTH_JWT_COOKIE_NAME=access_token
AUTH_JWT_COOKIE_SECRET=example_cookie_sign_secret123!
# Enable rate limiting for authentication routes
# Make sure you configure REVERSE_PROXY_TRUST
ENABLE_RATE_LIMITING=false

# -------------------------------------------------------------------
# OIDC
# -------------------------------------------------------------------
# Tailor supports OIDC authentication
# Configuration can be skipped if OIDC is not used
# NUXT_PUBLIC_OIDC_ENABLED=0
# OIDC_ALLOW_SIGNUP=0
# NUXT_PUBLIC_OIDC_LOGIN_TEXT=Sign in with OIDC
# OIDC_DEFAULT_ROLE=ADMIN
# OIDC_CLIENT_ID=
# OIDC_CLIENT_SECRET=
# OIDC_ISSUER=
# OIDC_JWKS_URL=
# OIDC_AUTHORIZATION_ENDPOINT=
# OIDC_TOKEN_ENDPOINT=
# OIDC_USERINFO_ENDPOINT=
# NUXT_PUBLIC_OIDC_LOGOUT_ENABLED=1
# OIDC_LOGOUT_ENDPOINT=
# Use OIDC_POST_LOGOUT_URI_KEY if OIDC provider uses post logout uri key not
# aligned with OIDC RP-Initiated Logout standard key (post_logout_redirect_uri)
# OIDC_POST_LOGOUT_URI_KEY=
# OIDC_SESSION_SECRET=

# -------------------------------------------------------------------
# Email configuration for sending notifications
# -------------------------------------------------------------------
EMAIL_SENDER_NAME=Tailor
EMAIL_SENDER_ADDRESS=tailor@example.com
EMAIL_USER=
EMAIL_PASSWORD=
EMAIL_HOST=email-smtp.us-east-1.amazonaws.com
# Can be omitted if using SSL
EMAIL_PORT=
EMAIL_SSL=1
EMAIL_TLS=

# -------------------------------------------------------------------
# File storage configuration
# -------------------------------------------------------------------
# Tailor supports two storage providers: Amazon S3 and filesystem.
# Can be set to amazon or filesystem
STORAGE_PROVIDER=filesystem
# If filesystem provider is used, this is the path where files will be stored
STORAGE_PATH=data
# If amazon provider is used, these are the credentials for the S3 bucket
# STORAGE_KEY=
# STORAGE_SECRET=
# STORAGE_REGION=us-east-1
# STORAGE_BUCKET=my-bucket

# -------------------------------------------------------------------
# OAuth2 client credentials for authenticating with end-system
# -------------------------------------------------------------------
# CONSUMER_CLIENT_ID=tailor_dev_id
# CONSUMER_CLIENT_SECRET=tailor_dev_secret
# CONSUMER_CLIENT_TOKEN_HOST=http://127.0.0.1:3000
# CONSUMER_CLIENT_TOKEN_PATH=/api/oauth2/token

# Consumer publish notification settings
# Hook to be called upon publishing a resource
# [Deprecated] CONSUMER_WEBHOOK_URL in favor of CONSUMER_PUBLISH_WEBHOOK.
# CONSUMER_PUBLISH_WEBHOOK=http://127.0.0.1:3000/my-publish-hook-route

# Ability to throttle publish webhook, in milliseconds
# 0 means no throttling
# CONSUMER_PUBLISH_WEBHOOK_THROTTLE=0

# Route to be called in the editor upon clicking preview button.
# To enable this, end-system/consumer needs to implement preview mechanism.
# Route is secured using OAuth2 client credentials above.
# [Deprecated] PREVIEW_URL in favor of CONSUMER_PREVIEW_WEBHOOK.
# CONSUMER_PREVIEW_WEBHOOK=http://localhost/api/v1/preview/

# -------------------------------------------------------------------
# Open AI configuration, optional
# -------------------------------------------------------------------
# Backend
AI_MODEL_ID=gpt-4o
AI_SECRET_KEY=
# Frontend, runtime configuration
NUXT_PUBLIC_AI_UI_ENABLED=

# -------------------------------------------------------------------
# Available schemas configuration, optional
# -------------------------------------------------------------------
# Keep empty to enable all course schemas, list schemas separated by comma to
# specify which schemas to enable
NUXT_PUBLIC_AVAILABLE_SCHEMAS=

# -------------------------------------------------------------------
# Test configuration
# -------------------------------------------------------------------
# Warning: Enabling test routes will expose data manipulation endpoints
# including the ability to reset the database.
# ENABLE_TEST_API_ENDPOINTS=

# Do not group published resources by outline item id.
# repository/id/resourceId* instead of repository/id/outlineId/resourceId*
FLAT_REPO_STRUCTURE=true

# Force color output (for logs)
# https://nodejs.org/api/tty.html#writestreamgetcolordepthenv
FORCE_COLOR=1

# Statsig key
NUXT_PUBLIC_STATSIG_KEY=