Skip to content

darth-dodo/ledger

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

9 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

Ledger

Your financial ledger. Ask anything.

Upload bank statements, auto-parse transactions, and chat with your financial data using AI.

Tests Codecov License

NestJS Angular TypeScript PostgreSQL Mistral AI Vercel AI SDK ReAct Agent Tailwind CSS


The Problem

Bank statements sit in downloads folders as PDFs and CSVs. Understanding spending patterns means manual spreadsheet work. Searching for a specific transaction means scrolling through pages of data.

How Ledger Solves It

  1. Upload -- Drag and drop any bank statement (PDF or CSV)
  2. Parse -- Transactions are automatically extracted and categorized by AI
  3. Embed -- Statement content is chunked and vectorized for semantic search
  4. Ask -- Chat with your financial data in natural language
  5. Visualize -- See spending patterns on interactive dashboards (coming soon)

Features

Feature Status Description
Statement Upload โœ… Drag-and-drop PDF/CSV with multi-bank support
Transaction Parsing โœ… Extensible parser strategy (PDF + CSV heuristics)
AI Categorization โœ… Mistral-powered batch categorization of transactions
Vector Embeddings โœ… pgvector storage with cosine similarity search
RAG Chat โœ… Natural language Q&A over your financial data
Agentic ReAct Loop โœ… Multi-step tool-calling agent (think โ†’ act โ†’ observe)
Adaptive Query Decomposition โœ… LLM breaks compound questions into typed sub-queries
Chart Data Tool โœ… Agent generates chart-ready data (label/value columns)
Category Updates via Chat โœ… Re-categorize transactions through conversation
LLM Thinking Display โœ… Transparent ReAct loop with live tool-call streaming
Dashboard ๐Ÿšง Visual analytics and spending breakdowns
Auth & Polish ๐Ÿšง User accounts and production hardening

Screenshots

Chat with Thinking Display

The agentic ReAct loop is fully transparent. While the LLM works, you see its thought process in a live-expanding accordion -- query decomposition, reasoning, SQL queries, and search results. The accordion auto-collapses when the final answer arrives.

Thinking expanded Response with collapsed thinking
Thinking expanded Chat response

Architecture

graph TB
    subgraph Frontend ["Angular Frontend :4200"]
        UP[Upload Page]
        TX[Transactions View]
        CH[Chat Page]
    end

    subgraph Backend ["NestJS Backend :3000"]
        UC[Upload Controller]
        TC[Transactions Controller]
        RC[RAG Controller]
        HC[Health Controller]

        US[Upload Service]
        PS["Parsers (PDF + CSV)"]
        MS[Mistral Service]
        CS[Chunker Service]
        ES[Embeddings Service]
        TS[Transactions Service]
        RS[RAG Service]
        AG["Agent Tools\n(think, decompose_query,\nsql_query, vector_search,\nupdate_category, chart_data, done)"]
    end

    subgraph Data ["PostgreSQL + pgvector"]
        ST[(statements)]
        TT[(transactions)]
        EM[(embeddings)]
        SS[(chat_sessions)]
        SM[(chat_messages)]
    end

    subgraph External ["Mistral AI"]
        CAT[Categorize]
        EMB[Embed]
        LLM[mistral-large-latest]
    end

    UP -->|POST /upload| UC
    TX -->|GET /transactions| TC
    CH -->|POST /chat SSE| RC

    UC --> US --> PS --> MS --> CAT
    US --> CS --> ES --> EMB
    US --> ST
    US --> TT
    ES --> EM
    TC --> TS --> TT
    RC --> RS --> MS --> LLM
    RS --> AG --> TT
    RS --> AG --> EM
    RS --> SS
    RS --> SM

    style Frontend fill:#e8f4f8
    style Backend fill:#fff3cd
    style Data fill:#d4edda
    style External fill:#f8d7da
Loading

Quick Start

# Clone and install
git clone git@github.com:darth-dodo/ledger.git
cd ledger && pnpm install

# Start PostgreSQL (with pgvector)
docker compose up -d

# Configure environment
cp backend/.env.example backend/.env
# Add your MISTRAL_API_KEY to backend/.env

# Start backend (port 3000)
cd backend && pnpm dev

# Start frontend (port 4200)
cd frontend && pnpm dev

Development

# Run all tests (336 tests)
make test

# Run with coverage
make test-coverage                     # Backend + frontend coverage

# Individual test suites
cd backend && pnpm test                # 278 backend tests
cd frontend && pnpm test               # 58 frontend tests (with coverage)

# Type check
cd backend && pnpm build

# Database migrations
cd backend && pnpm migrate             # Run pending migrations
cd backend && pnpm migration:revert    # Revert last migration

Coverage

Module Statements Branches Functions Lines
Backend 96% 91% 100% 96%
Frontend 94% 93% 85% 96%

Coverage is enforced in CI and thresholds are set at 85% for the backend (backend/vitest.config.ts).

Tech Stack

Layer Technology Purpose
Frontend Angular 21, Tailwind CSS 4, daisyUI SPA with standalone components
Backend NestJS 11, TypeORM REST API with dependency injection
Database PostgreSQL + pgvector Relational data + vector embeddings
AI Mistral AI + Vercel AI SDK Categorization, embeddings, ReAct agent streaming
Testing Vitest Unit + integration tests (336 total)
Runtime tsx, pnpm TypeScript execution, package management

Project Structure

ledger/
โ”œโ”€โ”€ backend/                # NestJS API (port 3000)
โ”‚   โ””โ”€โ”€ src/
โ”‚       โ”œโ”€โ”€ upload/         # POST /upload, GET/DELETE /statements
โ”‚       โ”œโ”€โ”€ transactions/   # GET /transactions, PATCH /transactions/:id
โ”‚       โ”œโ”€โ”€ embeddings/     # Chunking + vector embedding pipeline
โ”‚       โ”œโ”€โ”€ mistral/        # Mistral AI client (categorize + embed + chatStream)
โ”‚       โ”œโ”€โ”€ rag/            # Chat sessions, ReAct agent, 7 agent tools
โ”‚       โ”œโ”€โ”€ health/         # GET /health
โ”‚       โ””โ”€โ”€ db/             # Migrations and data source config
โ”œโ”€โ”€ frontend/               # Angular SPA (port 4200)
โ”‚   โ””โ”€โ”€ src/app/
โ”‚       โ”œโ”€โ”€ core/           # Services (ApiService)
โ”‚       โ”œโ”€โ”€ shared/         # Reusable components (FileDropzone)
โ”‚       โ””โ”€โ”€ features/       # Page components (Upload, Chat, Settings)
โ”œโ”€โ”€ docs/
โ”‚   โ”œโ”€โ”€ product.md          # Product spec
โ”‚   โ”œโ”€โ”€ architecture.md     # System design
โ”‚   โ”œโ”€โ”€ adrs/               # Architecture decision records
โ”‚   โ””โ”€โ”€ milestones/         # Milestone docs and retros
โ””โ”€โ”€ docker-compose.yml      # PostgreSQL + pgvector

Documentation

About

๐Ÿงฎ Privacy focused Agentic RAG over financial statements

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors