A modern React frontend application for budget tracking that integrates with the FastAPI backend. Built with React 18, TypeScript, Tailwind CSS, and React Query for optimal performance and user experience.
- Authentication System: JWT-based authentication with automatic token refresh
- Dashboard: Financial overview with real-time stats and charts
- Transaction Management: Add, edit, and categorize transactions
- Budget Planning: Create and track budgets with progress visualization
- Category Management: Organize transactions with custom categories
- Responsive Design: Mobile-first design that works on all devices
- Data Visualization: Interactive charts and graphs for financial insights
- Real-time Updates: Optimistic updates for better user experience
- React 18 - Modern React with hooks and concurrent features
- TypeScript - Type-safe development
- Vite - Fast build tool and development server
- Tailwind CSS - Utility-first CSS framework
- React Router - Client-side routing
- React Hook Form - Performant forms with easy validation
- Zod - Schema validation
- Axios - HTTP client with interceptors
- Chart.js - Data visualization
- Lucide React - Beautiful SVG icons
- Node.js 16+
- npm or yarn
- Budget Tracker Backend API running (see backend README)
-
Clone the repository
git clone <repository-url> cd budget-tracker-frontend
-
Install dependencies
npm install # or yarn install -
Set up environment variables
cp .env.example .env.development
Update the environment variables in
.env.development:VITE_API_BASE_URL=http://localhost:8000 VITE_APP_NAME=Budget Tracker VITE_APP_VERSION=1.0.0 VITE_DEV_MODE=true
-
Start the development server
npm run dev # or yarn dev -
Open your browser Navigate to
http://localhost:3000 -
API Integration Make sure the FastAPI backend is running on
http://localhost:8000(or update theVITE_API_BASE_URLin your environment file)
-
Build the application
npm run build # or yarn build -
Preview the production build
npm run preview # or yarn preview
The built files will be in the dist/ directory.
src/
├── components/ # Reusable UI components
│ ├── ui/ # Basic UI components (Button, Input, etc.)
│ ├── forms/ # Form components
│ └── layout/ # Layout components (Navbar, Layout, etc.)
├── pages/ # Page components
├── hooks/ # Custom React hooks
├── services/ # API integration services
├── contexts/ # React contexts (Auth, etc.)
├── utils/ # Utility functions and constants
├── types/ # TypeScript type definitions
└── styles/ # CSS and styling files
- AuthContext: Global authentication state management
- ProtectedRoute: Route protection for authenticated users
- LoginForm/RegisterForm: Authentication forms with validation
- apiClient: Axios instance with request/response interceptors
- Service files: Organized API calls by domain (auth, transactions, etc.)
- Automatic token refresh: Seamless token renewal without user interruption
- Responsive design: Mobile-first approach with Tailwind CSS
- Accessible components: ARIA labels and keyboard navigation
- Loading states: Skeleton screens and loading indicators
- Error handling: User-friendly error messages and recovery
- Dashboard charts: Income/expense trends and category breakdowns
- Budget progress: Visual progress bars and alerts
- Real-time updates: Optimistic UI updates for better UX
| Variable | Description | Default |
|---|---|---|
VITE_API_BASE_URL |
Backend API URL | http://localhost:8000 |
VITE_APP_NAME |
Application name | Budget Tracker |
VITE_APP_VERSION |
Application version | 1.0.0 |
VITE_DEV_MODE |
Development mode flag | true |
| Command | Description |
|---|---|
npm run dev |
Start development server |
npm run build |
Build for production |
npm run preview |
Preview production build |
npm run lint |
Run ESLint |
npm run type-check |
Run TypeScript type checking |
The frontend integrates with the FastAPI backend through these endpoints:
POST /auth/login- User loginPOST /auth/register- User registrationPOST /auth/refresh- Token refreshPOST /auth/logout- User logout
GET /transactions/- List transactionsPOST /transactions/- Create transactionPUT /transactions/{id}- Update transactionDELETE /transactions/{id}- Delete transaction
GET /categories/- List categoriesPOST /categories/- Create categoryPUT /categories/{id}- Update categoryDELETE /categories/{id}- Delete category
GET /budgets/- List budgetsPOST /budgets/- Create budgetPUT /budgets/{id}- Update budgetDELETE /budgets/{id}- Delete budgetGET /budgets/progress- Get budget progress
- JWT Authentication: Secure token-based authentication
- Automatic Token Refresh: Seamless session renewal
- Protected Routes: Route-level authentication guards
- CSRF Protection: Request validation
- Input Validation: Client and server-side validation
- Error Handling: Secure error messages
- Code Splitting: Lazy loading of routes and components
- Bundle Optimization: Tree shaking and minification
- Caching: API response caching and optimistic updates
- Image Optimization: Responsive images and lazy loading
- Memoization: React.memo and useMemo for expensive operations
- ARIA Labels: Screen reader support
- Keyboard Navigation: Full keyboard accessibility
- Color Contrast: WCAG compliant color schemes
- Focus Management: Proper focus indicators
- Semantic HTML: Meaningful HTML structure
- Modern Browsers: Chrome, Firefox, Safari, Edge (last 2 versions)
- Mobile Browsers: iOS Safari, Chrome Mobile
- ES2020 Support: Modern JavaScript features
- Fork the repository
- Create a feature branch:
git checkout -b feature/amazing-feature - Commit your changes:
git commit -m 'Add amazing feature' - Push to the branch:
git push origin feature/amazing-feature - Open a Pull Request
- Connect your GitHub repository to Vercel
- Set environment variables in Vercel dashboard
- Deploy automatically on push to main branch
- Connect your GitHub repository to Netlify
- Set build command:
npm run build - Set publish directory:
dist - Configure environment variables
FROM node:18-alpine as build
WORKDIR /app
COPY package*.json ./
RUN npm ci
COPY . .
RUN npm run build
FROM nginx:alpine
COPY --from=build /app/dist /usr/share/nginx/html
COPY nginx.conf /etc/nginx/nginx.conf
EXPOSE 80
CMD ["nginx", "-g", "daemon off;"]-
API Connection Issues
- Check if backend is running
- Verify
VITE_API_BASE_URLis correct - Check CORS settings in backend
-
Authentication Problems
- Clear localStorage and cookies
- Check token expiration
- Verify backend auth endpoints
-
Build Issues
- Clear node_modules and reinstall
- Check Node.js version compatibility
- Verify environment variables
- React Developer Tools: Browser extension for React debugging
- Redux DevTools: State management debugging
- Network Tab: Monitor API requests
- Console Logs: Check for JavaScript errors
This project is licensed under the MIT License - see the LICENSE file for details.
For support and questions:
- Create an issue in the GitHub repository
- Check the troubleshooting section
- Review the API documentation