-
-
Break the books: cut a receipt link and the six checks re-run in your tab and catch it. 7 exceptions now, ₹39,648 more at risk
-
INV-1042: no goods receipt. Text search scores GRN-5404 a perfect 1.00; the graph strikes it out because it already belongs to PO-7604
-
INV-1037: follow the money. ₹8,90,000 went to an account owned by our own AP clerk, who also entered the bank change
-
INV-1036: one payment, three invoices, two bank debits, one returned. The books say paid; ₹1,95,600 never reached the vendor
-
After one click: GRN-5520 linked to PO-7713, the trail holds and ₹99,120 leaves the at-risk total
-
The graph model: how orders, receipts, invoices, payments, bank lines and our GSTR-2B link up, and where each of the six checks looks
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
- Open the live demo and press Break the books in the left panel.
- 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. - 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
.cypherfiles againststore/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:
- 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.
- Billed more than was received. Many receipts and many invoices are summed across one PO.
- 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.
- The same invoice paid twice (BOS/889 and BOS-889), each copy with its own payment and bank line.
- 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.
- 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.rlis one period's books in one file you can hand to an auditor. The embedded Python library builds it and opens itread_onlyfor every read. Relate's CLI andrelate serveopen the same file. - Cypher features used: quantified path patterns,
SEARCH … VECTOR INDEX … SCORE ASinside anOPTIONAL CALLsubquery,EXISTS {}andCOUNT {}subqueries, uniqueness constraints andduration.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
.cypherfiles; the cut is a realDELETEon that in-tab graph. - Agents: a small stdio MCP server exposes the domain tools, and
.mcp.jsonalso registersrelate serve --mcp stdio --read-onlyfor 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
.rlfile. 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-dbfrom PyPI, and the unmodified@relate/relate-wasm1.0.1 package vendored inweb/vendor/relate-wasm/. - Fonts: Inter Tight and JetBrains Mono (Google Fonts).
- Everything else was written for this hackathon.
Built With
- cypher
- github
- javascript
- mcp
- neo4j
- python
- relate
- svg
- webassembly