A comprehensive, full-stack personal finance management application built with the MERN stack (MongoDB, Express.js, React, Node.js). This application provides users with powerful tools to track expenses, manage income, visualize financial data, and gain insights into their spending habits through beautiful charts and analytics.
The MERN Fullstack Expense Tracker is designed to help individuals take control of their personal finances through:
- Comprehensive Expense Tracking: Categorize and monitor all your expenses with detailed analytics
- Income Management: Track multiple income sources and analyze earning patterns
- Visual Analytics: Beautiful charts and graphs powered by Recharts for data visualization
- Secure Authentication: JWT-based authentication system with profile management
- Real-time Updates: Live data synchronization across all devices
- Export Capabilities: Download financial data as Excel files for external analysis
- Responsive Design: Works seamlessly across desktop, tablet, and mobile devices
π View Live Application (Coming Soon)
- Secure user registration and login system
- JWT-based authentication with token refresh
- Password encryption using bcrypt
- Protected routes and middleware
- User profile management with image upload
- Account deletion with data cleanup
- Add, edit, and delete expense entries
- Categorize expenses with custom categories
- Emoji-based category icons for visual appeal
- Date-based expense filtering and sorting
- Bulk operations for managing multiple expenses
- Excel export functionality for expense data
- Multiple income source tracking
- Income categorization and organization
- Monthly and yearly income analysis
- Visual income distribution charts
- Income vs expense comparison tools
- Comprehensive income reporting
- Interactive pie charts for expense distribution
- Bar charts for monthly/yearly trends
- Line charts for spending patterns over time
- Financial overview with balance calculations
- Recent transactions display
- Custom date range analytics
- Modern, clean interface design
- Responsive mobile-first design
- Real-time toast notifications
- Smooth animations and transitions
- Intuitive navigation and user flow
- Dark/light theme support (planned)
- Secure cloud data storage
- Real-time data synchronization
- Data export capabilities
- Backup and restore functionality
- Data visualization export
- Node.js - JavaScript runtime environment
- Express.js 5.1.0 - Web application framework
- MongoDB - NoSQL database for data storage
- Mongoose 8.17.0 - MongoDB object modeling
- JWT - JSON Web Tokens for authentication
- bcryptjs - Password hashing and security
- Multer - File upload handling
- CORS - Cross-origin resource sharing
- dotenv - Environment variable management
- React 19.1.0 - User interface library
- Vite 7.0.4 - Build tool and development server
- React Router DOM 7.7.1 - Client-side routing
- Tailwind CSS 4.1.11 - Utility-first CSS framework
- Axios 1.11.0 - HTTP client for API requests
- Recharts 3.1.0 - Data visualization library
- React Hot Toast - Toast notifications
- Emoji Picker React - Emoji selection component
- Moment.js - Date manipulation and formatting
- ESLint - Code linting and quality assurance
- Prettier - Code formatting
- Nodemon - Development server auto-restart
- Concurrently - Run multiple scripts simultaneously
Fullstack-MERN-Expense-Tracker/
βββ BackEnd/ # Backend API Server
β βββ config/
β β βββ db.js # MongoDB connection
β βββ controllers/
β β βββ authController.js # Authentication logic
β β βββ dashboardController.js # Dashboard data
β β βββ expenseController.js # Expense operations
β β βββ incomeController.js # Income operations
β βββ middleware/
β β βββ authMiddleware.js # JWT verification
β β βββ uploadMiddleware.js # File upload handling
β βββ models/
β β βββ User.js # User data model
β β βββ Expense.js # Expense data model
β β βββ Income.js # Income data model
β βββ routes/
β β βββ authRoutes.js # Authentication endpoints
β β βββ dashboardRoutes.js # Dashboard endpoints
β β βββ expenseRoutes.js # Expense endpoints
β β βββ incomeRoutes.js # Income endpoints
β βββ uploads/ # User uploaded files
β βββ server.js # Main server file
β βββ package.json # Backend dependencies
β βββ README.md # Backend documentation
βββ FrontEnd/ # React Frontend Application
β βββ public/
β β βββ vite.svg # App favicon
β βββ src/
β β βββ assets/ # Static assets
β β βββ components/ # React components
β β β βββ Cards/ # Card components
β β β βββ Charts/ # Chart components
β β β βββ Dashboard/ # Dashboard components
β β β βββ Expense/ # Expense components
β β β βββ Income/ # Income components
β β β βββ Inputs/ # Form input components
β β β βββ layouts/ # Layout components
β β β βββ Profile/ # Profile components
β β βββ context/ # React Context providers
β β βββ hooks/ # Custom React hooks
β β βββ pages/ # Page components
β β β βββ Auth/ # Authentication pages
β β β βββ Dashboard/ # Dashboard pages
β β βββ utils/ # Utility functions
β β βββ App.jsx # Main App component
β β βββ main.jsx # App entry point
β β βββ index.css # Global styles
β βββ package.json # Frontend dependencies
β βββ vite.config.js # Vite configuration
β βββ README.md # Frontend documentation
βββ screenshots/ # Application screenshots
βββ LICENSE # MIT License
βββ README.md # This file
Before you begin, ensure you have the following installed:
- Node.js (v18 or higher) - Download here
- MongoDB (local installation or MongoDB Atlas account) - Setup guide
- Git - Download here
- npm or yarn package manager
git clone https://github.com/NhanPhamThanh-IT/Fullstack-MERN-Expense-Tracker.git
cd Fullstack-MERN-Expense-Tracker# Navigate to backend directory
cd BackEnd
# Install backend dependencies
npm install
# Create environment file
cp .env.example .env
# Configure your environment variables in .env file
# MONGO_URI=mongodb://localhost:27017/expense-tracker
# JWT_SECRET=your-super-secret-jwt-key
# PORT=5000
# CLIENT_URL=http://localhost:5173
# Start the backend server
npm run dev# Open a new terminal and navigate to frontend directory
cd FrontEnd
# Install frontend dependencies
npm install
# Update API base URL in src/utils/apiPaths.js if needed
# export const BASE_URL = "http://localhost:5000";
# Start the frontend development server
npm run dev- Frontend: Open http://localhost:5173 in your browser
- Backend API: Backend server runs on http://localhost:5000
# Install MongoDB Community Edition
# Start MongoDB service
mongod
# The application will connect to mongodb://localhost:27017/expense-tracker- Create a free MongoDB Atlas account
- Create a new cluster
- Get your connection string
- Update
MONGO_URIin your.envfile
# Database Configuration
MONGO_URI=mongodb://localhost:27017/expense-tracker
# or for MongoDB Atlas:
# MONGO_URI=mongodb+srv://username:password@cluster.mongodb.net/expense-tracker
# JWT Configuration
JWT_SECRET=your-super-secret-jwt-key-minimum-32-characters-long
# Server Configuration
PORT=5000
NODE_ENV=development
# Client Configuration (CORS)
CLIENT_URL=http://localhost:5173Update API endpoints in FrontEnd/src/utils/apiPaths.js:
export const BASE_URL =
process.env.NODE_ENV === "production"
? "https://your-production-api.com"
: "http://localhost:5000";For detailed information about each part of the application, please refer to the respective README files:
Comprehensive guide covering:
- API endpoints and authentication
- Database models and relationships
- Server configuration and middleware
- Security implementation
- Deployment instructions
- Testing and development workflow
Detailed documentation including:
- Component architecture and design system
- State management and routing
- UI/UX implementation details
- Responsive design approach
- Performance optimization
- Build and deployment process
POST /api/v1/auth/register # User registration
POST /api/v1/auth/login # User login
GET /api/v1/auth/getUser # Get user profile
POST /api/v1/auth/upload-image # Profile image upload
DELETE /api/v1/auth/deleteAccount # Delete user accountGET /api/v1/expense/get # Get all expenses
POST /api/v1/expense/add # Create new expense
PUT /api/v1/expense/:id # Update expense
DELETE /api/v1/expense/:id # Delete expense
GET /api/v1/expense/downloadexcel # Export expensesGET /api/v1/income/get # Get all income
POST /api/v1/income/add # Create new income
PUT /api/v1/income/:id # Update income
DELETE /api/v1/income/:id # Delete income
GET /api/v1/income/downloadexcel # Export incomeGET /api/v1/dashboard # Get dashboard data
GET /api/v1/dashboard/overview # Financial overview
GET /api/v1/dashboard/analytics # Advanced analytics- Minimalist Design: Clean, uncluttered interface focused on usability
- Consistent Typography: Poppins font family for modern, readable text
- Color Psychology: Purple primary color for trust, green for income, red for expenses
- Responsive Layout: Mobile-first approach with Tailwind CSS utilities
- Hover Effects: Subtle animations on buttons and cards
- Loading States: Skeleton screens and loading indicators
- Toast Notifications: Real-time feedback for user actions
- Modal Dialogs: Confirmation dialogs for destructive actions
- Form Validation: Real-time input validation with error messages
- Keyboard Navigation: Full keyboard accessibility support
- Screen Reader Support: Proper ARIA labels and semantic HTML
- Color Contrast: WCAG-compliant color contrast ratios
- Focus Indicators: Clear focus states for interactive elements
- Password Hashing: bcrypt with salt rounds for secure password storage
- JWT Authentication: Secure token-based authentication system
- Input Validation: Server-side validation for all API endpoints
- CORS Protection: Configured CORS policy for frontend integration
- Rate Limiting: Protection against brute force attacks (planned)
- Data Sanitization: Protection against injection attacks
- Token Management: Secure JWT token storage and automatic renewal
- Input Sanitization: Client-side input validation and sanitization
- HTTPS Enforcement: Secure communication in production
- Environment Variables: Sensitive data stored in environment variables
- Content Security Policy: CSP headers for XSS protection (planned)
- Database Indexing: Optimized MongoDB indexes for fast queries
- Connection Pooling: Efficient database connection management
- Middleware Optimization: Lightweight middleware for request processing
- Caching Strategy: Planned Redis integration for session caching
- API Rate Limiting: Planned rate limiting for API protection
- Code Splitting: Automatic route-based code splitting with Vite
- Tree Shaking: Elimination of unused code in production builds
- Asset Optimization: Optimized images and static assets
- Lazy Loading: Component lazy loading for improved load times
- Bundle Analysis: Regular bundle size monitoring and optimization
- Unit Tests: Individual controller and middleware testing
- Integration Tests: API endpoint testing with supertest
- Database Tests: MongoDB integration testing
- Authentication Tests: JWT token validation testing
- Component Tests: React component testing with React Testing Library
- Integration Tests: User flow testing with Cypress
- Visual Regression Tests: UI consistency testing
- Performance Tests: Core Web Vitals monitoring
# Install Heroku CLI and login
heroku login
# Create new Heroku app
heroku create your-expense-tracker-api
# Set environment variables
heroku config:set JWT_SECRET=your-secret
heroku config:set MONGO_URI=your-mongodb-uri
# Deploy
git push heroku main- Connect your GitHub repository
- Set environment variables in Railway dashboard
- Automatic deployments on git push
- Connect repository and configure build settings
- Set environment variables
- Automatic deployments with custom domains
# Install Vercel CLI
npm i -g vercel
# Deploy from frontend directory
cd FrontEnd
vercel --prod- Connect GitHub repository
- Set build command:
npm run build - Set publish directory:
dist
- Use GitHub Actions for automated deployment
- Configure custom domain if needed
- Backend deployed and accessible
- Environment variables configured
- Database connection established
- Frontend built and deployed
- API endpoints updated in frontend
- CORS configured for production domain
- SSL certificates configured
- Custom domain configured (optional)
- Monitoring and error tracking setup
# Clone and setup
git clone https://github.com/NhanPhamThanh-IT/Fullstack-MERN-Expense-Tracker.git
cd Fullstack-MERN-Expense-Tracker
# Install dependencies for both backend and frontend
cd BackEnd && npm install
cd ../FrontEnd && npm install
# Start development servers (use two terminals)
# Terminal 1 - Backend
cd BackEnd && npm run dev
# Terminal 2 - Frontend
cd FrontEnd && npm run dev# Backend development
npm run dev # Start development server with nodemon
npm start # Start production server
npm run lint # Run ESLint
# Frontend development
npm run dev # Start Vite dev server
npm run build # Build for production
npm run preview # Preview production build
npm run lint # Run ESLint# Create feature branch
git checkout -b feature/new-feature
# Make changes and commit
git add .
git commit -m "feat: add new feature"
# Push and create pull request
git push origin feature/new-featureWe welcome contributions from the community! Here's how you can help:
- π Bug Reports: Found a bug? Open an issue with detailed reproduction steps
- π‘ Feature Requests: Have an idea? Create a feature request issue
- π§ Code Contributions: Submit pull requests for bug fixes or new features
- π Documentation: Help improve documentation and examples
- π¨ Design: Contribute to UI/UX improvements
- π§ͺ Testing: Help write tests and improve test coverage
- Fork the repository
- Clone your fork locally
- Create a feature branch (
git checkout -b feature/amazing-feature) - Make your changes with clear, descriptive commits
- Test your changes thoroughly
- Update documentation if necessary
- Submit a pull request with a clear description
- Follow existing code style and conventions
- Write clear, descriptive commit messages
- Add comments for complex logic
- Ensure responsive design compatibility
- Test on multiple browsers and devices
- Update documentation for new features
- Backend: Follow Node.js best practices and Express.js conventions
- Frontend: Use React best practices with functional components and hooks
- CSS: Utilize Tailwind CSS utility classes consistently
- JavaScript: Use ES6+ features and async/await for promises
- Advanced Analytics: Spending trends, budget forecasting, financial insights
- Budget Management: Set monthly budgets with alerts and tracking
- Recurring Transactions: Automated recurring income and expense entries
- Data Export: Multiple export formats (PDF, CSV, JSON)
- Search & Filtering: Advanced search and filtering capabilities
- Dark Theme: Complete dark mode implementation
- Multi-language Support: Internationalization (i18n)
- Notification System: Email notifications for budgets and goals
- Goal Setting: Financial goals with progress tracking
- Category Management: Custom categories with icons and colors
- Multi-currency Support: Handle multiple currencies with exchange rates
- Bank Integration: Connect bank accounts for automatic transaction import
- Sharing & Collaboration: Share expenses with family or roommates
- Mobile App: React Native mobile application
- Offline Support: Progressive Web App with offline capabilities
- Team Accounts: Business expense tracking for teams
- Advanced Reporting: Custom reports and analytics
- API Access: Public API for third-party integrations
- White-label Solution: Customizable branding for businesses
- Advanced Security: Two-factor authentication, audit logs
Issue: MongoDB connection error
Error: MongoNetworkError: failed to connect to serverSolution:
- Ensure MongoDB is running locally
- Check your MongoDB URI in
.envfile - Verify network connectivity for MongoDB Atlas
Issue: JWT token errors
Error: jwt malformedSolution:
- Check JWT_SECRET in environment variables
- Ensure token is properly formatted
- Verify token expiration
Issue: API connection error
Error: Network ErrorSolution:
- Verify backend server is running
- Check API base URL in
apiPaths.js - Ensure CORS is configured properly
Issue: Charts not rendering
Error: Cannot read property 'map' of undefinedSolution:
- Check data format passed to chart components
- Ensure data is loaded before rendering charts
- Verify chart component props
Issue: Port already in use
Error: listen EADDRINUSE: address already in use :::5000Solution:
# Find process using the port
lsof -i :5000
# Kill the process
kill -9 <PID>
# Or use different port in .env file- π Check the Backend README for backend-specific issues
- π Check the Frontend README for frontend-specific issues
- π Create an issue on GitHub with detailed error information
- π¬ Join our community discussions for help and support
This project is licensed under the MIT License - see the LICENSE file for details.
- β Commercial Use: Use for commercial projects
- β Modification: Modify the source code
- β Distribution: Distribute the software
- β Private Use: Use for private projects
- β Liability: Software provided "as is"
- β Warranty: No warranty provided
Nhan Pham Thanh
- π GitHub: @NhanPhamThanh-IT
- πΌ LinkedIn: [Your LinkedIn Profile]
- π Portfolio: [Your Portfolio Website]
- π§ Email: [your.email@example.com]
- MERN Stack Community for the amazing ecosystem
- Tailwind CSS for the utility-first CSS framework
- Recharts for beautiful data visualization components
- React Community for the excellent React ecosystem
- MongoDB for the flexible NoSQL database solution
- Open Source Community for countless examples and solutions
- Stack Overflow for troubleshooting and learning
- MDN Web Docs for web standards and best practices
- React Documentation for excellent learning resources
- All contributors who help improve this project
- Users who provide feedback and bug reports
- Open source maintainers who make development possible
- The developer community for sharing knowledge and tools
- π Documentation: Start with this README and component documentation
- π Bug Reports: Create detailed issues on GitHub
- π‘ Feature Requests: Share your ideas through GitHub issues
- β Questions: Use GitHub Discussions for general questions
- Be respectful and constructive in all interactions
- Provide detailed information when reporting issues
- Search existing issues before creating new ones
- Help others when you can share knowledge
- Follow the code of conduct in all community spaces
- β Star the repository to show support
- π Watch for updates and new releases
- π Subscribe to release notifications
- π¦ Follow on social media for updates
| Resource | Link | Description |
|---|---|---|
| π Live Demo | [Coming Soon] | Try the application online |
| π Backend Docs | Backend README | API documentation and setup |
| π Frontend Docs | Frontend README | UI components and configuration |
| π Issues | GitHub Issues | Bug reports and feature requests |
| π¬ Discussions | GitHub Discussions | Community Q&A and ideas |
| π Project Board | GitHub Projects | Development roadmap |
Built with β€οΈ using the MERN Stack