A Go-based system that uses Google's Gemini Flash model to categorize transaction records into structured data.
- LLM Integration: Uses Gemini Flash via the official
google.golang.org/genaiSDK. - Structured Output: Returns strict JSON with fields like
category,amount,merchant, etc. - Single-Request Batch Processing: Efficiently categorizes multiple records in a single LLM call to save time and quota.
- Go 1.25+
- A Google Cloud Project with the Gemini API enabled.
- an API Key for Gemini.
- Clone the repository.
- Install dependencies:
go mod tidy
-
Create a
.envfile:cp .env.example .env # Edit .env and paste your API key -
Run the categorizer:
make run # Or directly: go run cmd/categorizer/main.go
Run the test suite:
make testBuild the binary:
make buildThe binary will be created at bin/categorizer.
The CLI processes a predefined list of records:
- "Supermarket"
- "Banana"
- "Ifood"
- "Uber"
- "Transfer 100 to Alex"
- "Netflix Subscription"
- "Salary deposit"
- "Dentist appointment"
[
{
"original": "Transfer 100 to Alex",
"category": "transfer",
"merchant_or_counterparty": "Alex",
"direction": "out",
"amount": 100,
"currency": "BRL",
"confidence": 0.87
}
]pkg/categorizer: Core domain logic and types.types.go: Data structures.llm.go: Gemini client integration (usinggoogle.golang.org/genai).service.go: Business logic service.
cmd/categorizer: CLI entry point.