Skip to Content
Database

Database

Supabase-hosted PostgreSQL instance. RLS is enabled on both tables with a "service role full access" policy that grants full access to the backend service key.


Table: transactions

Stores all expense and income records.

ColumnTypeNullableDescription
idUUIDNoPrimary key, auto-generated (gen_random_uuid())
amountDECIMAL(10,2)NoTransaction amount in BRL
dateDATENoTransaction date
establishmentVARCHAR(255)YesMerchant or payee name
descriptionTEXTYesFree-text description
category_idINTNoFK → categories.id
tax_idVARCHAR(18)YesCNPJ or CPF of the merchant
entry_typeVARCHAR(20)No'imagem', 'texto', or 'pdf' — stored in Portuguese per DB constraint
transaction_typeVARCHAR(10)No'income' or 'expense' (default: 'outcome' in schema, renamed to 'expense' via migration)
confidenceDECIMAL(3,2)YesAI extraction confidence (0.00–1.00)
raw_dataJSONBNoFull AI extraction output (default: {})
created_atTIMESTAMPTZNoRecord creation timestamp
updated_atTIMESTAMPTZNoLast update timestamp

Indexes:

IndexColumnsPurpose
idx_transactions_datedateFilter/sort by date
idx_transactions_category_idcategory_idFilter by category
idx_transactions_date_category_id(date, category_id)Combined date + category queries
idx_transactions_transaction_typetransaction_typeFilter by income vs expense

Note: The payment_method field ('credit' | 'debit') exists in the API layer (domain entity and endpoints) but is not yet reflected in the supabase_schema.sql file. It may be stored in raw_data or added via a pending migration.


Table: categories

Stores expense categories. Deactivating a category preserves all linked transactions.

ColumnTypeNullableDescription
idSERIALNoPrimary key, auto-increment
nameVARCHAR(100)NoCategory name (unique)
is_activeBOOLEANNoWhether the category is active (default: true)
created_atTIMESTAMPTZNoRecord creation timestamp

Constraint: UNIQUE(name)


Relationships

categories (id) ──< transactions (category_id)

category_id in transactions is NOT NULL — every transaction must have a category.


Default Categories

Seeded on first setup:

Name
Alimentação
Educação
Lazer
Moradia
Outros
Pets
Saúde
Serviços
Transporte
Vestuário
Last updated on