Live demo (runs in your browser): https://automationbot24x7.github.io/trailmark/ · 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.

Inspiration

I work in finance automation. 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 and the nodes that prove it:

  1. Invoice with no goods receipt. A vector search over receipt descriptions finds lookalike receipts from the same vendor. The graph then rules out the one already received against another PO, 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 while the supplier's other invoices are present.
  6. A large payment to a just-changed bank account that belongs to an employee. Every 1-3 hop path from the payment to our own people: the same AP clerk entered the new bank details, approved the payment and owns the account.

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

  • a 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, bank 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 {} subqueries, uniqueness constraints and duration.inDays.
  • Text vectors: small and deterministic (hashed character trigrams), so no model or API key is needed.
  • Browser: the browser view uses Relate's WebAssembly build. It rebuilds the graph from an export of the store and runs the very same .cypher files.
  • 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: seven end-to-end tests run in CI on Windows, macOS and Linux.

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.
  • 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

  • The missing-link view: the link the trail expects and cannot find is drawn as a dashed red "expected, not found" card, so the answer is visible rather than buried in a report.
  • Vector search and the graph together: vector search proposes candidate receipts and the graph rules them out or in.
  • 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
  • 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.

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