A super simple expense tracker for beginners. Track your daily expenses in INR (₹).
Built with: Node.js + Express + PostgreSQL + Bootstrap
Try it live: http://13.201.76.0:3000/
The application is currently running on AWS EC2 in the Mumbai region (ap-south-1). Experience the full-stack expense tracker in action!
- Node.js - Download here (Get the LTS version)
- PostgreSQL - Download here
That's it!
Download this project or clone it:
git clone https://github.com/ObaidAbdullah16/expense-tracker.git
cd expense-trackerOpen terminal/command prompt in the project folder and run:
npm install- Open PostgreSQL (pgAdmin or command line)
- Run these commands one by one:
CREATE DATABASE expense_tracker;- Connect to the database:
\c expense_tracker- Create the table (copy from
database.sqlfile):
CREATE TABLE expenses (
id SERIAL PRIMARY KEY,
description VARCHAR(255) NOT NULL,
amount DECIMAL(10, 2) NOT NULL,
category VARCHAR(100) NOT NULL,
date DATE NOT NULL,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);Open server.js file and change this line (around line 15):
password: 'yourpassword', // Put your actual PostgreSQL password herenpm startOpen your browser and go to: http://localhost:3000
Done! 🎉
-
Create EC2 Instance
- Choose Ubuntu 22.04
- Instance type: t2.micro (free tier)
- Security group: Open ports 22, 80, and 3000
-
Connect to EC2
ssh -i your-key.pem ubuntu@your-ec2-ip
-
Install Node.js
sudo apt update curl -fsSL https://deb.nodesource.com/setup_18.x | sudo -E bash - sudo apt install -y nodejs -
Install PostgreSQL
sudo apt install postgresql postgresql-contrib -y sudo systemctl start postgresql
-
Setup Database
sudo -u postgres psql CREATE DATABASE expense_tracker; CREATE USER myuser WITH PASSWORD 'mypassword'; GRANT ALL PRIVILEGES ON DATABASE expense_tracker TO myuser; \c expense_tracker -- Paste CREATE TABLE command here \q
-
Upload Your Code
git clone https://github.com/ObaidAbdullah16/expense-tracker.git cd expense-tracker npm install -
Edit server.js (change database password)
nano server.js # Change the password line # Save: Ctrl+X, then Y, then Enter
-
Run Forever
sudo npm install -g pm2 pm2 start server.js pm2 startup pm2 save
-
Access Your Site
http://your-ec2-ip:3000
- server.js - Main server file (all backend code here!)
- database.sql - Database setup commands
- public/index.html - Website page
- public/script.js - Frontend JavaScript
- public/style.css - Styling
- package.json - Dependencies list
✅ Add expenses with description, amount, category, date
✅ View all expenses in a table
✅ See total expenses in INR (₹)
✅ Beautiful gradient design
✅ Different colors for different categories
✅ Indian date format (DD/MM/YYYY)
"Database connection failed"
- Check if PostgreSQL is running
- Check username and password in
server.js
"Port 3000 already in use"
- Change PORT in
server.js(line 8) to something else like 3001
Can't access on EC2
- Make sure security group has port 3000 open
- Use public IP, not private
ObaidAbdullah16
GitHub: @ObaidAbdullah16
- This is a beginner-friendly project
- Everything is kept simple on purpose
- Perfect for learning Node.js + PostgreSQL
- Currency: Indian Rupees (₹)
Happy tracking! 🇮🇳💰