Skip to content

ForceFour/FinTrack

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Agentic Expense Tracker πŸ€–πŸ’°

Multi-Agent AI-Powered Expense Tracking & Financial Analysis System

A comprehensive university assignment project implementing multi-agent AI workflows using LangChain/LangGraph for intelligent financial management with Next.js frontend and FastAPI backend.

🎯 Project Overview

This system transforms traditional expense tracking into an intelligent, AI-driven financial analysis platform featuring:

  • 6 Specialized AI Agents working in coordinated workflows
  • Real-time Transaction Processing with intelligent categorization
  • Advanced Fraud Detection and security monitoring
  • Personalized Financial Suggestions powered by LLMs
  • Interactive Next.js Dashboard with real-time updates
  • FastAPI Backend with HTTP API for agent communication

πŸ—οΈ System Architecture

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                     NEXT.JS FRONTEND                       β”‚
β”‚  πŸ“Š Dashboard | πŸ“€ Upload | 🏷️ Categories | πŸ“ˆ Analytics   β”‚
β”‚  πŸ’‘ Suggestions | πŸ”’ Security Monitor | πŸ€– Agent Status    β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
              β”‚                               β”‚
              β”‚ FastAPI (AI Services)         β”‚ Direct Queries
              β”‚ HTTP API                      β”‚ (CRUD Operations)
              β”‚                               β”‚
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚      FASTAPI BACKEND            β”‚  β”‚  SUPABASE POSTGRESQL  β”‚
β”‚  πŸ€– LLM Services                β”‚  β”‚  πŸ’Ύ Transaction Store β”‚
β”‚  πŸ“€ File Upload/Processing      β”‚  β”‚  πŸ” Row Level Securityβ”‚
β”‚  πŸ“Š Analytics Aggregation       β”‚  β”‚  ⚑ Real-time Queries β”‚
β”‚  πŸ”„ Workflow Monitoring         β”‚  β”‚  πŸ” Direct DB Access  β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
              β”‚ LangGraph Workflows
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                  MULTI-AGENT SYSTEM (LangGraph)            β”‚
β”‚  🏷️ NER Agent      β”‚ οΏ½ Merchant Agent β”‚ οΏ½ Classifier     β”‚
β”‚  πŸ’‘ Suggestion Gen β”‚ πŸ”’ Validator      β”‚ 🎯 Orchestrator   β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

πŸ€– AI Agent System

Agent Architecture

The system employs 6 specialized LangGraph agents for intelligent transaction processing:

  1. 🏷️ NER (Named Entity Recognition) Agent

    • Extracts merchant names, amounts, dates from transaction descriptions
    • LLM-First Approach: Uses OpenAI/Groq models as primary extraction method
    • Fallback: Regex patterns for standard formats when LLM fails
    • Handles natural language and unstructured text inputs
  2. πŸͺ Merchant Classification Agent

    • Identifies and standardizes merchant names across transactions
    • LLM-First Approach: Context-aware merchant recognition and normalization
    • Fallback: String matching and fuzzy logic for known merchants
    • Learns merchant patterns from historical data
  3. πŸ“Š Transaction Classifier Agent

    • Categorizes transactions into financial categories and subcategories
    • LLM-First Approach: Context-aware classification with reasoning
    • Fallback: scikit-learn ML models and rule-based classification
    • Provides confidence scores for each classification
  4. πŸ’‘ Personalized Suggestion Agent

    • Generates context-aware financial recommendations
    • Analyzes spending patterns and suggests optimizations
    • Creates actionable insights based on user behavior
    • Powered by LLM reasoning for personalized advice
  5. πŸ”’ Validation Agent

    • Ensures data quality and consistency across workflow
    • Validates extracted information and classifications
    • Flags anomalies and potential errors for review
    • Maintains data integrity throughout the pipeline
  6. 🎯 Orchestrator Agent

    • Coordinates workflow execution across all agents
    • Manages agent communication and state transitions
    • Handles error recovery and retry mechanisms
    • Optimizes agent execution order for efficiency

LangGraph Integration

  • Workflow Definition: Complex multi-step financial analysis workflows
  • Agent Communication: Structured message passing between agents
  • State Management: Persistent workflow state across agent interactions
  • Error Handling: Robust error recovery and retry mechanisms

πŸš€ Quick Start

Prerequisites

  • Python 3.11+
  • UV package manager
  • OpenAI/Anthropic API keys (for LLM agents)

Installation

  1. Clone and Setup
git clone <repository-url>
cd fintrack
uv sync  # Install all dependencies
  1. Environment Configuration
# Create .env file
cp .env.example .env
# Add your API keys and configuration
  1. Start the Backend
uv run python main.py
# API will be available at http://localhost:8000
# Documentation at http://localhost:8000/docs
  1. Start the Frontend
cd fintrack-frontend
npm run dev
# Frontend will be available at http://localhost:3000

πŸ“± Frontend Features

Next.js React Application

🏠 Main Dashboard

  • Real-time agent status monitoring
  • Financial summary cards and KPIs
  • Interactive charts and visualizations
  • Quick action buttons and navigation

πŸ“€ Transaction Upload

  • Drag-and-drop file upload (CSV, Excel, OFX)
  • Real-time processing progress
  • Duplicate detection and handling
  • Batch categorization with AI

🏷️ Category Management

  • AI-powered categorization rules
  • Custom category creation
  • Rule-based automation setup
  • Category performance analytics

πŸ“ˆ Advanced Analytics

  • Spending trends and patterns
  • Budget vs. actual analysis
  • Merchant and category breakdowns
  • Forecasting and predictions

πŸ’‘ AI Suggestions

  • Personalized financial recommendations
  • Budget optimization advice
  • Savings opportunity identification
  • Goal achievement strategies

πŸ”’ Security Monitor

  • Real-time fraud alerts
  • Suspicious activity detection
  • Security score dashboard
  • Incident reporting and response

πŸ”§ Backend Architecture

Data Access Strategy

The application implements a hybrid data access architecture optimized for performance and intelligence:

πŸ—„οΈ Direct Supabase Queries (Transaction CRUD)

The frontend uses direct PostgreSQL queries via Supabase client for:

  • Transaction Management: Create, Read, Update, Delete operations
  • Real-time Filtering: Complex queries with multiple filter conditions
  • Pagination: Efficient large dataset handling
  • Aggregations: Client-side and database-level statistics
  • Security: Row Level Security (RLS) policies enforce user data isolation

Benefits:

  • Lower latency (no middleware layer)
  • Database-level security enforcement
  • Type-safe TypeScript integration
  • Real-time subscription capabilities

πŸ€– FastAPI Backend Services (AI & Workflows)

The backend handles LLM-powered operations and orchestration with 12 core endpoints:

Analytics Services

  • GET /api/v1/analytics/summary/dashboard?user_id={userId} - Aggregated dashboard metrics

Conversational AI

  • POST /api/v1/transactions/natural-language - Natural language transaction entry with LLM processing

File Processing

  • POST /api/v1/transactions/upload?user_id={userId} - CSV/Excel upload triggering multi-agent pipeline

Workflow Monitoring

  • GET /api/v1/workflow/statistics/{userId} - Workflow execution statistics
  • GET /api/v1/workflow/active/{userId} - Active workflow tracking
  • GET /api/v1/workflow/history/{userId} - Historical workflow logs
  • GET /api/v1/workflow/communications/{userId} - Inter-agent communication logs

User Management

  • GET /api/v1/auth/me - User profile retrieval
  • GET /api/v1/user-settings/{userId} - User settings and preferences
  • PUT /api/v1/user-settings/{userId} - Update user settings

Transaction Intelligence

  • POST /api/v1/categorize - AI-powered single transaction categorization

Health Monitoring

  • GET /api/v1/health - Service health check

Why This Hybrid Architecture?

Direct Supabase for CRUD:

  • βœ… Eliminates unnecessary API layer for simple operations
  • βœ… Leverages PostgreSQL's query optimization
  • βœ… Built-in RLS security at database level
  • βœ… Reduces backend server load

FastAPI for Intelligence:

  • βœ… Handles computationally intensive LLM operations
  • βœ… Orchestrates multi-agent LangGraph workflows
  • βœ… Manages complex file processing pipelines
  • βœ… Provides centralized monitoring and logging

🏫 University Assignment Compliance

Academic Requirements Met

  • βœ… Multi-Agent System: 6 specialized AI agents with LangGraph orchestration
  • βœ… LLM Integration: OpenAI/Anthropic APIs for natural language processing
  • βœ… Information Retrieval: Advanced search and categorization capabilities
  • βœ… Security Features: Fraud detection, anomaly detection, secure authentication
  • βœ… Agent Communication: Structured protocols using LangGraph workflows
  • βœ… Responsible AI: Ethical considerations, bias mitigation, transparency

Technical Implementation

  • Framework: LangChain + LangGraph for agent orchestration
  • Frontend: Next.js 15 with React 19 and TypeScript
  • Backend: FastAPI with async support (12 AI/workflow endpoints)
  • Database: Supabase PostgreSQL with Row Level Security (RLS)
  • Data Access: Hybrid architecture - Direct Supabase queries (CRUD) + FastAPI (AI operations)
  • Authentication: Supabase Auth (built-in authentication service)
  • Security: Row Level Security (RLS), input validation, rate limiting
  • Monitoring: Comprehensive logging and error handling

πŸ”¬ Advanced Features

AI & Machine Learning

  • Natural Language Processing: Transaction description analysis
  • Anomaly Detection: Statistical and ML-based fraud detection
  • Recommendation Engine: Collaborative filtering for suggestions
  • Pattern Recognition: Spending behavior analysis
  • Forecasting Models: Time series prediction for budgeting

Real-Time Capabilities

  • HTTP Polling: Live agent status updates
  • Streaming Data: Real-time transaction processing
  • Progressive Loading: Chunked data loading for large datasets
  • Background Tasks: Async processing for heavy operations

Data Science Integration

  • Pandas Integration: Advanced data manipulation and analysis
  • Plotly Visualizations: Interactive charts and dashboards
  • Statistical Analysis: Comprehensive financial metrics
  • Export Capabilities: Multiple format support (CSV, Excel, JSON)

πŸ“Š Project Structure

fintrack/
β”œβ”€β”€ main.py                     # FastAPI application entry point
β”œβ”€β”€ pyproject.toml             # UV project configuration
β”œβ”€β”€ fintrack-frontend/         # Next.js frontend
β”‚   β”œβ”€β”€ app/                  # Next.js app router pages
β”‚   β”œβ”€β”€ components/           # Reusable React components
β”‚   β”œβ”€β”€ lib/                  # Utility functions and API clients
β”‚   └── public/               # Static assets
β”œβ”€β”€ src/                      # Backend source code
β”‚   β”œβ”€β”€ routes/              # API route definitions
β”‚   β”œβ”€β”€ services/            # Business logic services
β”‚   β”œβ”€β”€ models/              # Data models and schemas
β”‚   β”œβ”€β”€ agents/              # AI agent implementations
β”‚   β”œβ”€β”€ llms/                # LLM integration modules
β”‚   β”œβ”€β”€ nodes/               # LangGraph node definitions
β”‚   β”œβ”€β”€ states/              # Workflow state management
β”‚   └── graphs/              # LangGraph workflow definitions
└── logs/                    # Application logs

πŸš€ Development Roadmap

Phase 1: Core Infrastructure βœ…

  • Project setup with UV package manager
  • FastAPI backend with route structure
  • Next.js frontend with React components
  • Basic API client and HTTP integration

Phase 2: AI Agent Implementation πŸ”„

  • LangGraph workflow definitions
  • Individual agent implementations
  • Agent communication protocols
  • Multi-agent orchestration system

Phase 3: Advanced Features πŸ“‹

  • Database integration and models
  • Authentication and security services
  • ML model training and deployment
  • Advanced analytics and reporting

Phase 4: Production Readiness πŸ“‹

  • Comprehensive testing suite
  • Performance optimization
  • Production deployment configuration
  • Documentation and user guides

🀝 Contributing

This is a university assignment project. For academic integrity purposes, please refer to your institution's collaboration policies.

Contributors

IT Number Name Email
IT23270442 Duwaragie K it23270442@my.sliit.lk
IT23248212 Zayan M.F.M it23248212@my.sliit.lk
IT23212954 Fonseka D.W.J.M it23212954@my.sliit.lk
IT23151406 Sandanayaka S.D.P.D it23151406@my.sliit.lk

πŸ“„ License

This project is created for educational purposes as part of a university assignment.


Built with ❀️ using LangChain, LangGraph, FastAPI, and Next.js

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 5