Self Hosting

This guide will demonstrate how to self host the Vault API on your own server or a cloud provider of your choice.

Prerequisites

  • A server running Ubuntu 18.04 or later
  • A domain name that you own
  • A valid SSL certificate for your domain name
  • A sendgrid account with an API key
  • Some knowledge of reverse proxies and DNS
  • An OpenAI API key or Your own Self hosted model (more on that later)

Step 1 - Configure DNS

You will need to configure your DNS to point to your server. You can do this by creating an A record for each of the subdomains you want to use.

A		self-chat.arguflow.ai
A		self-api.arguflow.ai
A		self-search.arguflow.ai

Step 2 - Install Docker on machine

Follow the guide here to install docker on your server: https://docs.docker.com/engine/install/ubuntu/

Step 3 - Clone the repository

Shell

git clone https://github.com/arguflow/arguflow
cd arguflow

Step 4 - Configure the Environment Variables for the API

There are 3 files you need to modify We have an example .env file in the root of the repository. You can use this as a starting point for your own configuration.

cp .env.dist .env

.env

REDIS_URL=redis://redis:6379
QDRANT_URL=http://qdrant-database:6334
DATABASE_URL=postgres://postgres:password@db:5432/vault
S3_ENDPOINT=http://s3:9000
QDRANT_COLLECTION="vault"
# Update with your own api keys
SENDGRID_API_KEY=SG.******************************************************************
OPENAI_API_KEY=sk-************************************************
# You might want better passwords
SECRET_KEY=01234012340123401234012340123401234012340123401234012340123401234012340123401234
SALT="goodsaltisveryyummy"
S3_USER="s3user"
S3_PASSWORD="s3password"
LIBREOFFICE_PATH=libreoffice
S3_ACCESS_KEY=ZaaZZaaZZaaZZaaZZaaZ
S3_SECRET_KEY=ssssssssssssssssssssTTTTTTTTTTTTTTTTTTTT
S3_BUCKET=vault
VERIFICATION_SERVER_URL=http://127.0.0.1:8091/get_url_content
QDRANT_API_KEY=qdrant_pass
COOKIE_SECURE=true
ALERT_EMAIL="developer@arguflow.gg"
USE_EMBED_SERVER=0
PARSER_COMMAND="./vault-nodejs/scripts/card_parser.js"
EMBEDDING_SERVER_CALL="http://localhost:5000/encode"
EMBEDDING_SIZE=1536

# Only lines that need to get changed for now are the ones below
PUBLIC_CHAT_URL=https://self-chat.arguflow.ai
PUBLIC_SEARCH_URL=https://self-search.arguflow.ai
API_HOST=https://self-api.arguflow.ai/api

# You might want better passwords
MINIO_ROOT_USER=rootuser
MINIO_ROOT_PASSWORD=rootpassword

.env.chat

VITE_API_HOST=https://self-api.arguflow.ai/api

.env.search

API_HOST=https://self-api.arguflow.ai/api
PUBLIC_HOST=https://self-search.arguflow.ai
PUBLIC_API_HOST=https://self-api.arguflow.ai/api

Step 5 - Setup docker compose

Shell

docker compose up -d

Step 6 - Configure Caddyfile

Install caddy using the instructions here: https://caddyserver.com/docs/install

We have an example Caddyfile in the root of the repository. You can use this as a starting point for your own configuration.

sudo cp Caddyfile /etc/caddy/Caddyfile

/etc/caddy/Caddyfile

# Global options
{
    email developer@arguflow.gg
}

# Define a site block for chat.arguflow.ai
self-chat.arguflow.ai {
    reverse_proxy localhost:3000
}

# Define a site block for api.arguflow.ai
self-api.arguflow.ai {
    reverse_proxy localhost:8090
}

# Define a site block for search.arguflow.ai
self-search.arguflow.ai {
    reverse_proxy localhost:3001
}

Once you have this you can run the caddy daemon using systemctl

sudo systemctl enable caddy.service
sudo systemctl restart caddy.service

Step 7 - Profit 🦀🦀🦀

Congratulations you have now self hosted the Arguflow API. You can now use the API by navigating to your domain name in your browser on either chat or search.