A complete full-stack web application to track your income, expenses, and visualize your spending habits with interactive charts and budget alerts. Built with Node.js, Express, MongoDB, and vanilla JavaScript.
- User Authentication: Secure registration and login with JWT tokens
- Add Income & Expenses: Record transactions with categories, amounts, descriptions, and dates
- Category Management: Pre-defined categories for income and expenses
- Monthly Dashboard: Visualize your spending with interactive charts
- Budget Alerts: Get notified when spending patterns need attention
- Multi-User Support: Each user has their own private data
- Data Persistence: All data stored securely in MongoDB database
- Pie Chart: See how your expenses are distributed across categories
- Bar Chart: Compare income vs expenses across the last 6 months
- Warns when a category exceeds 30% of total expenses
- Alerts when balance goes negative
- Notifies when expenses exceed income
- Reminds when remaining balance is low
- Node.js - Runtime environment
- Express.js - Web framework
- MongoDB - Database
- Mongoose - ODM for MongoDB
- JWT - Authentication tokens
- bcryptjs - Password hashing
- HTML5 - Structure
- CSS3 - Styling with modern design
- JavaScript (ES6+) - Application logic
- Chart.js - Data visualization
- Node.js (v14 or higher)
- MongoDB (local installation or MongoDB Atlas account)
- npm or yarn
cd webProjnpm installOption A: Local MongoDB
- Make sure MongoDB is installed and running
- Default connection:
mongodb://localhost:27017/expense-tracker
Option B: MongoDB Atlas (Cloud - Recommended)
- π Complete Step-by-Step Guide: See MONGODB_ATLAS_SETUP.md
- Create free account at mongodb.com/cloud/atlas
- Follow the detailed guide for setting up your cluster, user, and connection string
Create a .env file in the root directory:
PORT=5000
NODE_ENV=development
MONGODB_URI=mongodb://localhost:27017/expense-tracker
JWT_SECRET=your-super-secret-jwt-key-change-this-in-productionFor MongoDB Atlas (Cloud):
MONGODB_URI=mongodb+srv://username:password@cluster.mongodb.net/expense-tracker?retryWrites=true&w=majorityIf using local MongoDB:
# Windows
mongod
# macOS/Linux
sudo systemctl start mongod
# or
brew services start mongodb-community# Development mode (with auto-reload)
npm run dev
# Production mode
npm startThe server will run on http://localhost:5000
Open index.html in your web browser, or serve it through a local server.
Note: For production, you should serve the frontend files through the Express server or a web server like Nginx.
webProj/
βββ backend/
β βββ config/
β β βββ database.js # MongoDB connection
β βββ models/
β β βββ User.js # User model
β β βββ Transaction.js # Transaction model
β βββ middleware/
β β βββ auth.js # JWT authentication middleware
β βββ routes/
β β βββ auth.js # Authentication routes
β β βββ transactions.js # Transaction routes
β βββ server.js # Express server
βββ frontend/
β βββ index.html # Main HTML file
β βββ styles.css # Styles
β βββ app.js # Frontend JavaScript
βββ package.json # Dependencies
βββ .env # Environment variables (create this)
βββ README.md # This file
-
POST /api/auth/register- Register a new user{ "name": "John Doe", "email": "john@example.com", "password": "password123" } -
POST /api/auth/login- Login user{ "email": "john@example.com", "password": "password123" }
GET /api/transactions- Get all user transactionsGET /api/transactions/summary?month=0&year=2024- Get monthly summaryGET /api/transactions/monthly-comparison?month=0&year=2024- Get comparison dataPOST /api/transactions- Create a new transaction{ "type": "expense", "amount": 50.00, "category": "Food", "description": "Lunch", "date": "2024-01-15" }DELETE /api/transactions/:id- Delete a transaction
- Password hashing with bcryptjs
- JWT token-based authentication
- Protected API routes
- User data isolation (users can only access their own data)
- Input validation
- Register/Login: Create an account or login with existing credentials
- Add Transactions: Record your income and expenses
- View Dashboard: Check your monthly summary and charts
- Monitor Alerts: Review budget alerts and adjust spending
- Track Trends: Use charts to understand your financial patterns
- Set environment variables in your hosting platform
- Update
MONGODB_URIto your cloud database - Deploy the backend
- Option 1: Serve through Express (update server.js for production)
- Option 2: Deploy to Netlify, Vercel, or GitHub Pages
- Update
API_URLinapp.jsto point to your backend URL
- Ensure MongoDB is running locally, or
- Check your MongoDB Atlas connection string
- Verify network access for cloud databases
- The backend includes CORS middleware
- For production, configure allowed origins in
server.js
- Clear browser localStorage if tokens are corrupted
- Check JWT_SECRET in
.envfile
- Custom budget limits per category
- Recurring transactions
- Data export (CSV/PDF)
- Multiple currency support
- Dark mode
- Mobile app
- Email notifications
- Transaction search and filters
- Financial goals and savings tracking
This project is open source and available for personal and commercial use.
Contributions, issues, and feature requests are welcome!
Enjoy tracking your expenses and building better financial habits! π°