Skip to content

Approach-Labs-AI/spend-agent

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Spend Agent — AI-Powered Personal Burn Tracker

Remixable Val Town template. Connect your bank via Teller or upload CSV exports, get AI-powered categorization with an editable prompt, and track your monthly burn with interactive charts.

Uses Val Town's per-val scoped SQLite (std/sqlite/main.ts) so each remix gets its own isolated database — no prefix dance, no shared state with other vals on the same account.

Quick Start

  1. Remix this project on Val Town
  2. Set environment variables (see below)
  3. Open the dashboard — upload a CSV or connect a bank
  4. Hit "Preview Classification" to categorize transactions with AI

Time to value: ~5 minutes

How It Works

Architecture

The feedback loop is the key insight: more data + prompt refinement = better classification over time. Once your data is categorized, the structured output powers everything downstream.

Ideas After You Remix

Once your transactions are classified, the structured data is yours to build on. Some starting points:

  • Find & cancel subscriptions — "Show me all my recurring subscriptions. Which ones haven't I used in 3 months? Help me cancel them by next billing cycle."
  • Budget guardrails with alerts — Set up a cron that texts you when a category (restaurants, golf, shopping) exceeds your monthly budget. Proactive, not reactive.
  • Spending trends & accountability — "How much do I spend on food per day on average? How do I trend that down?" Have the agent check in weekly and keep you honest.
  • Smart digest emails — Weekly or monthly email: "You spent $X this month, up 15% from last month. Top 3 categories that grew: ..."
  • Ask anything — The /ask tab already lets you chat with your financial data. Ask "what did I spend on travel last quarter?" or "am I on track for my savings goal?"
  • Custom automations — Val Town crons + Claude + your categorized data = any workflow you can imagine. Budget forecasting, tax prep summaries, spending comparisons across months.

Files

File Type Purpose
app.ts http Dashboard, settings, API routes
db.ts script SQLite schema, config helpers, default categories
lib.ts script Formatting, HTML shell, category colors
classify-engine.ts script LLM classification engine (tool use with JSON schema)
classify-ui.ts script Classification drawer UI (extracted for file size limits)
classify.ts interval (daily) Thin cron wrapper — calls runClassification()
sync-engine.ts script Teller mTLS sync logic
sync.ts interval (15min) Thin cron wrapper — calls runSync()

Environment Variables

Var Required Purpose
ANTHROPIC_API_KEY Yes Claude API for AI classification + Ask tab
TELLER_APP_ID No Your Teller application ID (free at teller.io)
TELLER_ENV No sandbox (default), development, or production
TELLER_CERT No Teller mTLS certificate PEM (not needed for sandbox)
TELLER_KEY No Teller mTLS private key PEM (not needed for sandbox)

Teller vars are only needed if you want automatic bank sync. Without them, CSV upload still works. Sandbox mode lets you test with fake bank data without mTLS certificates — just set TELLER_APP_ID.

Set these in Val Town Environment Variables — they are never stored in code.

Dashboard Pages

  • / — Monthly burn overview, stacked bar chart, Spend/Net Income toggle, category breakdown with expandable transactions, unclassified banner with classification drawer
  • /ask — Chat with your financial data using Claude (natural language queries)
  • /settings — Classification prompt editor, Teller bank connection, CSV upload (Chase, Amex, Venmo), category management

Classification Engine

How It Works

  1. Cross-source dedup — Matches same amount ±2 days across institutions, marks bank-side as transfer
  2. LLM classification (Claude Haiku) — Uses Anthropic tool use with JSON schema to enforce valid categories. The category field is constrained to an enum — no hallucinated categories possible
  3. User overrides — Manual category changes are permanent and never re-classified

Interactive Flow

  1. Click "Review & Classify" banner → drawer opens with unclassified transactions
  2. Review/edit the classification prompt → click "Preview Classification"
  3. Review results with color-coded category pills + confidence scores
  4. Edit prompt inline and "Retry" or "Approve All" to commit

Default Categories

Housing, Food, Transportation, Shopping, Entertainment, Health, Subscriptions, Bills, Travel, Investments, Transfers, Salary, Income, Gifts, Other

Customizable on the Settings page. The tool schema updates dynamically.

CSV Import

Supports Chase, Amex, and Venmo CSV exports with automatic format detection and deduplication. Upload via Settings page.

SQLite Schema

transactions       -- All transactions (bank + CSV)
monthly_summaries  -- Pre-computed monthly aggregates
config             -- Key-value settings (classification prompt, categories, etc.)
teller_tokens      -- Linked bank account tokens

Plain table names — no prefix needed because this val uses Val Town's per-val scoped SQLite via import { sqlite } from 'https://esm.town/v/std/sqlite/main.ts'. Each remixed val gets its own isolated DB. The legacy account-scoped import (std/sqlite without /main.ts) would share one DB across all your vals.

About

Personal spend agent — Teller + Claude transaction classification (Val Town)

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors