Back to work
OnTract dashboard showing contract stats, recent contracts, and recent activity feed
AI Engineering RAG

OnTract

An AI-powered contract intelligence platform that summarizes contracts, extracts key clauses, and lets teams query documents conversationally. I worked as an AI Engineer on the team that built the underlying AI and backend systems.

View Live App

My Role

AI Engineer

Team

7 (6 peers + me)

Skills / Tools

OpenAI API, LangChain, ChromaDB, RAG, Python, AWS, SQL

Overview

Building affordable AI contract intelligence for teams enterprise tools have priced out.

OnTract brings enterprise-grade contract analysis to small and mid-sized businesses at a price they can afford. As an AI Engineer on a team of 7, I built the systems that read and understand legal documents, from ingestion through the retrieval pipeline powering conversational search, cutting the manual work of contract review.

Problem

Enterprise contract intelligence tools price out the businesses that need them most.

Tools that summarize agreements, extract clauses, and flag renewal dates are built and priced for enterprise legal teams. Smaller businesses face the same dense, error-prone contracts but can't justify the cost, so they review everything by hand. We built OnTract to close that gap: the same AI-powered analysis, at a price a smaller team can afford.

Approach

Three systems worked together to turn raw contract text into structured, queryable knowledge.

01

AI-powered contract summarization

Reading a full contract to find a few key terms is slow.

AI workflows running as Supabase Edge Functions use GPT-4o to summarize each contract and extract key clauses (renewal dates, payment terms, obligations) on ingestion. Every clause links back to its source excerpt, so a summary is always something to verify against the original text.

02

Conversational, context-aware document search

A single keyword search rarely captures what someone actually needs from a contract.

LangChain adds semantic search and conversational memory over the LLM, supporting multi-turn chat over ingested contracts. Text is embedded in ChromaDB, and every interaction is traced through LangSmith. Each answer surfaces the excerpt it's grounded in, so chat stays checkable against the source instead of merely plausible-sounding.

03

A scalable backend for contract data

AI outputs are only useful if they're stored and retrievable at scale.

Supabase's managed Postgres, storage, and edge functions handle document storage and metadata, with migrations and seed data keeping every teammate's environment reproducible.

Technical Challenges

Building a RAG pipeline is the easy part: making it trustworthy enough for legal documents is the hard part.

Most of the engineering effort went into grounding summaries in the actual document and making failures debuggable.

Engineering Challenges

  1. Retrieval vs. clause boundaries. Fixed-size chunks often split a clause from its own key figure. Chunking on clause and section boundaries instead keeps each embedded chunk semantically complete.
  2. Debugging non-deterministic output. A wrong answer could come from retrieval, the prompt, or the model. Tracing every call through LangSmith (question, retrieved chunks, final prompt) makes the failure point traceable instead of a guess.
  3. Cost as a design constraint. Every call has a real dollar cost, and margins matter more for an affordability-first product. Reusing embeddings already stored in ChromaDB keeps per-query cost close to just the LLM call.
  4. Trust for a legal document. A fluent but wrong clause is worse than none at all. Every summary and chat answer surfaces the source excerpt it was drawn from, so verifying a claim means checking one passage instead of re-reading the whole contract.
langsmith · trace
01 question user's natural-language question about the contract
02 retrieved_chunks top-k clause-bounded chunks pulled from ChromaDB
03 prompt system instructions + retrieved context + question
04 response answer grounded in, and cited to, the source excerpt

Known Limitations

Heavily scanned PDFs without clean OCR produce weaker summaries, and very long contracts push against context and retrieval limits more than a heavier enterprise stack would. Pre-launch evaluation relied on manual spot-checks rather than a repeatable eval set, and pipeline latency was never formally measured, both known gaps.

System Architecture

A modular stack where AI, payments, and observability layer on top of a Supabase core.

A Next.js frontend pairs with Supabase for auth, Postgres, storage, and edge functions, the same edge functions that run the AI processing pipeline, keeping AI workloads close to the data without a separate backend service.

Only Supabase is required to run the app at all; AI processing, billing, tracing, and email are optional, env-gated integrations on top. For vector storage, the team chose ChromaDB over managed options like Pinecone to avoid recurring hosting costs while validating demand, with a planned migration to Pinecone once usage justifies it.

OnTract system architecture diagram A Next.js frontend connects to a Supabase core (Auth, Postgres, Storage) and Edge Functions, which run the AI processing pipeline. Four optional, environment-gated integrations branch from Edge Functions: OpenAI, LangChain, and ChromaDB for document AI and vector search, LangSmith for tracing, Stripe for billing, and Resend for transactional email. Next.js Frontend UI + routing Supabase Core System of record + access control Auth Postgres Storage Edge Functions AI processing + email jobs OpenAI + LangChain + ChromaDB Summarization, clauses & search LangSmith Tracing & observability Stripe Subscription billing Resend Transactional email Core: always required Optional: env-gated

Core services (solid connectors) are required for the app to run at all. Integrations (dashed connectors) branch off the edge functions layer and only activate once their API keys are configured.

Core Stack

  1. Next.js: frontend application and routing
  2. Supabase (Postgres, Auth, Storage): the system of record and access control
  3. Edge Functions: serverless compute for AI processing and email jobs

Optional Integrations

  1. OpenAI + LangChain + ChromaDB: document summarization, clause extraction, and conversational chat over vector embeddings stored in ChromaDB
  2. LangSmith: tracing and observability for every LLM call
  3. Stripe: subscription billing across Starter and Pro tiers
  4. Resend: transactional email for team and client invitations

Outcome

A shipped, lower-cost alternative to enterprise contract intelligence tools.

The result is a live platform giving smaller businesses enterprise-style summarization, clause extraction, and conversational search at a fraction of the cost. Because the retrieval layer isn't hard-coded to one vector store, swapping in Pinecone later is a targeted change rather than a rebuild.

Lessons Learned

Match infrastructure cost to the stage of the business as much as the scale of the technology.

  1. Cost-conscious choices should stay reversible. ChromaDB was right for an affordability-first product, but only because the retrieval layer wasn't hard-coded to it, leaving room to swap in Pinecone later.
  2. Optional-by-default architecture lowers onboarding friction. Requiring only Supabase to run the core app meant a new teammate could get it running locally in minutes instead of after configuring five external services just to see a login screen.
  3. Observability pays for itself the first time something breaks. Tracing every call through LangSmith felt like overhead until a teammate could point to the exact retrieved chunk behind a wrong answer instead of re-running the same prompt five times.
Live product

See it in action

OnTract is live: upload a contract and try the AI summarization and conversational search yourself.

View Live App
contract-management-gray.vercel.app OnTract dashboard showing contract stats, recent contracts, and recent activity feed
Next project: Lotus You(th)