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.
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
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β 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 β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
The system employs 6 specialized LangGraph agents for intelligent transaction processing:
-
π·οΈ 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
-
πͺ 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
-
π 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
-
π‘ 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
-
π 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
-
π― 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
- 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
- Python 3.11+
- UV package manager
- OpenAI/Anthropic API keys (for LLM agents)
- Clone and Setup
git clone <repository-url>
cd fintrack
uv sync # Install all dependencies- Environment Configuration
# Create .env file
cp .env.example .env
# Add your API keys and configuration- Start the Backend
uv run python main.py
# API will be available at http://localhost:8000
# Documentation at http://localhost:8000/docs- Start the Frontend
cd fintrack-frontend
npm run dev
# Frontend will be available at http://localhost:3000- Real-time agent status monitoring
- Financial summary cards and KPIs
- Interactive charts and visualizations
- Quick action buttons and navigation
- Drag-and-drop file upload (CSV, Excel, OFX)
- Real-time processing progress
- Duplicate detection and handling
- Batch categorization with AI
- AI-powered categorization rules
- Custom category creation
- Rule-based automation setup
- Category performance analytics
- Spending trends and patterns
- Budget vs. actual analysis
- Merchant and category breakdowns
- Forecasting and predictions
- Personalized financial recommendations
- Budget optimization advice
- Savings opportunity identification
- Goal achievement strategies
- Real-time fraud alerts
- Suspicious activity detection
- Security score dashboard
- Incident reporting and response
The application implements a hybrid data access architecture optimized for performance and intelligence:
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
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 statisticsGET /api/v1/workflow/active/{userId}- Active workflow trackingGET /api/v1/workflow/history/{userId}- Historical workflow logsGET /api/v1/workflow/communications/{userId}- Inter-agent communication logs
User Management
GET /api/v1/auth/me- User profile retrievalGET /api/v1/user-settings/{userId}- User settings and preferencesPUT /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
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
- β 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
- 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
- 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
- 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
- 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)
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
- Project setup with UV package manager
- FastAPI backend with route structure
- Next.js frontend with React components
- Basic API client and HTTP integration
- LangGraph workflow definitions
- Individual agent implementations
- Agent communication protocols
- Multi-agent orchestration system
- Database integration and models
- Authentication and security services
- ML model training and deployment
- Advanced analytics and reporting
- Comprehensive testing suite
- Performance optimization
- Production deployment configuration
- Documentation and user guides
This is a university assignment project. For academic integrity purposes, please refer to your institution's collaboration policies.
| IT Number | Name | |
|---|---|---|
| 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 |
This project is created for educational purposes as part of a university assignment.
Built with β€οΈ using LangChain, LangGraph, FastAPI, and Next.js