● In production since 2026 · v2.48Product in production · Transaction auditing

Explainable transaction auditing

A platform that flags possible fraud and operational errors in the sales of a service-station chain

automated .NET and dashboard tests in the latest count (Oct 2026)
6,500+
line coverage of the detection module in the latest documented measurement (Oct 2026)
88%
rule types, plus user-defined rules, across 5 detectors
45
HTTP actions across 47 controllers
224

Technologies: C# / .NET 9 · ASP.NET Core 9 · .NET Framework 4.5 · PostgreSQL 16 · EF Core 9 + Dapper · Hangfire · SignalR · React 19 + TypeScript · Docker · Cloudflare Tunnel · xUnit + Testcontainers · GitHub Actions

The problem

The company already checked that daily totals balanced, but nobody reviewed individual transactions, and fraud can hide inside operations that balance. Each station keeps its sales in its own point-of-sale database and the company runs a separate central database, on different engines and, on some machines, a Windows Server too old for .NET 9. The link between the stations and the server can drop, and an outage could neither lose nor duplicate transactions. And those databases had to be read without ever writing to them or opening ports at the stations.

Goal

Give the company's auditors a single, near-real-time view of what happens at every station without changing the point-of-sale systems already in use. The platform had to flag possible fraud and operational errors, send possible fraud to the audit inbox and honest mistakes back to the station, and back every alert with evidence an auditor can check.

My contribution

I authored every commit in the platform's repository, which spans the reading agents, central API, detection engine, web dashboard, installers and deployment. It began as a Software Engineering thesis project at UDLA, co-authored and already defended, and since then I keep developing it as a production product. I build it with an AI-augmented software engineering workflow that I designed and direct: I define the architecture, the contracts between components and the acceptance criteria, and split the work among several AI agents (Claude) running in parallel, each owning its own files. Nothing is merged just because it compiles: every change is backed by automated tests, the riskiest ones are reviewed by an independent agent with a clean context, and targeted mutation testing proves the tests actually catch faults. Every decision is recorded in a change log with its rationale and verification.

LIVE ARCHITECTURE

Architecture

Every moving dot is data; amber marks alerts. Tap a component to see what it does and what it connects to.

Architecture: Explainable transaction auditingData flowToward the output
SourcesAt the stationIngestionCoreOutputInterface
SourcesAt the stationIngestionCoreOutputInterface

Tap a piece, or press Enter on it, to see what it does and what it connects to.

See every connection as a list
  • Point-of-sale database at each station to Station agentIncremental read-only extraction
  • Point-of-sale database at each station to Compatibility agentExtraction on older machines
  • Station agent to On-disk local queueStores what wasn't delivered
  • On-disk local queue to Cloudflare tunnelsResent at the start of each cycle
  • Station agent to Cloudflare tunnelsHTTPS + JWT: batches, heartbeat and live-query results
  • Compatibility agent to Cloudflare tunnelsHTTPS + JWT, with retry
  • Company central database to Central agentSELECT only, with a fallback path
  • Central agent to Cloudflare tunnelsHTTPS, with an ordered on-disk queue for undelivered batches
  • Cloudflare tunnels to Idempotent ingestionAgents' outbound calls
  • Idempotent ingestion to PostgreSQL 16Merge by identity + unique hash index
  • Central API to Station agentHeartbeat response: live queries and updates
  • Scheduled jobs (Hangfire) to Rules engineTriggers each detection cycle
  • PostgreSQL 16 to Rules engineNew transactions and windows
  • Rules engine to Risk scoringEach finding with its evidence
  • Risk scoring to PostgreSQL 16New alert or accumulated case (×N)
  • PostgreSQL 16 to Real timepg_notify / LISTEN
  • Real time to Audit dashboardSignalR by role and station
  • Risk scoring to EmailBy minimum level and rule flow
  • Audit dashboard to Central APIREST /api/v1 with JWT
  • Station monitor to Central APIPolls its station's issues
Overview: agents read in read-only mode and push data over HTTPS; the server detects, scores and notifies.

Decisions

  1. Push model with agents running as Windows services

    I had the agents call out to the central server over HTTPS, so no port is opened at any station and the platform doesn't expose their databases. The station agent runs as a Windows service and configures itself so that Windows restarts it if it crashes, and for machines on Windows Server 2012 or older, where .NET 9 won't start, I maintain a compatibility agent on .NET Framework 4.5.

  2. The station is the source of truth

    I set as a design rule that raw station data takes priority and that the central database is used only for what a station cannot provide or has been shown to store incorrectly. Central data arrives already consolidated and may be delayed or transformed, so relying on it would mean auditing a copy. Outside those exceptions, it is used to cross-check, not to replace.

  3. Explainable rules over machine learning

    In the thesis, machine learning was ruled out because there was no labelled data; as a product I kept explicit rules and a readable scoring formula, because an alert that can't say why it fired gets ignored. Where statistics were needed, as with tank inventory, I used outlier-resistant estimators that are easy to explain (median and MAD).

  4. Resending doesn't duplicate

    I designed delivery so that repeating a send doesn't duplicate data, rather than trying to make sure nothing is ever resent. Deduplication has three layers: SHA-256 fingerprints in the agent, merging by document identity on the server, and a unique index on station plus content hash in PostgreSQL, with per-row acknowledgements. That lets the agent retry every cycle without duplicating what was already delivered.

  5. Leaning on PostgreSQL instead of adding moving parts

    I also used PostgreSQL to store Hangfire's jobs and as the notification channel between instances (pg_notify and LISTEN), so several central instances can share real-time alerts without adding Redis. The API and the dashboard ship as a single Docker image.

