Skip to content

AI Expense Tracker is a smart, intuitive application designed to help users track, categorize, and analyze their personal or business expenses with the help of AI. By combining traditional expense tracking features with AI-powered categorization and insights, this project simplifies budgeting and financial management.

Notifications You must be signed in to change notification settings

Anglesvar/AI-Expense-Tracker

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

6 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

AI Expense Tracker

A full-stack expense tracking app that uses AI to parse natural language input.

Built by: Anglesvar Appiya Chandrasekar GitHub: https://github.com/Anglesvar Time to build: [3 hours] (with AI assistance)

πŸŽ₯ Demo

React-Native-Android NodeJS

πŸ› οΈ Tech Stack

  • Mobile: React Native, Expo, TypeScript
  • Backend: Node.js, Express, TypeScript
  • Database: SQLite
  • AI: [Groq/OpenAI/Gemini] API

πŸš€ Setup Instructions

Prerequisites

  • Node.js 18+
  • npm or yarn
  • Expo CLI
  • [AI Service] API key

Backend

cd backend
npm install
cp .env.example .env
# Add your AI API key to .env
npm run dev

Mobile

cd mobile
npm install
npm start
# Scan QR code with Expo Go app

πŸ“ Project Structure


ai-expense-tracker/
    backend/
    β”œβ”€β”€ src/
    β”‚   β”œβ”€β”€ index.ts                        # Application entry point
    β”‚   β”œβ”€β”€ config/                         # Configuration files
    β”‚   β”‚   └── config.ts                   # Environment config
    β”‚   β”œβ”€β”€ database/                       # Database layer
    β”‚   β”‚   β”œβ”€β”€ connection.ts               # DB connection & initialization
    β”‚   |   β”œβ”€β”€ utils.ts                    # DB utility functions
    β”‚   β”‚   └── dto/                        # Data Transfer Objects
    β”‚   β”‚       β”œβ”€β”€ create-expense.dto.ts
    β”‚   β”‚       β”œβ”€β”€ update-expense.dto.ts
    β”‚   β”‚       └── index.ts
    |   | 
    β”‚   β”œβ”€β”€ services/                       # Business logic layer
    β”‚   β”‚   └── expense.service.ts
    β”‚   β”‚   └── expense-parser.service.ts
    β”‚   β”œβ”€β”€ types/                          # Business logic layer
    β”‚   β”‚   β”œβ”€β”€ expense.ts
    β”‚   β”‚   β”œβ”€β”€ expense-filters.ts
    β”‚   β”‚   β”œβ”€β”€ parsed-expense.ts
    β”‚   β”‚   └── index.ts
    β”‚   β”œβ”€β”€ routes/                         # API routes layer
    β”‚   β”‚   β”œβ”€β”€ index.ts                    # Routes aggregator
    β”‚   β”‚   └── expenses.routes.ts          # Expense endpoints
    β”‚   β”œβ”€β”€ middleware/                     # Express middleware
    β”‚   β”‚   β”œβ”€β”€ error.middleware.ts
    β”‚   β”‚   └── validation.middleware.ts
    β”‚   └── utils/                          # Helper utilities
    β”‚       └── async-handler.ts
    β”‚       └── validate-and-normalize.ts
    β”œβ”€β”€ .env                                # Environment variables
    β”œβ”€β”€ .env.example                        # Example env file
    β”œβ”€β”€ package.json
    └── tsconfig.json

    mobile/
    β”œβ”€β”€ App.tsx                             # Main app entry point
    β”œβ”€β”€ screens/
    β”‚   └── ExpenseTrackerScreen.tsx        # Main screen with business logic
    β”œβ”€β”€ components/
    β”‚   β”œβ”€β”€ index.ts                        # Component exports
    β”‚   β”œβ”€β”€ Header.tsx                      # App header with title
    β”‚   β”œβ”€β”€ ExpenseInput.tsx                # Input field with Add button
    β”‚   β”‚   β”œβ”€β”€ TextInput
    β”‚   β”‚   β”œβ”€β”€ AddButton
    β”‚   β”‚   └── LoadingIndicator
    β”‚   β”œβ”€β”€ SuccessCard.tsx                 # Success feedback card
    β”‚   β”œβ”€β”€ ExpenseList.tsx                 # FlatList with pull-to-refresh
    β”‚   └── ExpenseItem.tsx                 # Individual expense item
    β”‚       β”œβ”€β”€ CategoryIcon (emoji + name)
    β”‚       β”œβ”€β”€ Amount
    β”‚       β”œβ”€β”€ Description
    β”‚       β”œβ”€β”€ TimeAgo
    β”‚       └── DeleteButton
    β”œβ”€β”€ api/                                 # API service layer
    |       helpers/
    β”‚           β”œβ”€β”€ expense-api-error.ts
    β”‚           β”œβ”€β”€ fetch-with-timeout.ts
    β”‚           └── handle-response.ts
    β”‚       β”œβ”€β”€ add-expense.api.ts
    β”‚       β”œβ”€β”€ delete-expense.api.ts
    β”‚       β”œβ”€β”€ get-expense.api.ts
    β”‚       └── index.ts
    β”œβ”€β”€ types.ts                            # TypeScript interfaces
    β”œβ”€β”€ utils.ts                            # Utility functions
    β”œβ”€β”€ config.ts                           # Configuration
    β”œβ”€β”€ package.json                        # Dependencies
    └── tsconfig.json                       # TypeScript config

    |-- README.md

πŸ€– AI Prompt Design

I used this system prompt for expense parsing:

    You are an expense parser. Extract expense information from natural language input.

    RULES:
    1. Extract the amount as a number (no currency symbols)
    2. Default currency is INR unless explicitly mentioned (USD, EUR, etc.)
    3. Categorize into EXACTLY one of these categories:
    - Food & Dining (restaurants, cafes, food delivery, groceries)
    - Transport (uber, ola, taxi, fuel, parking, metro)
    - Shopping (clothes, electronics, amazon, flipkart)
    - Entertainment (movies, netflix, spotify, games)
    - Bills & Utilities (electricity, water, internet, phone)
    - Health (medicine, doctor, gym, pharmacy)
    - Travel (flights, hotels, trips)
    - Other (anything that doesn't fit above)
    4. Description should be a clean summary (not the raw input)
    5. Merchant is the company/store name if mentioned, null otherwise

    RESPOND ONLY WITH VALID JSON, no other text:
    {
        "amount": <number>,
        "currency": "<string>",
        "category": "<string>",
        "description": "<string>",
        "merchant": "<string or null>"
    }

    If the input is invalid or you cannot extract an amount, respond:
    {
        "error": "Could not parse expense. Please include an amount.",
        "amount": null
    }

About

AI Expense Tracker is a smart, intuitive application designed to help users track, categorize, and analyze their personal or business expenses with the help of AI. By combining traditional expense tracking features with AI-powered categorization and insights, this project simplifies budgeting and financial management.

Resources

Stars

Watchers

Forks

Contributors