HASSAR.AI Platform Documentation

Deployment Guide

Version 1.0 Date July 2026 Audience Client DevOps / System Administrator
Overview

Architecture

HASSAR.AI consists of two independently deployed components that connect at runtime:

ComponentTechnologyTargetDomain
FrontendNext.js 16 (App Router)Cloudflare Pageshassar.ai
BackendFastAPI + PostgreSQLClient's dedicated serverapi.hassar.ai
NoteThe frontend can be deployed first, but login and chat will not function until the backend is live at https://api.hassar.ai.
Prerequisites

Before You Begin

Frontend
  • Cloudflare account with hassar.ai domain already added
  • Access to GitHub repository: VlassStudio/HassarAI
Backend Server
  • Ubuntu 22.04 LTS or Debian 12
  • Python 3.11+
  • PostgreSQL 15+
  • Nginx
  • DNS: api.hassar.ai pointed to the server's public IP
  • Firewall: port 443 and 80 open inbound; port 8000 not exposed publicly
Part 1 — Frontend
01

Create Cloudflare Pages Project

  1. Log in to Cloudflare DashboardWorkers & Pages
  2. Click CreatePagesConnect to Git
  3. Authorise Cloudflare to access your GitHub account
  4. Select repository: VlassStudio/HassarAI
  5. Click Begin setup
02

Build Settings

FieldValue
Project namehassarai (or your preference)
Production branchmain
Framework presetNext.js
Root directoryfrontend
Build commandnpm run build
Build output directory.next
03

Environment Variable

Under Environment variables, add the following for both Production and Preview:

VariableValue
NEXT_PUBLIC_API_URLhttps://api.hassar.ai

Click Save and Deploy. The first build takes 2–4 minutes.

04

Custom Domain

  1. In your Pages project → Custom domainsSet up a custom domain
  2. Enter hassar.ai — Cloudflare auto-creates DNS records
  3. Repeat for www.hassar.ai if needed
  4. SSL is provisioned automatically — no further action needed
Auto-DeployEvery git push to main triggers an automatic redeploy. No manual action needed for future updates.
Part 2 — Backend
05

Clone & Install

git clone https://github.com/VlassStudio/HassarAI.git
cd HassarAI/backend

python3 -m venv venv
source venv/bin/activate
pip install -r requirements.txt
06

PostgreSQL Setup

sudo -u postgres psql
CREATE DATABASE hassarai;
CREATE USER hassarai_user WITH PASSWORD 'your-strong-password';
GRANT ALL PRIVILEGES ON DATABASE hassarai TO hassarai_user;
\q
07

Environment File

Create /home/<user>/HassarAI/backend/.env:

DATABASE_URL=postgresql://hassarai_user:your-strong-password@localhost:5432/hassarai
JWT_SECRET_KEY=<random-string-minimum-64-characters>
APP_ENV=production
Generate JWT Secretpython3 -c "import secrets; print(secrets.token_hex(32))"
ImportantNever commit the .env file to git. It is already listed in .gitignore.
08

Systemd Service

Create /etc/systemd/system/hassarai.service (replace <user> with your system username):

[Unit]
Description=HASSAR.AI Backend
After=network.target postgresql.service

[Service]
Type=simple
User=www-data
WorkingDirectory=/home/<user>/HassarAI/backend
EnvironmentFile=/home/<user>/HassarAI/backend/.env
ExecStart=/home/<user>/HassarAI/backend/venv/bin/uvicorn app.main:app --host 127.0.0.1 --port 8000 --workers 2
Restart=always
RestartSec=5

[Install]
WantedBy=multi-user.target
sudo systemctl daemon-reload
sudo systemctl enable hassarai
sudo systemctl start hassarai
sudo systemctl status hassarai
09

Nginx Reverse Proxy

sudo apt install nginx -y

Create /etc/nginx/sites-available/hassarai-api:

server {
    listen 80;
    server_name api.hassar.ai;

    location / {
        proxy_pass http://127.0.0.1:8000;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto $scheme;
        proxy_set_header CF-Connecting-IP $http_cf_connecting_ip;
        proxy_read_timeout 120s;
    }
}
sudo ln -s /etc/nginx/sites-available/hassarai-api /etc/nginx/sites-enabled/
sudo nginx -t
sudo systemctl reload nginx
10

SSL Certificate

sudo apt install certbot python3-certbot-nginx -y
sudo certbot --nginx -d api.hassar.ai

Follow the prompts. Certbot auto-renews every 90 days.

Verify Backend

curl https://api.hassar.ai/
# Expected: {"ok": true}
11

Create Admin Account

  1. Open https://hassar.ai/signup and register the first user
  2. Promote to admin directly in the database:
sudo -u postgres psql hassarai
UPDATE users SET role = 'admin' WHERE email = 'your@email.com';
\q
Part 3 — AGIM
12

Connect AGIM

  1. Log in to https://hassar.ai with your admin account
  2. Go to System AdminAI Config
  3. Enter the AGIM URL and API Key provided by Vlass Studio
  4. Click Save
  5. Open Talk to Jim and send a test message — confirm AGIM responds
AGIM CredentialsThe AGIM URL and API Key will be provided separately by Vlass Studio after backend deployment is confirmed.
Ref

Updating the Application

Frontend

Push to main branch — Cloudflare Pages redeploys automatically.

Backend
cd HassarAI
git pull origin main
cd backend
source venv/bin/activate
pip install -r requirements.txt
sudo systemctl restart hassarai
Ref

Environment Variables Reference

Frontend (Cloudflare Pages)
VariableRequiredValue
NEXT_PUBLIC_API_URLYeshttps://api.hassar.ai
Backend (.env file)
VariableRequiredDescription
DATABASE_URLYesPostgreSQL connection string
JWT_SECRET_KEYYesRandom string, minimum 64 characters
APP_ENVYesSet to production on live server