Files
WealthySmart/backend/app/seed.py
Carlos Escalante 13161b8e49
Some checks failed
Deploy to VPS / deploy (push) Failing after 7s
Add budget module: FastAPI backend + React frontend
Backend: FastAPI + PostgreSQL with models for accounts, transactions,
and categories. Auto-categorization from merchant patterns, token auth,
CRUD endpoints, and seed data for 16 categories and 4 bank accounts.

Frontend: Login, Dashboard (account balances + recent charges),
Transactions (full CRUD table with search/filter), Cash & Transfers
view. Dark theme with emerald/cyan accents, responsive layout.

Infrastructure: Updated docker-compose for backend + db services,
nginx proxy config for API routing, deploy workflow with secrets.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-21 11:33:38 -06:00

46 lines
2.4 KiB
Python

from sqlmodel import Session, select
from app.db import engine
from app.models.models import Account, Bank, Category, Currency
DEFAULT_CATEGORIES = [
("Groceries", "shopping-cart", "automercado,auto mercado,fresh market,macrobiotica,pricesmart,price smart,grassfedcr,pequeno mundo"),
("Food & Delivery", "utensils", "uber eats,rappi,mcdonalds,subway,pizza,restaurant,soda,cafe,coyote ugly,el rodeo,steak house"),
("Utilities", "zap", "c.n.f.l,cnfl,ice,aya,claro cr telecomunicaciones"),
("Transportation", "car", "gasolina,gasolinera,uber rides,didi,parqueo,parking,peaje,estacion de servicio,estac.de serv"),
("Shopping", "shopping-bag", "amazon,ebay,ticotek,construplaza,epa,novex,novedades chayfer,total imports,tiendalaliga,gnc live well"),
("Entertainment", "film", "netflix,disney,cine,steam,playstation,blizzard,diablo"),
("Health", "heart-pulse", "farmacia,hospital,clinica,laboratorio,optica,medicina regenerativa,neumi,doer fitness,kettlebell,lacrosse"),
("Education", "graduation-cap", "universidad,udemy,coursera,libro"),
("Housing", "home", "hipoteca,alquiler,municipalidad,condominio,bac san jose pensiones"),
("Insurance", "shield", "seguro,ins"),
("Subscriptions", "repeat", "cloudflare,github,google one,apple,icloud,spotify,openai,claude.ai,cursor,netcup"),
("Telecom", "phone", "liberty,tigo,kolbi"),
("Parking & Fees", "circle-parking", "centro comercial curridabat,debito compass,cobro administr,compass"),
("Auto", "car-front", "auto lavado,lavado"),
("Lab & Medical", "microscope", "laboratorio echandi"),
("Other", "tag", ""),
]
DEFAULT_ACCOUNTS = [
(Bank.BAC, Currency.CRC, "BAC Colones", 0.0),
(Bank.BAC, Currency.USD, "BAC Dólares", 0.0),
(Bank.BCR, Currency.CRC, "BCR Colones", 0.0),
(Bank.DAVIVIENDA, Currency.CRC, "Davivienda Colones", 0.0),
]
def seed_db():
with Session(engine) as session:
existing = session.exec(select(Category)).first()
if not existing:
for name, icon, patterns in DEFAULT_CATEGORIES:
session.add(Category(name=name, icon=icon, auto_match_patterns=patterns))
session.commit()
existing_acc = session.exec(select(Account)).first()
if not existing_acc:
for bank, currency, label, balance in DEFAULT_ACCOUNTS:
session.add(Account(bank=bank, currency=currency, label=label, balance=balance))
session.commit()