A Node.js-based agent that processes M-Pesa SMS messages, extracts transaction details, categorizes expenses, and provides spending insights.
# M-Pesa Transaction Analyzer 💵
A simple but powerful Node.js agent that helps you understand where your money is going by analyzing M-Pesa SMS transactions.
## Features ✨
- **SMS Parsing**: Automatically extracts transaction details from M-Pesa SMS messages
- **Smart Categorization**: Intelligently categorizes spending into Food, Transport, Bills, Shopping, and more
- **Transaction Storage**: Saves all transactions in a JSON file for persistence
- **Spending Analysis**: Generates detailed spending summaries and breakdowns
- **Interactive CLI**: User-friendly command-line interface for easy data input and viewing
## Quick Start 🚀
### Installation
```bash
# Clone or navigate to the project directory
cd mpesa-transaction-analyzer
# Install dependencies (Node.js built-ins only)
npm install
```
### Running the Application
```bash
# Start the analyzer
npm start
```
## Usage 📖
### Main Menu Options
```
1. Add new M-Pesa SMS - Parse and add M-Pesa message
2. View all transactions - See all recorded transactions
3. Generate spending summary - Get total spending by type
4. View spending by category - See breakdown by categories
5. Delete transaction - Remove a specific transaction
6. Clear all transactions - Delete everything (use carefully!)
7. Export transactions - View JSON file location
8. Exit - Close the application
```
### Example M-Pesa Messages
The parser supports various M-Pesa message formats:
```
✅ You have sent KSh1,500 to stem kirigi. Balance is KSh5,234.50
✅ You have received KSh2,000 from savannah kioko. Balance is KSh7,234.50
✅ KSh50 paid to Safaricom for airtime. Balance is KSh7,184.50
✅ Withdrawal of KSh5,000 at MM123456. Balance is KSh2,184.50
```
### Data Storage 💾
All transactions are stored in `transactions.json` in the following format:
```json
{
"transactions": [
{
"id": "1234567890-abc123",
"amount": 1500,
"type": "sent",
"recipi …