Skip to content

nikhilnair31/FORGOR-Server

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

BUILDMODE-Server

This repository contains setup instructions for configuring the BUILDMODE Server, including database, services and NGINX with HTTPS support.


To-Do

  • Think of better system to track user interest
    • Maybe a graph
    • Track recency for decay and frequency for interest signals
    • Track in vector space for topic clusters
  • Create nudges system

Setup

1. Update the Server

sudo apt update
sudo apt full-upgrade

2. Database (PostgreSQL + pgvector)

Install

sudo apt install -y postgresql
sudo apt install -y postgresql-17-pgvector

Configure

  1. Log into Postgres:

    sudo -u postgres psql
  2. Set a password:

    ALTER USER postgres WITH PASSWORD '<YOUR_NEW_PASSWORD>';

Create Database

CREATE DATABASE mia2;
\c mia2
CREATE EXTENSION vector;
\q

Useful Commands

  • Open DB:

    psql -U <DB_USER> -d <DB_NAME>
  • Drop a table:

    DROP TABLE <table_name>;
  • Drop the database:

    sudo -u postgres dropdb <DB_NAME>
  • Completely remove PostgreSQL:

    sudo apt remove --purge -y postgresql*
    sudo apt autoremove --purge -y

Indexing with IVFFlat

CREATE INDEX tags_vector_idx ON data
USING ivfflat (tags_vector vector_cosine_ops)
WITH (lists = 50);

CREATE INDEX swatch_vector_idx ON data
USING ivfflat (swatch_vector vector_l2_ops)
WITH (lists = 50);
  • Tuning lists:

    • Small datasets (≤10K rows): 10–50
    • Medium datasets (10K–100K rows): 50–100

Update planner statistics:

ANALYZE data;

3. Services (Systemd)

Create Service

sudo nano /etc/systemd/system/forgor-api.service

Enable & Start

sudo systemctl daemon-reexec && sudo systemctl daemon-reload
sudo systemctl enable forgor-api.service
sudo systemctl start forgor-api.service
sudo systemctl restart forgor-api.service
sudo journalctl -u forgor-api.service -f

Check Logs

sudo systemctl status forgor-api
journalctl -u forgor-api.service -f

4. Digest Service (Systemd Timer)

The digest system sends weekly/monthly digests to users.

Create Service

sudo nano /etc/systemd/system/forgor-digest.service
```bash

```bash
sudo nano /etc/systemd/system/forgor-digest.timer
```bash

### 5. NGINX + HTTPS

#### Setup Domain

* Point your **domain A record** to the VPS IP.
* Wait \~15 minutes for DNS propagation.

#### Configure NGINX

```bash
sudo nano /etc/nginx/sites-available/<name>
  • Use the template in nginx.config.
sudo ln -s /etc/nginx/sites-available/<name> /etc/nginx/sites-enabled/
sudo nginx -t        # Validate config
sudo systemctl start nginx
sudo systemctl status nginx
sudo systemctl reload nginx

Enable HTTPS (Certbot)

sudo certbot --nginx -d <domain>.xyz -d www.<domain>.xyz

Verify auto-renewal:

sudo certbot renew --dry-run

Quick Commands

PostgreSQL

  • Check version:

    psql --version
  • Status:

    sudo systemctl status postgresql
  • Start & enable:

    sudo systemctl start postgresql
    sudo systemctl enable postgresql
  • Show Postgres logs (last 50 lines, live):

    journalctl -u postgresql.service -n 50 -f
  • Connect to DB:

    psql -U <DB_USER> -d <DB_NAME>
  • List databases:

    \l
  • List tables:

    \dt
  • Inspect schema of a table:

    \d <table_name>
  • Run quick query:

    SELECT * FROM <table_name> LIMIT 10;

API / Flask Service

  • Check status:

    sudo systemctl status forgor-api
  • Show logs (last 100 lines, live):

    journalctl -u forgor-api.service -f
  • Restart service:

    sudo systemctl daemon-reexec && sudo systemctl daemon-reload
    sudo systemctl restart forgor-api.service

NGINX

  • Status:

    sudo systemctl status nginx
  • Reload config:

    sudo nginx -t && sudo systemctl reload nginx
  • Logs:

    sudo tail -f /var/log/nginx/access.log
    sudo tail -f /var/log/nginx/error.log

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published