LedgerLens

AI-assisted transaction mapping for messy financial data.

Kind
Side project
Year
Status
Live
Stack
  • C# / .NET 9
  • ASP.NET Core
  • EF Core + SQLite
  • Blazor WebAssembly
  • Mock AI
Outcome
The real C# pipeline, running in your browser

The problem

Real-world transaction data is not clean. A bank or payment processor hands you strings like these:

AMZN Mktp US*8H2K91 SQ *LOCAL COFFEE PAYPAL *DIGITALOCEAN OPENAI *CHATGPT SUBSCRIPTION WM SUPERCENTER #2857

Categorizing these by hand is tedious and error-prone at scale. Handing the problem entirely to an AI model introduces a different risk: opaque decisions, inconsistent outputs, and no way to audit why a transaction was labeled the way it was.

Neither extreme fits real enterprise software. You want deterministic rules where rules work, AI assistance where they don't, and a human in the loop before anything gets committed.

The solution

LedgerLens routes every transaction through a fixed, ordered pipeline. Each step only runs if the previous one didn't resolve the transaction.

  1. 01
    Normalize

    Strip noise characters, collapse whitespace, uppercase the description. Turn SQ *LOCAL COFFEE into LOCAL COFFEE.

  2. 02
    Match existing rules

    Walk the rule library in priority order — exact match first, then contains rules, then regex patterns. First match wins. No suggestion call needed.

  3. 03
    Ask the suggestion provider

    If no rule matches, the normalized description goes to a suggestion provider behind a single interface, which returns a structured result: vendor, category, confidence, and a reason. The public demo uses a deterministic mock provider; a real model slots in behind the same contract.

  4. 04
    Queue for review

    AI output never goes directly into the database. It enters a review queue. A human sees the suggestion before anything is committed.

  5. 05
    Approve, edit, or reject

    The reviewer accepts the suggestion, modifies the category, or rejects it. Every outcome is recorded with a timestamp and user identifier.

  6. 06
    Write a rule

    An approved suggestion becomes a new mapping rule. The next identical or similar transaction matches the rule and never touches the AI layer.

  7. 07
    Append to audit log

    Every action — rule match, AI suggestion, approval, rejection, rule creation — is written to an append-only audit table with timestamp and user. Nothing is overwritten.

Architecture

Six focused projects, each with one job and one direction of dependency. The core business logic has no infrastructure dependencies — no EF Core, no HTTP, no AI client — which is what lets the same pipeline run on a server and, compiled to WebAssembly, in this page.

LedgerLens.Web
ASP.NET Core host: Minimal API endpoints (health, dashboard, transactions, suggestions, rules, audit) plus a server-rendered Razor Pages UI for the review queue. No client-side framework. Depends on Core, Data, and AI.
LedgerLens.Browser
Blazor WebAssembly host for the demo on this page. Same Core pipeline, same mock provider, an in-memory store instead of SQLite. Depends on Core and AI only, so EF Core and the server never ship to the browser.
LedgerLens.Tests
xUnit suite, 120+ tests, runs with no database server, network, or secrets. Covers the normalizer, rule matcher, workflow, both store implementations against one contract, and the demo seed.
LedgerLens.Core
Business logic only: normalizer, priority-ordered rule matcher, the mapping workflow, input validation, and the demo seed. Persistence is one small interface. No EF Core, no HTTP, no AI client. Fully testable in isolation.
LedgerLens.AI
The suggestion provider behind one interface. The public demo ships a deterministic mock, and the app refuses to start if any other provider is configured, so a misconfigured deploy can never make paid API calls. A real model provider slots in without touching the pipeline.
LedgerLens.Data
EF Core DbContext, migrations, and the SQLite-backed implementation of the store interface. Swappable for SQL Server or Postgres with no application-layer changes.

Interactive demo

This is the LedgerLens pipeline — the same C# code the server runs — compiled to WebAssembly and running in your browser. Pick a sample description or type your own, watch it normalize, hit a rule or fall through to the mock suggestion, then approve or reject to see a reusable rule and an audit entry appear.

If the demo does not load, your browser may be blocking embedded frames or WebAssembly. The screenshots below show the server version of the same flow.

Demo safety

  • Runs entirely in your browser. Nothing you type is sent anywhere; refreshing resets it.
  • All seeded transactions are synthetic — fabricated for demo purposes.
  • The AI provider is a local mock. No external AI service is called.
  • No paid APIs are used. No API keys exist anywhere in the project.

The server version

The ASP.NET Core app with SQLite and the REST API is the system of record; the browser demo above runs the same Core pipeline against an in-memory store.

LedgerLens transaction queue: raw and normalized descriptions, amounts, and a status of pending review, rule matched, or approved on each row
The queue. Rows that matched a rule never needed a suggestion; the rest wait for a reviewer.
LedgerLens review cards showing vendor, category, subcategory, confidence, and the mock provider's reasoning, with approve and reject buttons
Pending suggestions. Approving one writes a reusable rule; low-confidence results are flagged for a closer look.

Why this project

The transaction mapper is the vehicle. The point is to show what responsible AI integration looks like inside a real .NET codebase — the engineering parts that actually matter in production.

Validation at the boundary
AI responses are validated against a strict schema before they touch the application. Malformed or out-of-schema outputs are rejected and logged, not silently accepted.
Human review
No AI output is written directly to the database. Every suggestion passes through a queue and requires a human decision. The AI assists — it doesn't decide.
Deterministic fallback
Rules are evaluated first. Predictable, auditable, and free. AI is the fallback, not the primary path. The rule library grows over time and AI calls become rarer.
Auditability
Every categorization is traceable to a specific rule match or a specific reviewer decision at a specific timestamp. Nothing is a black box.
Cost-conscious AI usage
Approved suggestions become reusable rules. The next similar transaction never hits the API. Token usage decreases as the rule library matures.
Clean persistence
EF Core with a focused DbContext, append-only audit table, and no God-object repositories. The data layer is deliberately boring.

Status and what's next

Version 0.2.0 runs in your browser above. The pipeline, review flow, audit log, and dashboard are done. What remains is a real AI provider behind the existing interface and quality-of-life features.

Shipped

v0.2.0

  • Normalizer and priority-ordered rule matcher (exact, contains, regex)
  • EF Core schema and migrations on SQLite
  • Review queue with approve, edit, and reject
  • Approved suggestions written back as reusable rules
  • Append-only audit log
  • Dashboard metrics in the UI and API
  • Server-rendered Razor Pages UI
  • Docker image and automated CI
  • Startup guardrail that enforces the mock provider on the public demo
  • Browser demo: the Core pipeline compiled to WebAssembly, embedded in this page
Next

Planned

  • Real AI provider (structured outputs) behind the existing interface, off by default
  • CSV transaction upload
  • Rule priority editor and conflict detection
  • Confidence threshold to skip review on high-confidence suggestions
  • Export approved mappings