Rust app that fetches your Investec transactions and categorizes them using AI.
-
Clone the repository:
git clone https://github.com/dylanvanh/investec-transaction-buckets cd investec-transaction-buckets -
Setup environment variables:
cp .env.example .env # Edit .env with your actual API credentials -
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
-
Run with Docker Compose:
docker compose up -d
-
View logs:
docker compose logs -f app
-
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, themigrations/folder is copied into the image. -
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
-
Install dependencies:
- Rust 1.85+
- PostgreSQL (local or Docker)
- Either Ollama or Gemini API key
-
Clone and build:
git clone https://github.com/dylanvanh/investec-transaction-buckets cd investec-transaction-buckets cargo build -
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"
-
Get API keys:
- Investec: Login to online banking → API settings
- Gemini API: Get a Gemini API key (if using Gemini)
- Google Search API: Create Custom Search Engine (optional, improves Ollama)
-
If using Ollama, start it:
ollama pull tinyllama:latest ollama serve
-
Run:
cargo run
- 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
- Investec API credentials (required)
- Either Ollama running OR Gemini API key (choose one)
- Google Search API (optional, improves Ollama accuracy)
Transactions are categorized into: Food, Transportation, Entertainment, Bills & Utilities, Healthcare, Income, Transfers, Other.