CodingIdeas.ai
← Browse All Ideas

Build Guide

How to Build an Expense Tracker

An expense tracker is the most-built personal finance app and the most-abandoned — because most devs skip automatic categorisation, the one feature users actually need.

Beginner3–5 days

Personal finance apps have some of the highest user retention of any category. Build one and you'll learn date handling, data visualisation, CSV parsing, and recurring transaction logic.

Data model

The core tables you'll need before writing any UI.

Userid, email, currency, monthly_budget
Categoryid, user_id, name, icon, color, budget_limit
Transactionid, user_id, category_id, amount, type (income/expense), description, date, recurring (bool), created_at

Build order

The sequence that minimises rewrites — build in this order.

1

Transaction list and add form

Build a list of transactions and a form to add one — amount, description, date, type (income/expense). Store in localStorage. No categories yet.

2

Categories and tagging

Add a categories table with name, icon, and color. Add a category selector to the add form. Seed 10 default categories (food, transport, bills, etc.).

3

Monthly summary cards

Calculate total income, total expenses, and net savings for the current month. Display as three KPI cards at the top of the dashboard. Filter by month using date range.

4

Charts

Add a donut chart (spending by category) and a bar chart (monthly spend trend over 6 months) using Recharts. Feed them aggregated data from your transactions array.

5

Budget limits and alerts

Add a budget_limit per category. On each transaction add, check if the category total for the month exceeds the limit. Show a warning banner if so.

6

CSV import

Add a file input that accepts CSV. Parse with PapaParse. Show a preview table of parsed rows. Let the user map columns (date, amount, description) before importing.

7

AI auto-categorisation

Send the transaction description to Claude Haiku with a list of your categories and ask it to pick the best one. Cache results by description hash to avoid repeat API calls.

Done when

Observable behaviors that confirm V1 is complete — verify each one before you ship.

  • User adds an expense and the monthly total KPI card updates immediately

  • Category donut chart reflects new expenses without a page refresh

  • CSV import with 10+ rows succeeds and assigns categories automatically via AI

  • Budget warning banner appears when spending exceeds a category limit

  • App opens with populated charts — no blank dashboard on first visit

First Run Requirement

Seed 20 demo transactions across 6 categories for the current month so all charts and KPI cards are populated immediately on first load. No manual data entry required.

Build it with AI — Architect Prompt

Paste this into Claude, Cursor, Windsurf, or any AI coding tool. It includes the full context of this guide — data model, build order, done conditions, and pitfalls — so the AI starts with everything it needs.

ClaudeCursorWindsurfCopilotGemini
architect-prompt.txt
<context>
App: Expense Tracker
Difficulty: Beginner
Estimated build time: 3–5 days
Tech stack (intermediate): Next.js + Supabase + Claude API for AI categorisation + Recharts

Data model:
  User: id, email, currency, monthly_budget
  Category: id, user_id, name, icon, color, budget_limit
  Transaction: id, user_id, category_id, amount, type (income/expense), description, date, recurring (bool), created_at

FIRST RUN REQUIREMENT:
Seed 20 demo transactions across 6 categories for the current month so all charts and KPI cards are populated immediately on first load. No manual data entry required.

DONE WHEN — verify each before marking V1 complete:
  □ User adds an expense and the monthly total KPI card updates immediately
  □ Category donut chart reflects new expenses without a page refresh
  □ CSV import with 10+ rows succeeds and assigns categories automatically via AI
  □ Budget warning banner appears when spending exceeds a category limit
  □ App opens with populated charts — no blank dashboard on first visit

Recommended build order:
  1. Define API contract + schema + seed data (always first)
  2. Transaction list and add form — Build a list of transactions and a form to add one — amount, description, date, type (income/expense). Store in localStorage. No categories yet.
  3. Categories and tagging — Add a categories table with name, icon, and color. Add a category selector to the add form. Seed 10 default categories (food, transport, bills, etc.).
  4. Monthly summary cards — Calculate total income, total expenses, and net savings for the current month. Display as three KPI cards at the top of the dashboard. Filter by month using date range.
  5. Charts — Add a donut chart (spending by category) and a bar chart (monthly spend trend over 6 months) using Recharts. Feed them aggregated data from your transactions array.
  6. Budget limits and alerts — Add a budget_limit per category. On each transaction add, check if the category total for the month exceeds the limit. Show a warning banner if so.
  7. CSV import — Add a file input that accepts CSV. Parse with PapaParse. Show a preview table of parsed rows. Let the user map columns (date, amount, description) before importing.
  8. AI auto-categorisation — Send the transaction description to Claude Haiku with a list of your categories and ask it to pick the best one. Cache results by description hash to avoid repeat API calls.
  9. End-to-end verification — walk every Done When condition above (always last)

Known pitfalls to avoid:
  - Using floats for money — 0.1 + 0.2 = 0.30000000000000004 in JavaScript. Store amounts as integers (cents) and divide by 100 for display only.
  - Ignoring timezone — a transaction at 11pm UTC might show as the next day for a user in New York. Store dates as date strings (YYYY-MM-DD), not timestamps, unless you need exact times.
  - Not handling negative amounts on CSV import — bank exports often use negative numbers for debits. Normalise to positive amounts with a type field on import.
</context>

<role>
You are a Senior Full-Stack Engineer and product architect who has shipped production Expense Trackers before. You know exactly where developers get stuck and how to structure the project to avoid rewrites.
</role>

<task id="step-1-clarify">
Before writing any code or spec, ask me 3–5 clarifying questions that will meaningfully change the architecture. Focus on: scale expectations, auth requirements, platform (web / mobile / both), must-have vs nice-to-have features for the MVP, and any hard constraints (budget, deadline, existing infrastructure).

<example>
BAD: "What tech stack do you want to use?" — too broad, doesn't change architecture decisions.
GOOD: "Do you need real-time sync across devices, or is single-device with periodic refresh acceptable? This decides whether we use WebSockets or simple REST polling and significantly affects infrastructure complexity."
</example>

⚠️ Do NOT start planning or writing code until I answer. Present the questions, then stop and wait.
</task>

<task id="step-2-architect">
After I answer your questions, produce the following in order:

1. TECHNICAL SPECIFICATION
   - System architecture using → to show data and event flow
   - Core data model (refer to data model in <context>)
   - API contract — list ALL routes with request/response shapes BEFORE any implementation
     WHY: agreeing on contracts first prevents rewrites when frontend and backend shapes diverge
   - External APIs and integration points

2. MVP PLAN in three phases:

   SETUP   ✦ Step 1 (always): API contract + schema migration + seed data
     Done when: schema is migrated, seed script runs, app starts with demo data, zero manual setup.

   CORE FEATURES — build in this exact order:
   2. Transaction list and add form
   3. Categories and tagging
   4. Monthly summary cards
   5. Charts
   6. Budget limits and alerts
   7. CSV import
   8. AI auto-categorisation

   DONE WHEN — one observable condition per feature:
   □ User adds an expense and the monthly total KPI card updates immediately
   □ Category donut chart reflects new expenses without a page refresh
   □ CSV import with 10+ rows succeeds and assigns categories automatically via AI
   □ Budget warning banner appears when spending exceeds a category limit
   □ App opens with populated charts — no blank dashboard on first visit

   STRETCH GOALS — post-launch additions that are explicitly out of V1 scope.

3. BLOCKER ANALYSIS
   Flag: API rate limits, auth complexity, scope risks, cold-start problems, top 2–3 failure modes.

   FIRST RUN REQUIREMENT: Seed 20 demo transactions across 6 categories for the current month so all charts and KPI cards are populated immediately on first load. No manual data entry required.
   ✓ Done when: app launches with seed data and the full user journey works without any manual setup.

<self_check>
Before presenting your output, verify:
□ Every answer I gave to clarifying questions is reflected in the spec
□ Step 1 is ALWAYS: API contract + schema + seed — never UI first
□ Done When criteria are observable user behaviors, not internal states
□ The plan is realistic for one person to ship within 3–5 days
□ All known pitfalls from <context> are addressed in the spec
</self_check>
</task>

<task id="step-2.5-agents-md">
Generate an AGENTS.md file at the project root. This file is read automatically by Claude Code, Cursor, Windsurf, and all major AI coding tools at the start of every session.

Include:
- Project overview (2–3 sentences)
- Tech stack with exact version numbers
- Folder structure with one-line descriptions per directory
- Key architectural decisions and the WHY behind each
- Coding conventions: camelCase components, kebab-case files, max 200 lines per file, one concern per file
- Available commands: dev, build, test, lint, db:migrate, db:seed
- MVP scope boundaries — features explicitly out of V1

Note in the file: "Cursor users: symlink .cursorrules → AGENTS.md. Claude Code users: symlink CLAUDE.md → AGENTS.md."
</task>

<task id="step-3-implement">
Implement the full project in the exact order from step 2. For each step:
- Write complete code (no placeholders or TODOs)
- Confirm the step works before moving to the next

<constraints>
- Step 1 is ALWAYS: define all API routes + TypeScript request/response interfaces + run schema migration
  WHY: agreeing on contracts before writing a single component prevents shape mismatches that require rewrites
- Final step is ALWAYS: start the app and walk every Done When condition from <context> end-to-end
  WHY: a spec that passes unit tests but breaks the core user journey is not done
- Max 200 lines per file. WHY: every file must fit in one AI context window for complete reasoning
- One concern per file. WHY: mixing auth logic into API routes makes it impossible to reuse — extract to lib/auth.ts
- TypeScript strict mode, no `any` types. WHY: catches data shape mismatches at compile time, not in production
- All database queries in server components or API routes only. WHY: keeps credentials server-side
- All environment variables documented in .env.example. WHY: next developer sets up in under 5 minutes
</constraints>
</task>

How to use this prompt

  1. 1.Copy the prompt above
  2. 2.Open Claude, Cursor (Cmd+L), or Windsurf
  3. 3.Paste the prompt and send — the AI will ask 3–5 clarifying questions
  4. 4.Answer the questions, then it generates your full project spec
  5. 5.Continue in the same session to implement step by step

Common mistakes

What trips up most developers building this for the first time.

⚠️

Using floats for money — 0.1 + 0.2 = 0.30000000000000004 in JavaScript. Store amounts as integers (cents) and divide by 100 for display only.

⚠️

Ignoring timezone — a transaction at 11pm UTC might show as the next day for a user in New York. Store dates as date strings (YYYY-MM-DD), not timestamps, unless you need exact times.

⚠️

Not handling negative amounts on CSV import — bank exports often use negative numbers for debits. Normalise to positive amounts with a type field on import.

Recommended tech stack

Pick the level that matches your experience.

Beginner

React + Chart.js + localStorage — charts working in a day, no backend

Intermediate

Next.js + Supabase + Claude API for AI categorisation + Recharts

Advanced

Next.js + Plaid API (bank sync) + Supabase + Stripe — full fintech stack

Take it further — related ideas

Each comes with revenue math, a full build guide, and a prompt to paste into Claude or Cursor.