Skip to content

Latest commit

ย 

History

45 Commits

Folders and files

NameName
Last commit message
Last commit date
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

Expense Tracker AI Assistant

An AI-powered expense management application built with Python, LangGraph, LangChain, FastAPI, Streamlit, SQLite, Docker, GitHub Actions, and Render.

The project demonstrates how to take an LLM-based tool-calling application from local development to a containerized, CI/CD-enabled deployment.

๐Ÿš€ Features

  • Add expenses using natural language
  • Retrieve a specific expense by ID
  • List all expenses for the current user
  • Generate expense summaries by category
  • Delete expenses with a human confirmation step
  • Persistent conversation state using LangGraph checkpoints
  • User-scoped expense data
  • LLM tool calling with LangGraph
  • FastAPI backend
  • Streamlit frontend
  • SQLite database for the learning/project implementation
  • Docker containerization
  • GitHub Actions CI/CD
  • Render deployment configuration
  • Environment-variable based API configuration

๐Ÿ—๏ธ Architecture

                    โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
                    โ”‚      User            โ”‚
                    โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                               โ”‚
                               โ–ผ
                    โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
                    โ”‚  Streamlit Frontend  โ”‚
                    โ”‚    streamlit.py      โ”‚
                    โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                               โ”‚ HTTP POST /chat
                               โ–ผ
                    โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
                    โ”‚    FastAPI Backend   โ”‚
                    โ”‚     allinone.py      โ”‚
                    โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                               โ”‚
                               โ–ผ
                    โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
                    โ”‚      LangGraph       โ”‚
                    โ”‚   Agent Workflow     โ”‚
                    โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                               โ”‚
                    โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ–ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
                    โ”‚         LLM          โ”‚
                    โ”‚   Tool Calling       โ”‚
                    โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                               โ”‚
              โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
              โ–ผ                โ–ผ                 โ–ผ
        Add Expense       Get Expense       List Expenses
              โ”‚                โ”‚                 โ”‚
              โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                               โ–ผ
                         โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
                         โ”‚  SQLite   โ”‚
                         โ”‚ expenses  โ”‚
                         โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

              Delete Flow
                    โ”‚
                    โ–ผ
             Human Approval
                    โ”‚
              โ”Œโ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”
             Yes          No
              โ”‚            โ”‚
              โ–ผ            โ–ผ
           Delete       Cancel

๐Ÿงฐ Tech Stack

Backend

  • Python
  • FastAPI
  • LangGraph
  • LangChain
  • Pydantic
  • SQLite
  • aiosqlite

AI

  • LLM API through LangChain
  • Tool calling
  • Structured tool execution
  • Human-in-the-loop workflow for deletion

Frontend

  • Streamlit
  • Python requests

DevOps

  • Docker
  • Docker Hub
  • GitHub Actions
  • Render
  • CI/CD

๐Ÿ“‚ Project Structure

.
โ”œโ”€โ”€ allinone.py
โ”œโ”€โ”€ streamlit.py
โ”œโ”€โ”€ Dockerfile
โ”œโ”€โ”€ Dockerfile.backend
โ”œโ”€โ”€ render.yaml
โ”œโ”€โ”€ requirements.txt
โ”œโ”€โ”€ .gitignore
โ”œโ”€โ”€ .github/
โ”‚   โ””โ”€โ”€ workflows/
โ”‚       โ””โ”€โ”€ ci.yml
โ””โ”€โ”€ LanggraphExpenseAgent.ipynb

Important files

allinone.py

Contains the FastAPI backend, LangGraph agent, tools, database functions, checkpointing, and API endpoint.

streamlit.py

Provides the chat-based frontend and sends requests to the FastAPI backend.

Dockerfile

Defines the container image used for deployment.

render.yaml

Contains the Render deployment configuration.

.github/workflows/ci.yml

Defines the GitHub Actions CI/CD workflow.

requirements.txt

Contains the Python dependencies required by the application.

๐Ÿ”ง Expense Tools

The agent currently exposes five tools:

  1. add_expense_tool
  2. get_expense_tool
  3. get_summary_tool
  4. delete_expense_tool
  5. list_all_expenses_tool

The system prompt instructs the LLM to select the appropriate tool based on the user's request.

For example:

User: Show me all my expenses
        โ†“
list_all_expenses_tool
        โ†“
SQLite query
        โ†“
Expense records
        โ†“
LLM response

While:

User: Show me my food spending
        โ†“
get_summary_tool
        โ†“
SQLite aggregation
        โ†“
Summary

๐Ÿ—„๏ธ Database

The project currently uses SQLite:

expenses.db

The expense table contains:

expense_id
user_id
amount
category
description
date

SQLite was intentionally used as a lightweight database for this project and learning environment.

For a larger production system, the database layer can later be migrated to a server-based relational database such as PostgreSQL without changing the overall agent architecture.

๐Ÿง  LangGraph Workflow

The application uses a graph-based workflow:

START
  โ”‚
  โ–ผ
 LLM
  โ”‚
  โ”œโ”€โ”€ No tool call โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ–บ END
  โ”‚
  โ””โ”€โ”€ Tool call
          โ”‚
          โ–ผ
        Tools
          โ”‚
          โ–ผ
         LLM

Deletion has an additional human-approval flow:

User requests deletion
        โ”‚
        โ–ผ
delete_expense_tool
        โ”‚
        โ–ผ
Confirm with user
        โ”‚
     โ”Œโ”€โ”€โ”ดโ”€โ”€โ”
    Yes    No
     โ”‚      โ”‚
     โ–ผ      โ–ผ
  Delete   Cancel

LangGraph checkpointing is used to maintain conversation/workflow state.

โ–ถ๏ธ Run Locally

1. Clone the repository

git clone <your-repository-url>
cd Expense-Tracker-AI-Agent-using-Langgraph-Tool-Calling

2. Create a virtual environment

Windows:

python -m venv .venv
.venv\Scripts\activate

Linux/macOS:

python3 -m venv .venv
source .venv/bin/activate

3. Install dependencies

pip install -r requirements.txt

4. Start the FastAPI backend

uvicorn allinone:app --reload

The backend runs on:

http://127.0.0.1:8000

5. Start Streamlit

In another terminal:

streamlit run streamlit.py

The frontend will normally be available at:

http://localhost:8501

The Streamlit application reads the backend URL from:

API_URL

๐Ÿณ Docker

The application is containerized with Docker.

Build the image:

docker build -t mahady13/expense_tracker_ai_agent .

Run it:

docker run -p 8502:8502 mahady13/expense_tracker_ai_agent

The image is published to Docker Hub under:

mahady13/expense_tracker_ai_agent

๐Ÿ”„ CI/CD

This project uses GitHub Actions + Docker Hub + Render to automate deployment.

High-level pipeline:

Developer
    โ”‚
    โ–ผ
Git push
    โ”‚
    โ–ผ
GitHub Repository
    โ”‚
    โ–ผ
GitHub Actions
    โ”‚
    โ”œโ”€โ”€ Install dependencies
    โ”œโ”€โ”€ Run CI checks
    โ”œโ”€โ”€ Build Docker image
    โ””โ”€โ”€ Push image to Docker Hub
                โ”‚
                โ–ผ
          Docker Hub
                โ”‚
                โ–ผ
             Render
                โ”‚
                โ–ผ
          Deployed App

The workflow configuration is located at:

.github/workflows/ci.yml

Render deployment configuration is located at:

render.yaml

This means changes can be pushed to GitHub and processed automatically instead of manually rebuilding and deploying every change.

โ˜๏ธ Deployment

The application is designed to use:

  • GitHub for source control
  • GitHub Actions for automation
  • Docker Hub for container images
  • Render for cloud deployment

Secrets such as API keys should be configured through the deployment platform's environment-variable/secrets settings rather than committed to the repository.

๐Ÿงช Example Usage

User:
Show me all my expenses

Assistant:
ID    Date        Category    Description       Amount
1     2025-08-14  Food        Burger             200.00
2     2026-08-08  Food        Tea                 30.00
3     2026-08-08  Food        Coffee              25.00
...

Other supported requests include:

Add 50 BDT for lunch today

Show me expense ID 3

Show my food expense summary

Delete expense ID 2

Deletion requires confirmation before the record is removed.

๐Ÿ“ˆ What This Project Demonstrates

This project was built as a practical learning implementation of production-oriented AI engineering concepts:

  • LLM application architecture
  • Agentic workflows
  • LangGraph state management
  • Tool calling
  • RAG/AI-system development foundations
  • REST API development
  • Database interaction
  • Human-in-the-loop controls
  • Containerization
  • Environment-based configuration
  • CI/CD automation
  • Cloud deployment
  • Debugging local-vs-cloud deployment issues

The implementation intentionally starts with simple infrastructure so the core engineering concepts can be understood before introducing more complex infrastructure.

๐Ÿ”ฎ Future Improvements

Possible next steps include:

  • Replace SQLite with PostgreSQL
  • Add authentication and proper user management
  • Add automated unit/integration tests
  • Add API validation and structured error handling
  • Add production logging and observability
  • Add database migrations
  • Add Redis or another production-grade state/cache layer where appropriate
  • Add stronger security controls
  • Add automated deployment approvals
  • Add monitoring and health checks
  • Improve agent evaluation and tool-call reliability

๐Ÿ‘จโ€๐Ÿ’ป Author

Mohiuddin Mahady

Built as a hands-on AI engineering and DevOps project focused on learning how to move an LLM-powered application from local development toward production-style deployment.

About

An AI-powered expense management application built with Python, LangGraph, LangChain, FastAPI, Streamlit, SQLite, Docker, GitHub Actions, and Render. The project demonstrates how to take an LLM-based tool-calling application from local development to a containerized, CI/CD-enabled deployment.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages