Invoicing · 13 / 26

Databricks Data and AI (artificial intelligence) Platform

How Databricks holds the receivables platform's governed data, clause index, model serving, tracing and evaluation.

What Databricks does here

Databricks lakehouse for the receivables platform ERP and bank extracts, contracts and remittance documents and agent traces land in Unity Catalog as bronze, silver and gold tables, with a clause index and masks on bank and contact data. Model Serving, the agent application and MLflow tracing and evaluation read and write the governed tables. ERP and bank extracts invoices · payments Contracts and remittances documents Agent traces from the gateway Unity Catalog · ar_prod bronze · silver · gold knowledge · masks Model Serving endpoints + gateway Agent app retrieval + tools MLflow tracing · evaluation
One governed platform holds the data, the clause index, the serving endpoints and the evaluation loop.

Databricks is the data and AI platform for the receivables platform. It keeps operational copies and decisions in governed tables, builds the clause index from contracts, serves models where useful and provides tracing and evaluation. The orchestrator itself runs in the application tier and calls the AI gateway for models.

Governance in Unity Catalog

One catalog per environment, with schemas by purpose. Access is granted to groups, never to individuals, and sensitive data is protected in the table, so every notebook, dashboard and evaluation job inherits the control.

SchemaContentsWho can read
bronzeRaw bank lines, remittance pointers, invoice and payment extracts as receivedData engineers
silverCleaned invoices, payments, applications, disputes and decisions, with bank tokens and payer names as sensitive columnsAR (Accounts Receivable) engineers and analysts, with masks
goldEvaluation sets, KPIs (Key Performance Indicators), feedback, aging and unapplied-cash viewsFinance, evaluation and support teams
knowledgeClause index and its source tableThe agent service principal
securityScan results and security events from the gatewaySecurity operations

Protecting sensitive data in the table

Row filters and column masks make the rule part of the table. Analysts see a masked bank token; an AR lead sees it for a case they own.

Unity Catalog · masks and row filters
-- Tokenised bank accounts and payer names are masked except for approved roles
CREATE FUNCTION ar_prod.silver.mask_sensitive(value STRING)
  RETURN CASE WHEN is_account_group_member('ar_leads') THEN value ELSE '***' END;

ALTER TABLE ar_prod.silver.payments
  ALTER COLUMN bank_account_tok SET MASK ar_prod.silver.mask_sensitive;
ALTER TABLE ar_prod.silver.payments
  ALTER COLUMN payer_name SET MASK ar_prod.silver.mask_sensitive;

-- Regional teams see only their customers
CREATE FUNCTION ar_prod.silver.region_filter(region STRING)
  RETURN is_account_group_member('ar_global') OR is_account_group_member(CONCAT('ar_', region));
ALTER TABLE ar_prod.silver.invoices
  SET ROW FILTER ar_prod.silver.region_filter ON (region);

The clause index

Contract clauses are chunked by clause, tagged with customer, contract, effective dates and a version, and stored in a gold table. A Vector Search index (the product is now branded Databricks AI Search) syncs from that table, so a change to a contract updates the index without a rebuild. The agent filters by customer and effective date at query time, so it cannot cite another customer's terms or an expired clause.

knowledge/search.py · filters are enforced at query time
from databricks.vector_search.client import VectorSearchClient

index = VectorSearchClient().get_index(
    endpoint_name="ar-knowledge",
    index_name="ar_prod.knowledge.contract_clauses_index",
)

def search_clauses(question: str, customer_id: str, on_date: str) -> list[dict]:
    hits = index.similarity_search(
        query_text=question,
        columns=["clause_id", "contract_id", "title", "text", "source_url"],
        filters={"customer_id": customer_id, "effective_from <=": on_date, "effective_to >=": on_date},
        num_results=5,
    )
    return hits["result"]["data_array"]
A contract changes and the index follows Commercial operations publishes an amended contract. A job parses and chunks it, writes the clauses with effective dates to the source table, and the index syncs from that table. At question time the agent searches with a customer and date filter. Commercial ops Lakeflow job Source table Vector Search Agent app publish amended contract document change event parse, chunk by clause write clauses with effective dates sync from change feed embed and index search + customer and date filter cited clauses
A contract changes and the index follows

No rebuild is needed. Effective dates make sure a clause applies only when it should.

Serving, the gateway and tracing

Model Serving

Hosts any fine-tuned or small task model, such as the match scorer or the late-payment model, behind an endpoint with scaling and versioning.

AI Gateway on endpoints

Rate limits, usage tracking, guardrails, fallbacks and inference tables for served endpoints, to complement the enterprise gateway.

MLflow tracing

Spans for each retrieval, model call and tool call, logged with the case and trace identifier from the gateway.

Agent evaluation

Runs the evaluation set with built-in and custom judges, and stores results in a gold table for comparison across releases.

Jobs that keep it current

JobScheduleWhat it does
Ingest bank and ERP (Enterprise Resource Planning) extractsEvery 15 minutesLands extracts in bronze and upserts silver
Refresh clause indexOn contract change, daily checkRe-chunks changed contracts, writes the source table and syncs the index
Mask and curate tracesHourlyRedacts traces from the gateway into silver, with sensitive fields masked
Score late-payment riskNightlyWrites risk scores with reasons to a gold table
Nightly evaluationNightly and on every releaseRuns the evaluation set, writes scores and alerts on regressions
Feedback to test casesWeeklyTurns reviewed exceptions and corrections into new evaluation cases
Nightly evaluation job A nightly job runs the evaluation set through the agents and the gateway, records traces in MLflow, scores the results and writes them to a gold table. A regression raises an alert. Lakeflow job Agent app AI gateway MLflow Gold table Alert run dataset v9 model calls replies traces per case score with scorers and judges scores write scores by version compare with last release regression found
Nightly evaluation job

What the data answers

Build this for your business

This example is a receivables platform for a distributor, but the same pattern, deterministic financial rules, a governed gateway, runtime security, grounded evidence and measured quality, fits any back-office process that moves money. We can scope a pilot on your own systems.

Book a discovery call