The CLI Expense Tracker is a command-line-based expense management system that helps users track their daily, weekly, and monthly spending. Users can add, update, delete, and view expenses, generate reports, and visualize spending trends.
This project is built with Python, using PostgreSQL for data persistence, and bcrypt for secure password handling. It follows a modular structure, ensuring scalability and maintainability.
- User Authentication: Secure signup & login with password hashing (bcrypt).
- Expense Management:
- Add expenses with categories, descriptions, and date restrictions.
- Delete expenses after searching by category & date range.
- Update expenses with flexible field changes.
- Category Management:
- View all categories in a structured format.
- Create new categories.
- Delete unused categories.
- Reporting System:
- Generate daily, weekly, monthly, and yearly reports.
- Compare expenses across different periods.
- Export reports in PDF format.
- Visualization & Graphs:
- Pie charts: Category-wise spending breakdown.
- Bar charts: Monthly and yearly expense comparison.
- Line graphs: Expense trends over time.
- Logging & History:
- Track all user actions (expense updates, deletions, reports generated).
- Maintain a history log of every action performed.
expense_tracker/
βββ main.py
βββ requirements.txt
|__ README.md
β
βββ config/
β βββ db_config.py
β
βββ database/
β βββ db_connection.py
β βββ models.py
β
βββ authentication/
β βββ auth.py
β
βββ expenses/
β βββ expense_manager.py
β
βββ categories/
β βββ category_manager.py
β
βββ reports/
β βββ report_generator.py
β
βββ utils/
β βββ pdf_generator.py
β βββ logger.py
git clone https://github.com/AnkushGitRepo/Cashflow-Compass.git
cd Cashflow-Compass
python -m venv .venv
source .venv/bin/activate # For MacOS/Linux
.\.venv\Scripts\activate # For Windows
pip install -r requirements.txt
- 1. Start PostgreSQL service:
sudo service postgresql start # For Linux/macOS
- 2. Create a new database:
CREATE DATABASE expense_tracker;
- 3. Update Database Configuration in
config/db_config.py
:DB_NAME = "cashflow_compass" DB_USER = "postgres" DB_PASSWORD = "your_password" DB_HOST = "localhost" DB_PORT = "5432"
python database/models.py
python main.py
1. Signup
2. Login
3. Exit
Choose an option:
1. Add Expense
2. Delete Expense
3. Update Expense
4. View Reports
5. Generate Reports
6. History
7. Categories
8. Exit
- Users enter amount first.
- Categories are displayed in a formatted manner (6 per line).
- Date input:
- Press Enter to use current date.
- Can only enter dates within Β±6 months.
- Logs are created in
user_logs
after expense addition.
- Users can search expenses before deleting:
- By category.
- By date range.
- Filtered expenses are displayed in a table before selection.
- Users can search expenses before updating.
- Flexible updates:
- Can skip fields (press Enter to keep old values).
- Validates category & date input.
- Users can generate reports:
- Daily, Weekly, Monthly, and Yearly.
- Comparison Reports (current vs. past months).
- User logs track every action.
- Logs include:
- Expense additions, updates, deletions.
- Report generations.
CREATE TABLE users (
id SERIAL PRIMARY KEY,
username VARCHAR(50) UNIQUE NOT NULL,
password TEXT NOT NULL,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);
CREATE TABLE categories (
id SERIAL PRIMARY KEY,
user_id INT REFERENCES users(id) ON DELETE CASCADE,
category_name VARCHAR(100) NOT NULL,
is_predefined BOOLEAN DEFAULT FALSE
);
CREATE TABLE expenses (
id SERIAL PRIMARY KEY,
user_id INT REFERENCES users(id) ON DELETE CASCADE,
category_id INT REFERENCES categories(id) ON DELETE SET NULL,
amount DECIMAL(10,2) NOT NULL,
description TEXT,
date DATE NOT NULL,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);
CREATE TABLE user_logs (
id SERIAL PRIMARY KEY,
user_id INT REFERENCES users(id) ON DELETE CASCADE,
action TEXT NOT NULL,
timestamp TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);
- Invalid Inputs: Users are prompted again until valid data is entered.
- Database Errors: Issues are logged in
user_logs
. - Graceful Exits: Users can cancel actions anytime.
- π Advanced Analytics (budgeting, spending trends).
- π Recurring Expenses (auto-add monthly subscriptions).
- π± Web Interface (integrate with Flask or Django).
- π€ Export to CSV/PDF for detailed financial tracking.
- Fork the repository.
- Create a new branch (feature-xyz).
- Commit changes (git commit -m "Added feature XYZ").
- Push and submit a PR.
Special thanks to contributors for helping improve this project. π
π Let me know if you need further refinements! π₯