Skip to main content
Vantage uses Supabase (PostgreSQL) as its primary database. Row-Level Security (RLS) is enabled on every table — users can only access their own data, enforced at the database level regardless of which client is querying.

Migrations overview


Core tables

users

Auto-populated via trigger on auth.users insert. preferred_currency drives all display formatting in the Flutter app.

accounts

livery_color drives the card gradient on the Accounts Hub screen. statement_day is used for the credit card billing cycle calculation in balance reconciliation.

transactions

Indexes:
FTS trigger:

holdings


budgets


groups and debts

creditor_id and debtor_id are text (not uuid) to allow debts with non-registered contacts — a friend without a Vantage account can still appear as a party in a split.

bill_splits


user_insights

AI-generated insights written by the AnomalyAlerts agent. Read by the Dashboard’s real-time insights feed.

ai_conversations


user_embeddings

RAG memory store — daily/weekly/monthly financial summaries embedded at 384 dimensions (BAAI/bge-small-en-v1.5).

transaction_embeddings

Per-transaction semantic search — embedded at 1024 dimensions (Voyage 3-Lite).

fcm_tokens


Row-Level Security policies

All tables have ALTER TABLE ... ENABLE ROW LEVEL SECURITY. Key policy patterns:

PostgreSQL functions

handle_new_user() — auth trigger

Fires on every new auth.users insert. Creates a matching public.users row with name/avatar extracted from OAuth metadata:

remap_seed_data(old_uid, new_uid) — first sign-in

Updates every foreign key and array member across all tables from the demo UUID to the real user’s UUID:

hybrid_search(query_embedding, query_text, user_id, count, fts_weight, semantic_weight)

Combines pgvector cosine similarity with PostgreSQL FTS, returned as a weighted score:
Used by the RAG pipeline to retrieve relevant context before AI responses.

pg_cron scheduled job

Runs daily at 00:30 UTC (08:30 SGT) to generate daily insights: