Getting everything ready for you…

Loading courses, problems and your progress. This takes just a moment.

0s

Projects › Beginner

Expense Tracker with Charts

Track income and expenses by category and month, with charts and a monthly budget alert.

Level: Beginner · Time: 4–6 days · Tech stack: React, Chart.js, localStorage

Features to build

What you will learn

Step-by-step guide

1. Data shape

{ id, type: 'expense' | 'income', amount: 450, category: 'Food', date: '2026-10-21', note: 'Dinner' }

Store amounts as numbers (paise if you want to avoid decimals).

2. The form

Controlled inputs, validation (amount > 0, date not empty), and reset after adding.

3. Derive, don't store

Totals, category sums and monthly sums are computed from the list:

const monthItems = useMemo(() => items.filter(i => i.date.startsWith(month)), [items, month]);
const byCategory = useMemo(() => monthItems.filter(i => i.type === 'expense')
  .reduce((m, i) => ({ ...m, [i.category]: (m[i.category] || 0) + i.amount }), {}), [monthItems]);

4. Charts

Install chart.js react-chartjs-2; pass Object.keys(byCategory) as labels and the values as data for a Pie chart.

5. Budget alert

If spent / budget >= 0.8, show a yellow banner; above 100%, red.

6. Export CSV

Build "date,type,category,amount,note\n" + rows, create a Blob and download it with a temporary <a download>.

Level it up

On your resume

Learn on Codify