Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

4 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

🏦 Enhanced Financial Wellness AI Chatbot

A comprehensive AI-powered financial analysis system that provides intelligent insights into your spending patterns, budget tracking, and financial recommendations using advanced MCP (Model Context Protocol) integration and Google Gemini AI.

Financial Analysis Demo Python Version AI Integration

🎯 Project Overview

This project has evolved from a basic financial chatbot to a comprehensive AI-powered financial analysis platform with enhanced MCP integration. The system processes real transaction data, provides intelligent insights, and generates professional visualizations.

Key Features

  • πŸ€– AI-Powered Analysis - Google Gemini Pro integration for natural language processing
  • πŸ“Š 7 Comprehensive Tools - Complete financial analysis toolkit
  • πŸ“ˆ Professional Charts - 4 types of financial visualizations
  • πŸ’Ύ Real Transaction Data - 95 realistic financial transactions
  • 🎯 Smart Recommendations - AI-powered financial advice
  • πŸ“± Interactive Interface - Natural language chatbot interface

πŸ—οΈ Project Structure

mcp_ai_chatbot/
β”œβ”€β”€ πŸ“ **CORE SYSTEM** (Current - Enhanced)
β”‚   β”œβ”€β”€ financial_mcp_server.py          # πŸ†• Enhanced MCP server (29KB, 659 lines)
β”‚   β”œβ”€β”€ enhanced_financial_client.py     # πŸ†• AI-powered client (19KB, 402 lines)
β”‚   β”œβ”€β”€ daily_transactions.csv           # πŸ†• Transaction dataset (8KB, 95 transactions)
β”‚   └── demo_financial_analysis.py       # πŸ†• Comprehensive demo (10KB, 257 lines)
β”‚
β”œβ”€β”€ πŸ“ **TESTING & DEBUG** (Current - New)
β”‚   β”œβ”€β”€ test_chart_generation.py         # πŸ†• Chart testing (2.3KB)
β”‚   β”œβ”€β”€ debug_chart_generation.py        # πŸ†• Debug script (2.7KB)
β”‚   └── show_charts.py                   # πŸ†• Chart status (3.1KB)
β”‚
β”œβ”€β”€ πŸ“ **DOCUMENTATION** (Current - Enhanced)
β”‚   β”œβ”€β”€ ENHANCED_README.md               # πŸ†• Comprehensive guide (13KB)
β”‚   β”œβ”€β”€ IMPLEMENTATION_SUMMARY.md        # πŸ†• Implementation details (10KB)
β”‚   └── QUICK_START.md                   # πŸ†• Quick start guide (5KB)
β”‚
β”œβ”€β”€ πŸ“ **GENERATED ASSETS** (Current - Auto-generated)
β”‚   └── charts/                          # πŸ†• Financial charts
β”‚       β”œβ”€β”€ category_breakdown.png       # πŸ†• Spending categories (180KB)
β”‚       β”œβ”€β”€ spending_trend.png           # πŸ†• Daily trends (202KB)
β”‚       β”œβ”€β”€ budget_vs_actual.png         # πŸ†• Budget comparison (145KB)
β”‚       └── merchant_analysis.png        # πŸ†• Merchant analysis (113KB)
β”‚
β”œβ”€β”€ πŸ“ **CONFIGURATION** (Current - Shared)
β”‚   β”œβ”€β”€ config.json                      # βœ… API configuration (138B)
β”‚   β”œβ”€β”€ requirements.txt                 # βœ… Dependencies (337B)
β”‚   └── venv/                           # βœ… Virtual environment
β”‚
└── πŸ“ **LEGACY SYSTEM** (Old - Deprecated)
    β”œβ”€β”€ api_server.py                    # ❌ Old FastAPI server (16KB)
    β”œβ”€β”€ client/                          # ❌ Old client directory
    β”œβ”€β”€ financial_data.json              # ❌ Old sample data (5.4KB)
    └── [other deprecated files...]      # ❌ Old documentation & tests

πŸš€ Quick Start

Prerequisites

  • Python 3.8 or higher
  • Google Gemini API key
  • Required Python packages (see requirements.txt)

Installation

  1. Clone the repository
git clone <repository-url>
cd mcp_ai_chatbot
  1. Install dependencies
pip3 install -r requirements.txt
  1. Configure API key
# Edit config.json with your Google Gemini API key
{
  "GOOGLE_API_KEY": "your-gemini-api-key-here"
}

Running the System

Option 1: Interactive AI Chatbot (Recommended)

python3 enhanced_financial_client.py

Example Interaction:

πŸ€– Enhanced Financial Wellness AI Chatbot
Loaded 95 transactions from daily_transactions.csv

Ask me anything about your finances! Examples:
β€’ 'How much did I spend this month?'
β€’ 'Show me my spending by category'
β€’ 'Am I over budget in any categories?'
β€’ 'Give me spending recommendations'
β€’ 'What are my top merchants?'
β€’ 'Generate a spending trend chart'
β€’ Type 'quit' to exit

You: Show me my spending by category

Assistant: Analyzing your financial data...
I found 95 transactions totaling $14,515.99.

**Top 5 Transactions:**
1. Employer Inc - $2500.00 (Income) - 2024-01-01
2. Property Management - $1200.00 (Rent) - 2024-01-08
3. Internal Transfer - $500.00 (Savings) - 2024-01-05
4. Micro Center - $500.00 (Shopping) - 2024-01-28
5. Best Buy - $450.00 (Shopping) - 2024-01-24

Option 2: Comprehensive Demo

python3 demo_financial_analysis.py

Option 3: Direct MCP Server Usage

from financial_mcp_server import FinancialMCPServer

server = FinancialMCPServer()
result = server.get_spending_analysis()
print(result)

πŸ”§ System Architecture

Core Components

1. Financial MCP Server (financial_mcp_server.py)

  • Size: 29KB (659 lines)
  • Purpose: Core financial analysis engine
  • Features:
    • 7 comprehensive analysis tools
    • Real-time transaction processing
    • Professional chart generation
    • Budget tracking and analysis
    • Advanced filtering capabilities

2. Enhanced Financial Client (enhanced_financial_client.py)

  • Size: 19KB (402 lines)
  • Purpose: AI-powered interactive interface
  • Features:
    • Natural language query processing
    • Google Gemini AI integration
    • Smart date extraction and filtering
    • Conversation memory
    • Intelligent response formatting

3. Transaction Dataset (daily_transactions.csv)

  • Size: 8KB (95 transactions)
  • Features:
    • 95 realistic financial transactions
    • 10 spending categories
    • 50+ unique merchants
    • 31 days of transaction data
    • Multiple transaction types

Available Analysis Tools

Tool Description Example Query
get_transactions() Filter and retrieve transactions "Show me all grocery transactions"
get_spending_analysis() Comprehensive spending breakdown "How much did I spend this month?"
get_budget_analysis() Budget vs actual comparison "Am I over budget?"
get_spending_recommendations() AI-powered financial advice "Give me spending recommendations"
get_merchant_analysis() Merchant spending patterns "What are my top merchants?"
get_trend_analysis() Time-based trend analysis "Show me spending trends"
generate_chart() Professional chart generation "Generate a spending trend chart"

Chart Generation Types

  1. Category Breakdown - Pie chart of spending categories
  2. Spending Trend - Line chart of daily spending trends
  3. Budget vs Actual - Bar chart comparing budget to actual spending
  4. Merchant Analysis - Bar chart of top merchants by spending

πŸ“Š Data Processing Pipeline

CSV Data β†’ Pandas DataFrame β†’ Filtering/Analysis β†’ JSON Response β†’ Chart Generation β†’ File Storage

Natural Language Processing Flow

User Query β†’ Query Analysis β†’ Tool Selection β†’ MCP Tool Call β†’ Response Formatting β†’ AI Enhancement β†’ Final Response

Chart Generation Process

Chart Request β†’ Data Filtering β†’ Visualization Creation β†’ File Saving β†’ Path Return

🎨 Generated Visualizations

The system automatically generates 4 types of professional financial charts:

1. Category Breakdown Chart

  • File: charts/category_breakdown.png
  • Type: Pie chart
  • Purpose: Shows spending distribution across categories

2. Spending Trend Chart

  • File: charts/spending_trend.png
  • Type: Line chart with markers
  • Purpose: Displays daily spending patterns over time
  • Features:
    • Date range: January 1 - February 1, 2024
    • Y-axis: Amount ($) from 0 to 1400
    • Shows spending volatility and trends

3. Budget vs Actual Chart

  • File: charts/budget_vs_actual.png
  • Type: Bar chart
  • Purpose: Compares budgeted vs actual spending

4. Merchant Analysis Chart

  • File: charts/merchant_analysis.png
  • Type: Bar chart
  • Purpose: Shows top merchants by spending amount

πŸ” Testing & Debugging

Testing Tools

# Test chart generation
python3 test_chart_generation.py

# Debug chart issues
python3 debug_chart_generation.py

# Show chart status
python3 show_charts.py

Common Issues & Solutions

  1. ModuleNotFoundError: No module named 'plotly'

    pip3 install plotly
  2. API Key Issues

    • Ensure config.json contains valid Google Gemini API key
    • Check API key permissions and quotas
  3. Chart Generation Failures

    • Verify charts/ directory exists
    • Check write permissions
    • Ensure matplotlib/seaborn are installed

πŸ“ˆ System Evolution

Version History

  • July 29, 2024: Original basic system
  • July 31, 2024: Major enhancement with MCP server and AI client
  • August 1, 2024: Chart generation fixes and testing tools

Key Improvements

  • Data Processing: CSV dataset vs JSON sample data
  • Analysis Tools: 7 comprehensive tools vs basic operations
  • User Interface: Natural language processing vs structured queries
  • Visualization: 4 professional chart types vs basic graphs
  • Documentation: Comprehensive guides vs basic setup instructions

🀝 Contributing

  1. Fork the repository
  2. Create a feature branch
  3. Make your changes
  4. Add tests if applicable
  5. Submit a pull request

Development Setup

# Create virtual environment
python3 -m venv venv
source venv/bin/activate  # On Windows: venv\Scripts\activate

# Install development dependencies
pip3 install -r requirements.txt

# Run tests
python3 test_chart_generation.py

πŸ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.


πŸ™ Acknowledgments

  • Google Gemini AI - For natural language processing capabilities
  • MCP Protocol - For standardized tool interface
  • Pandas & Matplotlib - For data processing and visualization
  • FastAPI & Uvicorn - For web server capabilities

πŸ“ž Support

For questions, issues, or contributions:

  • Create an issue on GitHub
  • Check the documentation in ENHANCED_README.md
  • Review IMPLEMENTATION_SUMMARY.md for technical details

πŸŽ‰ Ready to transform your financial analysis with AI-powered insights!

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages