A budget tracker
The problem
Build a React app that records income and expenses, shows the balance and the spending per category, and lets the user filter, edit and delete entries.
Requirements
- A form with controlled inputs for the description, amount, category and type (income or expense), with validation messages
- A list of entries with keys, each with edit and delete buttons
- The balance, the totals per category and a chart of bars drawn with divs, all computed from the entries
- Filters by type and category, and a search box
- The entries managed by a reducer, and the theme (light or dark) provided by context
Technologies
- React
- useReducer
- Context
- Controlled forms
Step by step
- Break the design into components and build a static version with sample data.
- Find the minimal state: the entries, the filters and the form's fields.
- Write the entries reducer with added, edited and deleted actions, and test it on its own.
- Add the form with validation and the filters, computing everything else during render.
- Add the theme context and a custom Hook for the form.
Expected result
A working budget app whose numbers always agree, because everything shown is computed from one list of entries.
How it is evaluated
- Totals and charts always match the entries
- Invalid input is explained and never saved
- No derived value is stored in state
- Components are small and each has one job
Ways to improve it
- Save the entries in localStorage with an effect
- Add monthly views and a date picker
- Rewrite it in TypeScript with typed actions