Expense Tracker
Automated expense management with a Supabase backend and hierarchical category support.
Expense Tracker Backend
AI-powered expense tracking system with natural language interface, intelligent categorization, and real-time sync.
Architecture
The system uses a two-server architecture:
- MCP Server: Core expense tracking tools exposed via Model Context Protocol
- Gemini AI Server: FastAPI server providing chat interface with authentication
Features
- š¤ Natural language expense management via Gemini AI
- š§ Intelligent categorization using embeddings and similarity search
- š JWT authentication with Supabase
- š Hierarchical categories for organization
- š·ļø Predefined tag system
- š Real-time data sync
- š Learning system that improves over time
Quick Start
Prerequisites
python3 -m venv venv
source venv/bin/activate
pip install -r requirements.txt
Environment Setup
cp .env.example .env
# Add your credentials:
# - SUPABASE_URL
# - SUPABASE_KEY
# - GOOGLE_API_KEY (for Gemini)
Database Setup
Execute the SQL scripts in your Supabase SQL Editor:
# Core tables
scripts/create_tables.sql
# Embeddings support
scripts/create_embeddings_schema.sql
Run Both Servers
Terminal 1 - MCP Server:
python run_mcp.py
Terminal 2 - Gemini AI Server:
uvicorn app.servers.gemini.main:app --reload --port 8000
Initialize Data
# Populate categories
python scripts/populate_hierarchical_categories.py
# Populate predefined tags
python scripts/populate_predefined_tags.py
API Endpoints
Chat Interface
POST /chat- Send natural language commandsPOST /auth/refresh- Refresh JWT token
MCP Tools (via chat)
- Create expenses from natural language
- Auto-categorize transactions
- Get spending summaries
- Analyze subscriptions
- View recent transactions
Flutter Client
refer https://github.com/keyurgit45/expense-tracker-client
Testing
# Run all tests with mocks
ENVIRONMENT=test pytest tests/ -v
# Run specific components
ENVIRONMENT=test pytest tests/test_mcp_tools.py -v
ENVIRONMENT=test pytest tests/test_categorization.py -v
Project Structure
backend/
āāā app/
ā āāā core/ # Business logic
ā āāā servers/
ā ā āāā gemini/ # AI chat server
ā ā āāā mcp/ # MCP tool server
ā āāā shared/ # Shared configs
āāā scripts/ # Utilities
āāā tests/ # Test suite
AI Categorization
The system uses a hybrid approach:
- Generates embeddings for transactions using Sentence Transformers
- Finds similar past transactions using pgvector
- Uses weighted voting to predict categories
- Falls back to rule-based matching
- Learns from user confirmations
Development
- API docs: http://localhost:8000/docs
- Frontend integration: Configure CORS in Gemini server
- MCP tools can be tested directly via chat interface
Related Servers
Huuh MCP Server
Integrates with the huuh.me platform to enable collaborative AI knowledge bases and personas.
freee
Interact with the freee accounting API to manage financial data and business operations.
KnowSync AI
Transform your scattered documentation into AI-ready knowledge that works seamlessly with Claude, Cursor, VS Code, and other AI tools.
PyApple MCP Tools
Python tools for MCP that integrate with native Apple applications like Messages, Notes, Mail, and more on macOS.
MCP Google Workspace
A comprehensive MCP server for managing Google Workspace services like Calendar, Contacts, and Gmail using OAuth2 authentication.
Notion
Connects AI assistants to your Notion workspace, allowing you to search, create, and manage content using natural language.
Trello
Integrates with Trello to manage projects, boards, and cards, using Nango for authentication.
Bitrix24
Interact with and manage your Bitrix24 CRM instance through a powerful set of tools.
Mercado Pago
Mercado Pago's official MCP server, offering tools to interact with our API, simplifying tasks and product integration.
OSP Marketing Tools for Node.js
A suite of tools for technical marketing content creation, optimization, and product positioning based on Open Strategy Partners' methodologies.