HASSAR.AI Platform Documentation
Deployment Guide
Overview
Architecture
HASSAR.AI consists of two independently deployed components that connect at runtime:
| Component | Technology | Target | Domain |
|---|---|---|---|
| Frontend | Next.js 16 (App Router) | Cloudflare Pages | hassar.ai |
| Backend | FastAPI + PostgreSQL | Client's dedicated server | api.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.aidomain 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.aipointed 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
- Log in to Cloudflare Dashboard → Workers & Pages
- Click Create → Pages → Connect to Git
- Authorise Cloudflare to access your GitHub account
- Select repository: VlassStudio/HassarAI
- Click Begin setup
02
Build Settings
| Field | Value |
|---|---|
| Project name | hassarai (or your preference) |
| Production branch | main |
| Framework preset | Next.js |
| Root directory | frontend |
| Build command | npm run build |
| Build output directory | .next |
03
Environment Variable
Under Environment variables, add the following for both Production and Preview:
| Variable | Value |
|---|---|
NEXT_PUBLIC_API_URL | https://api.hassar.ai |
Click Save and Deploy. The first build takes 2–4 minutes.
04
Custom Domain
- In your Pages project → Custom domains → Set up a custom domain
- Enter
hassar.ai— Cloudflare auto-creates DNS records - Repeat for
www.hassar.aiif needed - 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 Secret
python3 -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
- Open
https://hassar.ai/signupand register the first user - 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
- Log in to
https://hassar.aiwith your admin account - Go to System Admin → AI Config
- Enter the AGIM URL and API Key provided by Vlass Studio
- Click Save
- 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)
| Variable | Required | Value |
|---|---|---|
NEXT_PUBLIC_API_URL | Yes | https://api.hassar.ai |
Backend (.env file)
| Variable | Required | Description |
|---|---|---|
DATABASE_URL | Yes | PostgreSQL connection string |
JWT_SECRET_KEY | Yes | Random string, minimum 64 characters |
APP_ENV | Yes | Set to production on live server |