A simple command-line interface (CLI) application written in Go to manage personal expenses. It allows users to add, update, delete, and view expenses, as well as generate summaries of expenses, including monthly summaries for the current year.
Source: https://roadmap.sh/projects/expense-tracker
- Add Expense: Record a new expense with a description and amount.
- Update Expense: Modify the description or amount of an existing expense.
- Delete Expense: Remove an expense by its ID.
- List Expenses: View all recorded expenses in a tabulated format.
- Summary: Display the total amount of all expenses or expenses for a specific month in the current year.
- Go 1.18 or higher
- No external library dependencies; uses only the Go standard library
-
Clone or download the repository to your local machine.
-
Navigate to the project directory:
cd expense-tracker -
Build the application:
go build -o expense-tracker
Run the application using the ./expense-tracker command followed by a subcommand. The application stores data in a file named expenses.json in the same directory.
-
Add an expense:
./expense-tracker add --description "Lunch" --amount 20Output:
Expense added successfully (ID: 1) -
Update an expense:
./expense-tracker update --id 1 --description "Lunch at Cafe" --amount 25Output:
Expense updated successfully -
Delete an expense:
./expense-tracker delete --id 1
Output:
Expense deleted successfully -
List all expenses:
./expense-tracker list
Output:
ID Date Description Amount 1 2025-09-01 Lunch $20.00 2 2025-09-01 Dinner $10.00 -
View total expenses:
./expense-tracker summary
Output:
Total expenses: $30.00 -
View expenses for a specific month:
./expense-tracker summary --month 9
Output:
Total expenses for September: $30.00
Expenses are stored in a JSON file (expenses.json) in the same directory as the executable. Each expense entry includes:
id: Unique identifier for the expense.date: Date of the expense (format: YYYY-MM-DD).description: Description of the expense.amount: Amount spent.
Example expenses.json:
[
{
"id": 1,
"date": "2025-09-01",
"description": "Lunch",
"amount": 20
},
{
"id": 2,
"date": "2025-09-01",
"description": "Dinner",
"amount": 10
}
]The application includes error handling for:
- Invalid amounts (e.g., negative numbers or non-numeric input).
- Invalid expense IDs (e.g., non-existent or non-numeric IDs).
- Invalid months (e.g., values outside 1-12).
- Missing required arguments for commands.
Ensure the executable is in your PATH or run it directly from the project directory. For example:
./expense-tracker add --description "Coffee" --amount 5- The application assumes all expenses are in the current year for monthly summaries.
- The
expenses.jsonfile is created automatically when the first expense is added. - Ensure write permissions in the directory where
expenses.jsonis stored.
- Add support for expense categories and filtering by category.
- Implement budget settings with warnings for exceeding budgets.
- Add functionality to export expenses to a CSV file.
This project is licensed under the MIT License.