What it does

  • Reading without touching the source

    Station agents read the point-of-sale database incrementally, always over a read-only connection, and a central agent queries the company's central database with SELECT only, with a fallback connection path. Each station agent authenticates with the JWT of its own service account, and ingestion rejects anything an account bound to one station tries to send for another. The station and central agents store their credentials encrypted with machine-level DPAPI.

  • Local queue with resend and quarantine

    If the server doesn't answer, the agent writes the batch to disk as a JSON file named after its SHA-256 hash and resends it at the start of every cycle. Anything the server rejects goes to a size-capped quarantine, and the extraction watermark only moves forward once both the read and the queue are complete: after an outage, data is re-read, never skipped.

  • Rules configured without redeploying

    Five detectors hold 45 rule types covering cash and shifts, invoicing and inventory, payment methods and regulatory compliance, plus the rules users create. Each rule keeps its threshold, parameters, lane and schedule (every cycle, interval, calendar or rolling window) in the database and is switched on or off from the UI. Users can write their own rules with conditions and aggregates, or with an expression language that has its own tokenizer, parser and evaluator and never executes code.

  • Risk scoring and accumulated cases

    Each finding gets a 0–100 score that multiplies the rule's base risk by amount, recurrence and station-history factors, compressing the top of the scale so critical alerts don't tie. A repeating pattern doesn't flood the inbox: the alert grows (×N) and escalates, with guards against flapping and reopening.

  • Self-explaining alerts

    Every alert automatically carries the identifying evidence its source provides (document, plate, customer, shift, amount or payment method) and, when its rule has one, the regulatory basis behind it. From the alert the auditor can open the full invoice, read live from the station, and can classify, assign, comment on and export the alert to PDF or Excel.

  • Real-time and email notifications

    Alerts reach the dashboard over SignalR, scoped by role and station, and by email based on a minimum level and per-rule flows. Staff at each station see their own operational issues in a read-only monitor that also raises browser desktop notifications.

  • Remotely managed agents

    The server leaves orders in the heartbeat response: live queries against the station database, and updates the agent downloads in the background and checks against a SHA-256 hash before replacing its executable.

  • Security and audit trail

    Access uses JWT with refresh tokens, roles, TOTP two-factor authentication and BCrypt-hashed passwords. PostgreSQL triggers make the activity log immutable: they reject deletes, truncation and any update except unlinking a deleted user.

It survives connection outages

on-disk queue · SHA-256

A local queue that stores and resends

Offline, the agent stores on disk the batches it could not deliver, each with its SHA-256 fingerprint, and resends them at the start of every cycle. Rejected data goes to a capped quarantine.

agent · server · database

Resending never duplicates

Fingerprints in the agent, idempotent upserts by document identity and a unique index in PostgreSQL: a resend creates no duplicate sales.

manifest · SHA-256

Verified updates

The server orders updates in the heartbeat response and each agent checks the package’s SHA-256 before installing it.

Every alert explains why it fired

There is no machine learning in the alerts: rules with thresholds the team edits and, where readings are noisy, robust statistics.

line coverage of the detection module in the latest documented measurement (Oct 2026)

82 out of 100, example risk

  • Rule and basis
  • Evidence
  • Risk 0–100
  • Live invoice
My own sketch of an alert’s parts. The figure is an example, not real data.

Outcome

Version 2.48 went into production on 21 October 2026, and the company's auditors work with the dashboard daily. The server runs as a single non-root Docker image behind Cloudflare tunnels; the station agent and the monitor are deployed with Windows installers, and the agents are updated remotely. The latest documented full run passed more than 6,000 automated .NET and dashboard tests, including integration tests against a real PostgreSQL through Testcontainers, and the latest documented measurement shows 88% line coverage in the detection module. GitHub Actions CI builds, tests, checks that no data-model change is left without its migration and validates the dashboard on every push and pull request to the main branch.

Limits

It uses no machine learning: detection relies on explicit rules and a readable scoring formula, so it only finds what its rules describe. It reads source databases without writing to them and notifies through the dashboard, email and the station monitor, with no WhatsApp, SMS or Web Push. The repository is not public, and this case study publishes no code, data, station or customer names, operating figures or dashboard screenshots: the diagrams are my own, generic ones.

This case shows no dashboard screenshots because it works with company data. It also leaves out internal rules, station names and the code, which is private. The diagrams are my own.

NEXT CASEAdministrador de Conexiones LAN