Skip to content

About

Expense Tracking System to monitor expenses

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

1 Commit

Folders and files

Repository files navigation

Expense Tracking System

A full-stack web application for tracking daily expenses and visualizing spending analytics over time.

🚀 Features

  • Add & Update Expenses: Easily log your daily expenses by categorizing them and adding custom notes.
  • Expense Analytics: View a breakdown of your spending habits within a specific date range.
  • Intuitive UI: A clean, interactive frontend built with Streamlit.
  • Robust Backend: A fast, reliable REST API built with FastAPI.
  • Relational Database: Persistent data storage using MySQL.

🛠️ Technology Stack

  • Frontend: Streamlit
  • Backend: FastAPI, Python
  • Database: MySQL
  • Data Processing: Pandas
  • Testing: Pytest, Postman (for API testing)

📁 Project Structure

Project-Expense_tracking_system/
│
├── .env.example          # Template for environment variables (DB credentials)
├── schema.sql            # Database schema definition
├── backend/              # FastAPI server and database helper functions
│   ├── server.py         # Main FastAPI application with API endpoints
│   ├── db_helper.py      # Database connection and query execution
│   ├── config.py         # Configuration settings
│   └── logging_setup.py  # Logger configuration
│
├── frontend/             # Streamlit application UI
│   ├── app.py            # Main entry point for the frontend app
│   ├── add_update_ui.py  # UI component for adding/updating expenses
│   ├── analytics_by_category.py # UI component for category analytics
│   └── analytics_by_months.py   # UI component for monthly analytics
│
├── tests/                # Pytest unit tests for backend and database operations
│
└── requirements          # Python dependencies

⚙️ Setup Instructions

1. Prerequisites

  • Python 3.8+
  • MySQL Server

2. Installation

Install the required Python dependencies:

pip install -r requirements

3. Database Setup

Ensure your MySQL server is running. Create a .env file in the root directory using .env.example as a template and configure your local MySQL credentials (username, password, database name). You can initialize the database using the provided schema.sql script.

4. Running the Application

Start the Backend Server:

Navigate to the backend directory and run the FastAPI server using Uvicorn:

cd backend
uvicorn server:app --reload

The backend API will be available at http://localhost:8000 (You can view the Swagger UI docs at http://localhost:8000/docs).

Start the Frontend App:

Open a new terminal, navigate to the frontend directory, and run the Streamlit app:

cd frontend
streamlit run app.py

The Streamlit interface will open in your browser, typically at http://localhost:8501.

🔌 API Endpoints

The FastAPI backend provides the following RESTful endpoints:

  • GET /expenses/{expense_date}: Fetch all expenses for a specific date.
  • POST /expenses/{expense_date}: Add, update, or overwrite expenses for a specific date.
  • POST /analytics/category: Get an aggregated summary and percentage breakdown of expenses across categories for a specified date range.
  • POST /analytics/months: Get an aggregated monthly summary of expenses.

🧪 Testing

To run the unit tests, use pytest from the root directory:

pytest

About

Expense Tracking System to monitor expenses

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages