Inspiration

Most people use PayPal to pay — but never to understand their spending. We wanted to fix that. The idea was simple: what if PayPal could tell you not just what you spent, but how it compares to people like you, whether your budget is healthy, and what to buy next — all in one place?

What it does

SpendWise AI is a three-feature intelligent spending portal built on top of PayPal Sandbox.

  1. Smart Budget Plans An AI rules engine reads your transaction history, groups it by category, and generates personalised monthly budget recommendations with plain-English explanations. You can accept, reject, or fine-tune each suggestion — the system learns from your feedback.
  2. Smarter Product Search Type any product — "wireless earbuds", "hiking boots", "coffee maker" — and the portal searches a multi-merchant catalog powered by Channel3. It returns ranked store cards with price ranges, PayPal compatibility, and AI-generated trade-off summaries so you shop smarter before you check out.
  3. Spending Intelligence Three analytical zones in one dashboard: • Zone 1 — Benchmarks your category spending against peers in the same age group and employment bracket. • Zone 2 — Tracks your month-over-month progress with live progress bars. • Zone 3 — Projects your spending trend six months forward using linear regression, displayed as interactive charts. All three features connect directly to a PayPal Sandbox checkout flow: create an order, approve it, capture it, and the transaction is instantly recorded in your verified ledger — with full idempotency so a double-click can never create a double charge.

How we built it

The project is a TypeScript monorepo with three packages: • Frontend — React 18 + Vite + Tailwind CSS. Single-page app styled to match PayPal's brand. Uses React Query for server-state management, Recharts for graphs, and AG Grid for the transactions ledger. All modals are rendered via createPortal so overlays cover the full viewport cleanly. • Backend — Node.js + Express REST API. Handles all business logic: transaction CRUD, budget recommendation engine, Channel3 product search, PayPal order creation and capture, and CSV import with formula-injection defence. Every endpoint is scoped to the authenticated user's token (Row Level Security), so two demo users share zero data. • Shared Contracts — A @spendwise/contracts package exports Zod schemas and a typed SDK client. The SDK wraps every API call with a 60-second AbortController timeout and strips empty query parameters before they reach the server, eliminating a class of validation errors entirely. • PayPal Integration — Full sandbox order lifecycle: POST /paypal/create-order → POST /paypal/capture-order → automatic ledger sync. Idempotency keys stored in-memory prevent duplicate captures. • Testing — 51 tests across three Vitest suites (financial calculator, API integration, comprehensive assessment). All 51 pass on every build.

Challenges we ran into

• Signal abort errors — The SDK's default 15-second timeout was too short for sandbox API calls under load. Traced it to the AbortController and fixed it by raising the timeout to 60 seconds with proper teardown. • Full-viewport modal overlay — Standard fixed inset-0 inside a scrollable container only covered part of the screen. Solved by switching to createPortal(modal, document.body) and locking document.body.style.overflow while the modal is open. • Universal product search — The initial search only matched a narrow product list. Rebuilt the Channel3 service with a universal keyword catalog so any product query returns relevant results regardless of category. • Empty query params failing validation — Sending ?categoryId=&query= to Zod's .min(1) check caused validation errors. Fixed by stripping empty strings in both the SDK client and the route handler before schema validation runs.

Accomplishments that we're proud of

• Full PayPal Sandbox checkout flow working end-to-end — create, approve, capture, ledger sync — with idempotency protection in under 400 ms per call. • 51/51 tests passing including financial calculation correctness, multi-user data isolation, and API contract validation. • A genuinely user-friendly interface: a first-time user can add a transaction, run a budget plan, search for a product, and simulate a PayPal payment in under two minutes with no instructions.

What we learned

• PayPal's Sandbox REST API is well-structured but requires careful idempotency handling at the application layer — it does not deduplicate on its own. • Sharing a Zod schema package between frontend and backend eliminates an entire category of type-mismatch bugs and makes refactoring significantly safer. • React Query's invalidateQueries pattern works perfectly for keeping the transactions ledger in sync after mutations without manual state management.

What's next for SmartWise AI

• Connect to live PayPal production credentials for real user payments. • Add Elasticsearch-powered transaction search for instant full-text lookup across large ledgers. • Extend the peer benchmarking data with an opt-in anonymised dataset to make the comparisons statistically meaningful. • Mobile app wrapper (React Native) so users get spending alerts and budget updates on the go.

Built With

Share this project:

Updates

Submission history