Expense Tracker is a full-stack web application built on the MERN stack that lets you log, categorize, and monitor your income and expenses. Transactions are persisted in MongoDB and the balance updates in real time as you add or remove entries.
- Transaction Logging — Add transactions with a description and amount
- Income & Expense Split — Separate views for money in and money out
- Real-time Balance — Total balance recalculates instantly on every change
- Global State — Managed with React Context API and a custom reducer
- Persistent Storage — All data stored and retrieved via MongoDB
| Layer | Tools |
|---|---|
| Frontend | React, React Hooks, Context API |
| Backend | Node.js, Express.js |
| Database | MongoDB |
| HTTP Client | Axios |
Expense-Tracker/
├── client/ # React frontend
│ ├── public/
│ │ └── index.html
│ └── src/
│ ├── components/
│ │ ├── AddTransaction.js # Form to add a new transaction
│ │ ├── Balance.js # Displays current total balance
│ │ ├── Header.js # App header
│ │ ├── IncomeExpenses.js # Income vs expense summary
│ │ ├── Transaction.js # Single transaction item
│ │ └── TransactionList.js # Full list of transactions
│ ├── context/
│ │ ├── AppReducer.js # State reducer logic
│ │ ├── GlobalContext.js # Context definition
│ │ └── GlobalProvider.js # Context provider wrapper
│ ├── utils/
│ │ └── format.js # Currency formatting helpers
│ └── App.js
├── config/
│ ├── config.env # Environment variables
│ └── db.js # MongoDB connection
├── controllers/
│ └── transactions.js # Route handler logic
├── models/
│ └── Transaction.js # Mongoose transaction schema
├── routes/
│ └── transactions.js # API route definitions
├── server.js # Express server entry point
└── package.json
- Node.js 14+
- MongoDB instance (local or Atlas)
- npm
-
Clone the repository
git clone https://github.com/silentwraith03/Expense-Tracker-MERN.git cd Expense-Tracker -
Install backend dependencies
npm install
-
Install frontend dependencies
cd client npm install cd ..
-
Configure environment variables
Create
config/config.envand add the following:MONGO_URI=your_mongodb_connection_string PORT=5000
| Command | Description |
|---|---|
npm run dev |
Run frontend and backend concurrently |
npm run server |
Run backend only |
npm run client |
Run frontend only |
cd client && npm run build |
Build the frontend for production |
Distributed under the MIT License. See LICENSE for details.