GitHub - victoroki/MPESAAnalyzer

๐Ÿ“Š M-Pesa Transaction Analyzer

A React Native mobile application that automatically analyzes your M-Pesa transaction history by reading SMS messages and providing insightful spending analytics.

โœจ Features

  • ๐Ÿ“ฑ Automatic SMS Reading - Scans and parses M-Pesa SMS messages
  • ๐Ÿ’ฐ Transaction Categorization - Automatically categorizes expenses (Shopping, Food, Transport, Bills, etc.)
  • ๐Ÿ“ˆ Analytics Dashboard - Visual representation of spending patterns with pie charts
  • ๐Ÿ“Š Transaction History - Detailed view of all your M-Pesa transactions
  • ๐Ÿ” Spending Insights - Get personalized insights into your spending habits
  • ๐Ÿ’พ Local Storage - Securely stores transaction data on your device
  • โณ Date Range Filtering - Analyze spending within specific date ranges
  • ๐Ÿ”„ Enhanced Loading Experience - Beautiful animations during SMS processing
  • ๐Ÿ“… Custom Date Selection - Choose specific periods for analysis

๐Ÿš€ Getting Started

Prerequisites

Before you begin, ensure you have the following installed:

Installation

  1. Clone the repository
git clone https://github.com/victoroki/MPESAAnalyzer
cd mpesa-analyzer
  1. Install dependencies
npm install
# or
yarn install
  1. Install iOS dependencies (if building for iOS)
cd ios && pod install && cd ..
  1. Run the app

For Android:

npm run android
# or
yarn android

For iOS:

npm run ios
# or
yarn ios

๐Ÿ—๏ธ Project Structure

mpesa-analyzer/
โ”œโ”€โ”€ src/
โ”‚   โ”œโ”€โ”€ screens/
โ”‚   โ”‚   โ”œโ”€โ”€ DashboardScreen.tsx      # Home screen with overview
โ”‚   โ”‚   โ”œโ”€โ”€ TransactionsScreen.tsx   # List of all transactions
โ”‚   โ”‚   โ”œโ”€โ”€ AnalyticsScreen.tsx      # Charts and analytics
โ”‚   โ”‚   โ””โ”€โ”€ InsightsScreen.tsx       # Spending insights
โ”‚   โ”œโ”€โ”€ components/                   # Reusable components
โ”‚   โ”‚   โ”œโ”€โ”€ LoadingScreen.tsx        # Animated loading screen
โ”‚   โ”‚   โ”œโ”€โ”€ DateRangePicker.tsx      # Date range selection component
โ”‚   โ”‚   โ””โ”€โ”€ SMSReaderDemo.tsx        # Demo component for SMS reading
โ”‚   โ”œโ”€โ”€ contexts/                    # React contexts
โ”‚   โ”‚   โ””โ”€โ”€ LoadingContext.tsx       # Loading state management
โ”‚   โ”œโ”€โ”€ hooks/                       # Custom React hooks
โ”‚   โ”‚   โ””โ”€โ”€ useSMSReader.ts          # Hook for reading SMS messages
โ”‚   โ””โ”€โ”€ utils/                       # Utility functions
โ”œโ”€โ”€ App.tsx                           # Main app component
โ””โ”€โ”€ package.json

๐Ÿ› ๏ธ Built With

๐Ÿ“ฑ Permissions

The app requires the following permissions:

  • READ_SMS - To read M-Pesa transaction messages

The app only reads messages from M-Pesa (sender contains "MPESA") and does not access or store any other SMS messages.

๐Ÿ”’ Privacy & Security

  • All transaction data is stored locally on your device
  • No data is sent to external servers
  • Only M-Pesa messages are parsed and analyzed
  • You have full control over your data

๐Ÿงช How It Works

SMS Parsing

The app identifies M-Pesa transactions by parsing SMS messages with patterns like:

  • Sent Money: "XXX Confirmed. KshXX.XX sent to [Name] on..."
  • Received Money: "XXX Confirmed. You have received KshXX.XX from [Name]..."
  • Payments: "XXX Confirmed. KshXX.XX paid to [Merchant]..."
  • Withdrawals: "XXX Confirmed. KshXX.XX withdrawn from..."

Categorization

Transactions are automatically categorized based on keywords:

  • ๐Ÿ›’ Shopping - Shops, stores, supermarkets
  • ๐Ÿ” Food - Restaurants, cafes
  • ๐Ÿš— Transport - Fuel, petrol stations
  • ๐Ÿ’Š Health - Hospitals, clinics, pharmacies
  • ๐Ÿ’ก Bills - Utilities, rent
  • ๐Ÿ“š Education - Schools, universities
  • ๐Ÿ’ต Cash - ATM withdrawals
  • ๐Ÿ’ฐ Income - Money received
  • ๐Ÿ“ฆ Other - Unclassified transactions

๐Ÿค Contributing

Contributions are what make the open-source community amazing! Any contributions you make are greatly appreciated.

  1. Fork the Project
  2. Create your Feature Branch (git checkout -b feature/Feature)
  3. Commit your Changes (git commit -m 'Add some Feature')
  4. Push to the Branch (git push origin feature/Feature)
  5. Open a Pull Request

Please read CONTRIBUTING.md for details on our code of conduct and the process for submitting pull requests.

๐Ÿ› Known Issues

  • Currently only supports Android (iOS support coming soon)
  • SMS parsing patterns are optimized for Safaricom M-Pesa Kenya format

๐Ÿ“ TODO / Roadmap

  • Add iOS support
  • Export transactions to CSV/PDF
  • Budget setting and tracking
  • Enhanced loading animations
  • Date range filtering for analytics
  • Monthly/yearly spending comparisons
  • More granular category customization
  • Multi-language support
  • Dark mode
  • Backup and restore functionality

๐Ÿ“„ License

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

๐Ÿ‘จโ€๐Ÿ’ป Author

Your Name

๐Ÿ™ Acknowledgments

  • Thanks to the React Native community
  • M-Pesa for their transaction SMS format
  • All contributors who help improve this project

๐Ÿ“ž Support

If you encounter any issues or have questions:

  1. Check the Issues page
  2. Create a new issue if your problem isn't already listed
  3. Provide as much detail as possible (device, Android version, error messages)

โญ Star this repo if you find it helpful!