LedgerMind is a personal CFO-style financial analysis engine that turns raw transaction data into grounded financial insights and actionable recommendations.
LedgerMind answers personal finance questions like:
“How did I do last month and what should I change?”
Instead of relying on free-form LLM responses, LedgerMind plans and executes deterministic financial tools against normalized transaction and budget data, then generates a structured answer backed by verifiable evidence.
LedgerMind focuses on reliable AI-assisted financial analysis through:
- Tool-first architecture for deterministic financial calculations
- Structured outputs with citations linking insights to source data
- Validation layers that detect unsupported numbers or assumptions
- Local-first model execution using locally hosted LLMs
Key directories:
src/application/: orchestration services (planner,tool_executor,answer,validator, engine)src/domain/: Pydantic schemas and core modelssrc/infrastructure/: provider adapters, LLM client, persistence, policy profile storesrc/tools/: tool implementations and registrysrc/interface/: CLI and FastAPI entrypointsscripts/actual/: Python helper functions/CLI bridges for Actual (actualpy)tests/: unit tests
Important flow:
interface.cli.build_engine()builds the engine from planner + tool registry + executor + answer service- tools are auto-registered via
src/tools/__init__.py - transaction-based tools call
infrastructure.get_transactions.get_transactions ActualLedgerProviderreads from Actual via Python helpers inscripts/actual/
Tested setup:
- Python
3.11.x(recommended baseline) - An Actual server instance running (desktop/server)
- Access to your Actual file via
ACTUAL_SYNC_ID(orACTUAL_FILE)
- Create and activate a virtual environment
python3 -m venv .venv
source .venv/bin/activate- Install dependencies
pip install -r requirements.txt
pip install -e .- Configure environment
cp .env.example .envUpdate .env with your values:
ACTUAL_SERVER_URLACTUAL_PASSWORDACTUAL_SYNC_ID(or setACTUAL_FILE)ACTUAL_DATA_DIR(default.actual-cacheis fine)
Optional LLM config (for planner/answer generation):
OLLAMA_BASE_URLOLLAMA_MODELOLLAMA_TIMEOUT_SECONDS
python main.pyYou will be prompted for a message, then LedgerMind prints a structured JSON answer.
uvicorn interface.api:app --app-dir src --reloadThen open:
http://127.0.0.1:8000/(minimal test UI)http://127.0.0.1:8000/health
Examples of registered tools:
ledgers.month_summaryledgers.category_summarydetect.recurring_chargesdetect.anomaliesforecast.cashflow_30dpolicy.check_recommendation
LedgerMind keeps lightweight durable memory for the answer stage only (not the planner).
- Memory file path:
memory/memory.json(override withLEDGERMIND_MEMORY_FILE) - Max entries:
300by default (override withLEDGERMIND_MEMORY_MAX_ITEMS) - New memory to persist is returned in
EngineAnswer.memory
Flow:
AnswerServiceloads recent memory and passes it toAnswerLLM.AnswerLLMcan return new memory entries inEngineAnswer.memory.AnswerServiceappends those entries to the memory file (deduped and bounded).
Manual/offline summarizer:
python scripts/memory/summarize_memory.pyThis generates memory/memory_summary.json and is intentionally outside the normal request flow.
Run the full test suite:
python -m unittestRun a focused tool test file:
python -m unittest tests/test_tools_new.py -vactualpyimport errors:- confirm your virtualenv is active
- run
pip install -r requirements.txt
- Actual connection/auth errors:
- verify
ACTUAL_SERVER_URL,ACTUAL_PASSWORD, andACTUAL_SYNC_IDin.env
- verify
- Empty or broad tool results:
- check
date_rangein tool args (many analytics tools depend on it).
- check