A modern, responsive expense tracking application built with vanilla JavaScript, featuring comprehensive form validation, error handling, and a clean user interface.
- π Expense Management: Add, edit, and track expenses with detailed form validation
- π± Responsive Design: Works seamlessly on desktop and mobile devices
- π Form Validation: Real-time validation with user-friendly error messages
- β‘ Loading States: Visual feedback during form submission
- π¨ Modern UI: Clean, intuitive interface with gradient backgrounds and animations
- βΏ Accessibility: ARIA labels, keyboard navigation, and screen reader support
- π§ͺ Comprehensive Testing: 21/21 passing tests for the ExpenseForm component
- Node.js (version 16 or higher)
- npm (comes with Node.js)
-
Clone the repository
git clone https://github.com/Chan-Nyein21/Expense-Tracker.git cd expense-tracker -
Install dependencies
npm install
-
Start the development server
npm run dev
-
Open your browser
- Navigate to
http://localhost:5173 - The application will automatically reload when you make changes
- Navigate to
npm run dev # Start development server
npm run build # Build for production
npm run preview # Preview production build locallynpm test # Run all tests
npm run test:watch # Run tests in watch mode
npm run test:coverage # Generate test coverage reportnpm run lint # Run ESLint
npm run lint:fix # Fix ESLint issues automatically
npm run format # Format code with Prettiernpm run test:e2e # Open Cypress test runner
npm run test:e2e:headless # Run Cypress tests headlesslyexpense-tracker/
βββ src/
β βββ components/
β β βββ Component.js # Base component class
β β βββ ExpenseForm.js # Main expense form component
β βββ models/
β β βββ Expense.js # Expense data model
β βββ services/
β β βββ StorageService.js # Local storage management
β βββ utils/
β β βββ currency.js # Currency formatting utilities
β β βββ date.js # Date formatting utilities
β β βββ validation.js # Form validation utilities
β βββ styles/
β β βββ main.css # Main application styles
β β βββ design-system.css # Design system variables
β βββ main.js # Application entry point
βββ tests/
β βββ contract/ # Contract tests
β βββ unit/ # Unit tests
βββ public/ # Static assets
βββ index.html # Main HTML file
βββ package.json # Dependencies and scripts
βββ vite.config.js # Vite configuration
βββ jest.config.js # Jest test configuration
The project includes comprehensive testing with a focus on the ExpenseForm component:
# Run all tests
npm test
# Run specific test file
npm test tests/contract/expense-form.test.js
# Run tests with coverage
npm run test:coverage
# Run tests in watch mode (for development)
npm run test:watch- Contract Tests: Ensure components meet their interface requirements
- Unit Tests: Test individual functions and utilities
- Validation Tests: Comprehensive form validation testing
- β ExpenseForm Component: 21/21 tests passing
- β Validation Utilities: 53/53 tests passing
-
Fill out the form:
- Enter the amount (required, must be positive)
- Add a description (required, max 255 characters)
- Select a date (required, cannot be future date)
- Choose a category from the dropdown
-
Submit the form:
- Click "Add Expense" button
- Form will show loading state during submission
- Success notification will appear
- Form will clear automatically
The application includes comprehensive validation:
- Amount: Must be a positive number, supports decimals
- Description: Required, maximum 255 characters
- Date: Required, cannot be a future date
- Category: Must select from available categories
- Real-time validation: Errors appear as you type
- User-friendly messages: Clear, actionable error descriptions
- Visual feedback: Error states with appropriate styling
- Accessibility: Errors announced to screen readers
The application uses Vite for development with the following configuration:
- Port: 5173 (configurable in
vite.config.js) - Hot Module Replacement: Enabled for instant updates
- Source Maps: Enabled for debugging
Production builds are optimized with:
- Code splitting: Automatic chunking for better performance
- Minification: Terser for JavaScript compression
- Tree shaking: Removes unused code
- Asset optimization: Optimized images and CSS
- Modern Browsers: Chrome 90+, Firefox 88+, Safari 14+, Edge 90+
- Mobile Browsers: iOS Safari 14+, Chrome Mobile 90+
- ES Modules: Required (all modern browsers support this)
This project follows:
- ESLint: For code linting and style consistency
- Prettier: For code formatting
- Conventional Commits: For commit message formatting
- Component-based: Modular, reusable components
- Event-driven: Components communicate through events
- Separation of concerns: Clear separation between data, logic, and presentation
- Progressive enhancement: Works without JavaScript (basic functionality)
- None (vanilla JavaScript implementation)
- Vite: Build tool and development server
- Jest: Testing framework
- ESLint: Code linting
- Prettier: Code formatting
- Cypress: End-to-end testing
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Make your changes
- Run tests (
npm test) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
- Write tests for new features
- Follow the existing code style
- Update documentation as needed
- Ensure all tests pass before submitting
This project is licensed under the MIT License - see the LICENSE file for details.
- Built with vanilla JavaScript for maximum compatibility
- Tested with Jest for reliability
- Styled with modern CSS for a clean interface
- Developed with accessibility in mind
If you encounter any issues or have questions:
- Check the Issues page
- Create a new issue with detailed information
- Include steps to reproduce any bugs
Happy expense tracking! π°