Cut any link in the books and watch a Relate graph catch it, in your browser, with no key and no install.

Live demo: https://automationbot24x7.github.io/trailmark/web/ · Code (MIT): https://github.com/Automationbot24x7/trailmark · Relate store: store/trailmark.rl in the repo

All data is invented sample data: vendors, people, GSTINs, bank accounts and amounts. Every finding comes from Cypher over the graph; there is no AI model in the product.

Test it in 30 seconds

  1. Open the live demo and press Break the books in the left panel.
  2. Click the scissors on the receipt link of the invoice it opens. The link is deleted from the graph in your tab with a real DELETE, all six checks run again in milliseconds, and the invoice becomes an exception with the same receipt offered back as the fix. Restore sample books puts everything back.
  3. Open INV-1042. Text search scores receipt GRN-5404 a perfect 1.00, and the graph strikes it out because it already belongs to PO-7604.

Why it needs a graph

  • The graph overrules the text match. One statement runs a vector search over receipt descriptions and then graph rules: a lookalike already received against another PO is ruled out, however well it scores.
  • Paths of any shape, not fixed joins. One quantified path pattern finds every 1 to 3 hop route from a payment to any of our own employees, over five relationship types: who approved it, who entered the new bank details, who owns the receiving account. Another follows chains of bank reversals.
  • One file, three front ends. The browser (Relate as WebAssembly), the Python CLI and an MCP server for AI agents run the same .cypher files against store/trailmark.rl.

Inspiration

At every month-end, accounts-payable teams answer the same question for hundreds of invoices: why doesn't this one reconcile? The answer is never on one ledger. It sits across the purchase order, the goods receipt, the invoice, the payment, the bank statement and the GST return, so someone opens five spreadsheets and follows the trail by hand. That trail is a graph, and the breaks that cost money only show up when you can walk it.

What it does

