Skip to content

dylanvanh/investec-transaction-buckets

Repository files navigation

Investec Transaction Buckets

Rust app that fetches your Investec transactions and categorizes them using AI.

Docker Setup (Recommended)

  1. Clone the repository:

    git clone https://github.com/dylanvanh/investec-transaction-buckets
    cd investec-transaction-buckets
  2. Setup environment variables:

    cp .env.example .env
    # Edit .env with your actual API credentials
  3. Required variables in .env:

    # Required - Investec API
    INVESTEC_X_API_KEY=your_investec_api_key_here
    INVESTEC_CLIENT_ID=your_client_id_here
    INVESTEC_CLIENT_SECRET=your_client_secret_here
    
    # Required - PostgreSQL Database
    DATABASE_URL=postgresql://username:password@localhost:5432/investec_transactions
    
    # AI Model (Ollama runs automatically in container)
    OLLAMA_MODEL=tinyllama:latest
    
    # Optional - for better classification accuracy
    GOOGLE_SEARCH_API_KEY=your_google_api_key_here
    GOOGLE_SEARCH_ENGINE_ID=your_search_engine_id_here
    CITY=cape town
  4. Run with Docker Compose:

    docker compose up -d
  5. View logs:

    docker compose logs -f app
  6. Migrations (sqlx-cli): Install the CLI and manage migrations locally or in CI.

    cargo install sqlx-cli --no-default-features --features rustls,postgres
    
    # create a new reversible migration
    sqlx migrate add -r add_new_table_or_index
    
    # apply, revert, inspect
    sqlx migrate run
    sqlx migrate revert
    sqlx migrate info

    The app runs migrations from disk at startup using Migrator::new(Path::new("./migrations")), so adding new SQL files does not require rebuilding the binary. In Docker, the migrations/ folder is copied into the image.

  7. Access database: PostgreSQL is available on port 5432. You can connect using:

    # Connect to PostgreSQL
    psql -h localhost -p 5432 -U investec -d investec_transactions

Local Development Setup

  1. Install dependencies:

    • Rust 1.85+
    • PostgreSQL (local or Docker)
    • Either Ollama or Gemini API key
  2. Clone and build:

    git clone https://github.com/dylanvanh/investec-transaction-buckets
    cd investec-transaction-buckets
    cargo build
  3. Setup credentials in .cargo/config.toml:

    [env]
    # Required
    INVESTEC_X_API_KEY = "your-investec-api-key"
    INVESTEC_CLIENT_ID = "your-client-id"
    INVESTEC_CLIENT_SECRET = "your-client-secret"
    DATABASE_URL = "postgresql://username:password@localhost:5432/investec_transactions"
    
    # Choose ONE AI service (required)
    # Option 1: Local AI (Ollama)
    OLLAMA_MODEL = "tinyllama:latest"
    
    # Option 2: Cloud AI (Gemini - includes built-in search)
    GEMINI_API_KEY = "your-gemini-api-key"
    GEMINI_MODEL = "gemini-1.5-flash"
    
    # Optional: Improves Ollama accuracy (not needed for Gemini)
    GOOGLE_SEARCH_API_KEY = "your-google-search-api-key"
    GOOGLE_SEARCH_ENGINE_ID = "your-search-engine-id"
    
    # Optional
    CITY = "cape town"
  4. Get API keys:

  5. If using Ollama, start it:

    ollama pull tinyllama:latest
    ollama serve
  6. Run:

    cargo run

How it works

  • Fetches recent transactions from Investec API
  • Uses AI (Ollama or Gemini) to classify transactions into buckets
  • Gemini uses built-in Google Search, Ollama can use external search for better accuracy
  • Outputs categorized transactions

Requirements

  • Investec API credentials (required)
  • Either Ollama running OR Gemini API key (choose one)
  • Google Search API (optional, improves Ollama accuracy)

Buckets

Transactions are categorized into: Food, Transportation, Entertainment, Bills & Utilities, Healthcare, Income, Transfers, Other.

About

Rust app that fetches Investec transactions and AI-categorizes them. Supports Ollama + Gemini with Docker.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published