A Singapore-focused application that uses Generative AI to analyze consumer spending patterns and provide multi-card synergy recommendations with strategic usage guidelines. The system uses an agentic architecture leveraging the Model Context Protocol (MCP) to power AI-driven chat for scenario planning and T&C clarifications.
- Spending Analysis: Analyze transaction data to create a comprehensive spending profile
- Merchant Categorization: Categorize merchant names into spending categories using a distilled model trained on ACRA business data
- Card Recommendation: Recommend optimal credit card combinations based on spending patterns and user preferences
- Strategic Usage: Provide specific advice on which card to use for which spending category
- T&C Insights: Answer natural language questions about card terms and conditions
project/
├── app.py # Launcher script for Streamlit app
├── src/ # Main source code
│ ├── agent/ # Card optimizer agent implementation
│ │ └── agent.py # Main agent implementation
│ ├── card_processing/ # Card data processing modules
│ │ └── vector_db.py # Vector database implementation
│ ├── data_collection/ # Data collection utilities
│ ├── model_context_protocol/ # MCP implementation
│ │ ├── client.py # MCP client for server communication
│ │ └── card_data_server.py # Card data access server
│ ├── statement_processing/ # Statement analysis modules
│ │ ├── merchant_categorizer.py # Merchant categorization model
│ │ ├── merchant_categorizer_trainer.py # Training for categorizer
│ │ └── pdf_statement_parser.py # PDF parsing module
│ └── user_interface/ # Streamlit UI components
│ ├── Welcome.py # Main Streamlit entry point
│ ├── components.py # Reusable UI components
│ ├── utils.py # UI utility functions
│ └── pages/ # Additional app pages
├── models/ # Trained models
│ └── merchant_categorizer/ # Merchant categorization models
├── data/ # Data storage
│ ├── card/ # Card data
│ ├── card_tcs/ # Card terms and conditions
│ │ └── pdf/ # Original T&C PDFs
│ ├── categorization/ # Categorization data
│ ├── sample_statements/ # Sample card statements for testing
│ └── vector_db/ # Vector database storage
├── notebooks/ # Jupyter notebooks for analysis
├── docs/ # Documentation files
├── results/ # Analysis results and outputs
├── logs/ # Application logs
└── requirements.txt # Python dependencies
- python>=3.13
-
Create a virtual environment:
python -m venv venv source venv/bin/activate # On Windows: .\venv\Scripts\Activate.ps1
-
Install dependancies:
apt-get install build-essential libpoppler-cpp-dev pkg-config ocrmypdf
or
brew install gcc@11 pkg-config poppler ocrmypdf
For Windows, you have to manually find these binaries and ensure they are discoverable. It is likely that these would be available on Windows package managers like
WingetorChocolatey, but I have not tested them yet. -
Install requirements:
pip install -r requirements.txt
-
Create a .env file by copying .env.example and filling in required values.
-
Start the MCP server:
python -m src.model_context_protocol.card_data_server
-
(In a new terminal window) Run the Streamlit application:
python app.py
For Docker, see DOCKER.md.
src/statement_processing/merchant_categorizer.py- Model for categorizing merchant namessrc/statement_processing/merchant_categorizer_trainer.py- Training pipeline for categorizer modelsrc/statement_processing/pdf_statement_parser.py- PDF statement parsing and data extraction
src/card_processing/vector_db.py- Vector database for card embeddings and T&C documentssrc/model_context_protocol/card_data_server.py- MCP tools for card data access including semantic search
src/agent/agent.py- Main agent implementation for card recommendations and scenario analysis
src/card_processing/vector_db.py- Vector database for T&C document storagesrc/model_context_protocol/card_data_server.py- Tools for T&C querying
app.py- Main application entry pointsrc/user_interface/Welcome.py- Streamlit UI main pagesrc/user_interface/components.py- Reusable UI componentssrc/user_interface/utils.py- UI utility functions
The system implements core MCP tools through the src/model_context_protocol/card_data_server.py:
get_available_cards()- Returns a list of all available cards with basic metadataget_card_details(card_id)- Returns complete card information in its original formatquery_tc(question, card_id)- Natural language queries about card terms and conditionssearch_cards(query)- Semantic search for cards matching natural language criteria