Trailmark loads the AP ledgers into one Relate graph and runs six checks. Each check is a plain Cypher file, and each returns the broken link, the amount at risk, the nodes that prove it and the next step a reviewer takes:

  1. Invoice with no goods receipt. A vector search finds lookalike receipts from the same vendor; the graph rules out the ones already used and points at the receipt keyed against a PO number that doesn't exist. One click (or one agent tool call) links it, and the invoice turns green.
  2. Billed more than was received. Many receipts and many invoices are summed across one PO.
  3. Marked paid, but the money came back. One payment settles three invoices, leaves the bank as two debits, and one debit is returned. A quantified path pattern follows the reversal chain.
  4. The same invoice paid twice (BOS/889 and BOS-889), each copy with its own payment and bank line.
  5. Tax credit claimed, but the supplier never filed. The invoice is missing from our GSTR-2B (the government's monthly statement of what suppliers reported) while the supplier's other invoices are present.
  6. A large payment to a just-changed bank account that belongs to an employee. Follow the money: payment, account, owner. The same AP clerk entered the new bank details, approved the payment and owns the account.

In the browser the trail of each invoice is drawn as lanes, and a marker walks the evidence path hop by hop. Break the books lets anyone cut a receipt link on any of 19 clean invoices and watch the checks catch it.

You can use it in four ways, all on the same store:

  • the browser view, where Relate runs as WebAssembly in the tab
  • a Python CLI (scan, explain, link)
  • an MCP server for AI agents, with five tools: reads are read-only, and the one guarded write records who linked what and why
  • Relate's own CLI or relate serve --mcp

What connects to what

(:PurchaseOrder)-[:PLACED_WITH]->(:Vendor), (:GoodsReceipt)-[:RECEIVED_AGAINST]->(:PurchaseOrder), (:Invoice)-[:BILLS]->(:PurchaseOrder), (:Payment)-[:SETTLES {amount}]->(:Invoice) (many-to-many), (:BankLine)-[:CLEARS]->(:Payment) (one payment can be several debits), (:BankLine)-[:REVERSES]->(:BankLine), (:GstrLine)-[:REPORTS]->(:Invoice), (:Payment)-[:PAID_TO]->(:BankAccount)<-[:HAS_ACCOUNT {since}]-(:Vendor|:Employee), (:Employee)-[:APPROVED|ENTERED]->(...), (:BankChange)-[:NEW_ACCOUNT]->(:BankAccount). That is 184 nodes and 265 relationships, built from 13 flat CSV ledgers by linking on the keys an accountant uses: PO number, the bank's unique transaction reference (UTR), and GSTIN plus invoice number.

How we built it

  • Relate, single-file mode: store/trailmark.rl is one period's books in one file you can hand to an auditor. The embedded Python library builds it and opens it read_only for every read. Relate's CLI and relate serve open the same file.
  • Cypher features used: quantified path patterns, SEARCH … VECTOR INDEX … SCORE AS inside an OPTIONAL CALL subquery, EXISTS {} and COUNT {} subqueries, uniqueness constraints and duration.inDays.
  • Text vectors: small and deterministic (hashed character trigrams), so no model or API key is needed.
  • Browser: Relate's WebAssembly build rebuilds the graph from an export of the store and runs the very same .cypher files; the cut is a real DELETE on that in-tab graph.
  • Agents: a small stdio MCP server exposes the domain tools, and .mcp.json also registers relate serve --mcp stdio --read-only for raw Cypher.
  • Testing: eight end-to-end tests run in CI on Windows, macOS and Linux. One of them cuts each of the 19 eligible receipt links in turn and checks that it is caught exactly once and nothing else changes.

Challenges we ran into

  • A plain three-way match is not a graph problem. It is fixed-depth joins. So every scenario depends on many-to-many or variable-length structure: split and returned payments, partial receipts, duplicates, and people around the money. The README puts the Cypher next to the SQL it replaces.
  • Proving the checks are not staged. Six planted problems could be six rehearsed stories, so the app lets you break the books yourself, and a test does the same for every eligible link.
  • The WebAssembly build cannot open a .rl file. The page rebuilds the graph from an export of the store instead.
  • Relate allows one process per store. The CLI and the agent server open short-lived connections, read-only wherever possible.

Accomplishments that we're proud of

  • Break the books: anyone can cause a fault and watch the graph catch it and explain it.
  • The missing-link view: the link the trail expects and cannot find is drawn as a dashed red "expected, not found" card, and ruled-out lookalikes are struck through next to the PO they belong to.
  • Easy to try: it runs from a fresh clone with one dependency, or in the browser with none.

What we learned

Relate makes "a graph per job" practical: a few hundred kilobytes, one file, millisecond queries, and the same Cypher on a laptop, in a browser tab and behind an agent's tools.

What's next

  • importers for real ERP exports (Tally, SAP, Zoho Books)
  • more checks: TDS deducted but not deposited, vendor-to-vendor circular payments, partial credit notes
  • more ways to break the books, each with the same test behind it
  • a bulk "close pack" that writes every finding into the store as (:Finding) nodes, so auditors can query them

AI use

This project was built during the contest period by a solo builder with significant help from an AI coding assistant (Claude Code, by Anthropic). The assistant wrote most of the code, Cypher, sample-data generator, tests and documentation under my direction. I chose the use case, defined the accounting scenarios and reviewed the results. The product itself contains no AI model: every finding comes from Cypher over the graph. The sample data is invented. The paper-cut illustration on the thumbnail and the README was made with an AI image model; the screenshots and the graph diagram are rendered from the app and from code.

Reused code

  • Relate (Apache-2.0): relate-db from PyPI, and the unmodified @relate/relate-wasm 1.0.1 package vendored in web/vendor/relate-wasm/.
  • Fonts: Inter Tight and JetBrains Mono (Google Fonts).
  • Everything else was written for this hackathon.

Built With

Share this project:

Updates

Submission history