HackPrinceton project - AI-powered spending tracker that helps users distinguish between NEED and WANT purchases through iMessage interactions.
User makes purchase → Backend receives transaction → Sends iMessage asking "NEED or WANT?"
→ User replies via text → System learns patterns → Predicts future spending → Shows yearly savings
# Backend
cd backend
npm install
# Frontend
cd frontend
npm installCreate backend/.env:
PORT=3001
USER_PHONE_NUMBER=+12533683150
DATABASE_PATH=./database.db
# Terminal 1 - Start Backend
cd backend
npm start
# Terminal 2 - Start Frontend
cd frontend
npm run devAccess:
- Backend API: http://localhost:3001
- Frontend Dashboard: http://localhost:5174
- Express API - REST endpoints for transactions, classifications, predictions
- SQLite Database - Stores transactions, user classifications, merchant predictions
- iMessage Integration - Sends questions and watches for replies using
@photon-ai/imessage-kit - Prediction Engine - Calculates spending patterns and yearly savings
- React Dashboard - Real-time transaction feed
- Statistics - Total spent, needs vs wants breakdown
- Predictions Table - AI-predicted future purchases with savings calculations
- Classification UI - Buttons to classify transactions as NEED or WANT
transactions
- Transaction details from purchases
- Links to classifications
classifications
- User's NEED/WANT decisions
- Timestamps and confidence scores
predictions
- Per-merchant predictions
- Average amounts, purchase frequency
- Next purchase date estimates
- Yearly savings if switched to NEED
GET /api/dashboard # Get all data (transactions, stats, predictions)
POST /api/transactions # Create new transaction (triggers iMessage)
POST /api/classify/:id # Classify transaction as NEED or WANT
GET /api/predictions # Get spending predictions
- Open System Settings → Privacy & Security → Full Disk Access
- Add your Terminal app
- Open Messages.app and sign in with Apple ID
- Verify iMessage is enabled (Messages → Settings → iMessage)
When a transaction is created:
- Backend sends iMessage via AppleScript
- User receives: "You bought [item] for $[amount]. Was this a NEED or WANT?"
- User replies with "NEED" or "WANT"
- Backend watches Messages database for reply
- Classification is stored and predictions update
Fallback: If iMessage unavailable, use the web UI to classify transactions.
- Add transaction via frontend form (e.g., "Starbucks, Latte, $7.25")
- Backend logs show:
Sent iMessage to +12533683150... - Click NEED or WANT button to classify
- Add more purchases from same merchant
- Watch predictions calculate yearly savings
- Backend: Node.js, Express, SQLite, better-sqlite3
- Frontend: React, TypeScript, Vite
- iMessage: @photon-ai/imessage-kit, AppleScript
- Database: SQLite3
iMessage not sending:
- Ensure Messages.app is running and signed into iMessage
- Check Terminal has Full Disk Access permission
- Test manually in Messages.app first
Database errors:
- Delete
backend/database.dband restart backend (recreates tables)
Port conflicts:
- Backend uses 3001, frontend uses 5173/5174
- Change PORT in
.envif needed
hackprinceton/
├── backend/
│ ├── src/
│ │ ├── server.js # Express server
│ │ ├── database.js # SQLite operations
│ │ ├── routes/api.js # API endpoints
│ │ └── services/
│ │ ├── imessageService.js # iMessage sending/watching
│ │ └── predictionService.js # Spending predictions
│ ├── .env # Configuration
│ └── package.json
├── frontend/
│ ├── src/
│ │ ├── App.tsx # Main dashboard component
│ │ └── services/api.ts # Backend API client
│ └── package.json
└── README.md # This file
- Integrate Knot API for real bank transaction data
- Add Claude AI for automatic classification suggestions
- Support multiple users
- Mobile app for better UX
- Export reports and analytics