An AI-powered transaction categorization tool for MoneyMoney on macOS that uses Large Language Models to intelligently suggest categories for uncategorized transactions.
- π€ AI-Powered Categorization: Uses LM Studio local LLM to analyze transactions and suggest appropriate categories with confidence levels
- π¨ Colorful Interactive Interface: Beautiful CLI with emojis, colors, and single-key navigation (no Enter key needed)
- π Fuzzy Search: Find categories quickly with partial matching and fuzzy string matching
- π Smart Category Filtering: Only shows assignable leaf categories, automatically excludes parent/folder categories
- π¬ Rich Transaction Context: Displays user comments, bank booking text, and purpose information for better categorization
- π Dry Run Mode: Preview categorization without making changes
- π§ͺ Test Mode: Non-interactive testing mode for CI/CD and debugging
- π Flexible Date Range: Process transactions from specific date ranges
- π¦ Account Information: Shows transaction account names and details
- π Comprehensive Logging: Detailed logging for debugging and monitoring
- macOS: Required for MoneyMoney AppleScript integration
- MoneyMoney: The financial management application must be installed and running
- LM Studio: Local LLM server for AI categorization
- Python 3.9+: Required for running the application
-
Clone the repository:
git clone <repository-url> cd MoneyMoneyAutomator
-
Install Python dependencies:
pip install -r requirements.txt
-
Set up LM Studio:
- Install LM Studio
- Download and load a compatible language model
- Start the local server (default: http://localhost:1234/v1)
-
Configure MoneyMoney:
- Ensure MoneyMoney is installed and accessible
- The application will use AppleScript to communicate with MoneyMoney
The application can be configured using environment variables:
| Variable | Default | Description |
|---|---|---|
LM_STUDIO_URL |
http://localhost:1234/v1 |
LM Studio API base URL |
NUM_SUGGESTIONS |
5 |
Number of AI suggestions to show |
LOG_LEVEL |
INFO |
Logging level (DEBUG, INFO, WARNING, ERROR) |
You can set these in your shell:
export LM_STUDIO_URL="http://localhost:1234/v1"
export NUM_SUGGESTIONS="3"
export LOG_LEVEL="DEBUG"Process uncategorized transactions from the last 30 days:
python3 categorizer.pypython3 categorizer.py [OPTIONS]Options:
--from-date YYYY-MM-DD: Start date for transactions (default: 30 days ago)--to-date YYYY-MM-DD: End date for transactions (default: today)--dry-run: Preview mode - show what would be done without making changes--test: Non-interactive test mode - requires LLM suggestions and fails if none provided
# Process transactions from the last week
python3 categorizer.py --from-date 2024-01-15
# Process specific date range
python3 categorizer.py --from-date 2024-01-01 --to-date 2024-01-31
# Dry run to see what would happen
python3 categorizer.py --dry-run
# Non-interactive test mode for CI/CD (validates LLM integration)
python3 categorizer.py --test
# Process last 7 days with debug logging
LOG_LEVEL=DEBUG python3 categorizer.py --from-date $(date -d '7 days ago' +%Y-%m-%d)-
Initialization:
- Connects to LM Studio server
- Loads categories from MoneyMoney
- Validates configuration
-
Transaction Loading:
- Retrieves uncategorized transactions from MoneyMoney
- Filters by date range
-
AI Processing:
- Sends transaction details to LM Studio
- Receives AI-generated category suggestions
- Validates suggestions against available categories
-
User Interaction:
- Displays transaction details and AI suggestions
- Provides options to accept suggestions or search manually
- Applies selected categorization to MoneyMoney
When processing each transaction, you have several options (no Enter key needed):
- π― [1-5]: Accept an AI suggestion
- π [s]: Search all categories manually
- βοΈ [n]: Skip this transaction
- πͺ [q]: Quit the application
- Enter search terms (minimum 2 characters)
- Uses fuzzy matching to find relevant categories
- Shows up to 10 best matches
- Navigate back to suggestions or continue searching
MoneyMoneyAutomator/
βββ categorizer.py # Main application entry point
βββ config.py # Configuration management
βββ llm_client.py # LM Studio API client
βββ moneymoney_client.py # MoneyMoney AppleScript interface
βββ category_selector.py # Interactive category selection
βββ requirements.txt # Python dependencies
βββ tests/ # Test files
βββ README.md # This file
Main application class that orchestrates the categorization process.
Handles communication with the LM Studio local LLM server for AI-powered categorization suggestions.
Manages AppleScript-based communication with MoneyMoney for reading transactions and applying categories.
Provides interactive user interface for category selection with fuzzy search capabilities.
The application includes comprehensive error handling:
- Connection Errors: Validates LM Studio connectivity
- AppleScript Errors: Handles MoneyMoney communication issues
- JSON Parsing: Gracefully handles malformed LLM responses
- User Input: Validates and sanitizes user input
Detailed logging is available at multiple levels:
- Transaction processing status
- API communication details
- Error messages and stack traces
- Performance metrics
Set LOG_LEVEL=DEBUG for verbose output during troubleshooting.
Run the test suite:
pytest tests/Run with coverage:
pytest tests/ --cov=. --cov-report=htmlTest the full application including LLM integration:
python3 categorizer.py --testThis will:
- β Validate LM Studio connection
- β Ensure AI suggestions are generated
- β Test transaction processing pipeline
- β Fail with exit code 1 if LLM doesn't provide suggestions
Perfect for CI/CD pipelines to ensure the AI integration is working correctly.
"Cannot connect to LM Studio"
- Ensure LM Studio is running and accessible
- Check the URL configuration
- Verify firewall settings
"No categories found in MoneyMoney"
- Ensure MoneyMoney is running
- Check that categories exist in your MoneyMoney setup
- Verify AppleScript permissions
"EOF when reading a line"
- This occurs when running in non-interactive environments
- Use
--testmode for automated testing and CI/CD - Use
--dry-runfor preview without changes - Run in a proper terminal for interactive use
Enable debug logging for detailed troubleshooting:
LOG_LEVEL=DEBUG python3 categorizer.py --dry-run- Fork the repository
- Create a feature branch
- Add tests for new functionality
- Ensure all tests pass
- Submit a pull request
This project is licensed under the MIT License - see the LICENSE file for details.
- MoneyMoney: Excellent financial management software for macOS
- LM Studio: Local LLM server for privacy-focused AI processing
- FuzzyWuzzy: Fuzzy string matching for category search