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
- Add income/expense with amount, category, date and note
- Monthly summary: income, spent, balance
- Pie chart by category and bar chart by month
- Budget per month with a warning at 80%
- Export to CSV
What you will learn
- Forms in React
- Derived data with useMemo
- Charts
- Date handling
- CSV export
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
- Login + MongoDB backend so data syncs across devices
- Recurring expenses
- Split bills with friends
On your resume
- Built an expense tracker in React with category/month analytics, Chart.js visualisations, budget alerts and CSV export.