bitreka

Software Engineering Leader | AI-Assisted Development | .NET & C# | FinTech & Payments | E-Commerce | Architecture • Backend • Microservices • DevOps • Test Automation • AI Agents

All work

ContractApproval

AI pre-screening for contracts: clause-level risk, missing clauses and a plain-language summary.

Status
MVPA working first version with the core flows.
Role
Sole engineer: product design, architecture, API, analysis pipeline, UI and the CI gate.
Started
Categories
Legal tech, AI and LLM
Parts
Web

Purpose

Give a small-business owner a quick, structured first opinion on a contract before signing it — a preparation tool, not a replacement for a lawyer.

The problem

Small businesses often sign service agreements without a review because a lawyer is slow or expensive for a first look. A generic chatbot answer is not good enough either: it can invent clause numbers, phrase guesses as certainties and leave no reliable record.

What I built

  • A .NET 10 API with ASP.NET Core Identity and EF Core on PostgreSQL; analysis runs asynchronously (202 Accepted plus status polling) in a background worker.
  • A Claude integration that forces structured output through an analyze_contract tool schema — clause number, risk level (low, medium, high), reason and suggested fix, plus missing clauses and a plain summary — with prompt caching for the system prompt.
  • A domain-level check that rejects any clause reference not present in the uploaded document, so a hallucinated clause number never reaches the user.
  • A React interface with risk cards, missing-clause warnings, a printable report and a mandatory "not legal advice" notice enforced in the UI itself.
  • Privacy by default: the uploaded file and extracted text share one retention rule — deleted after 30 days or immediately on request — and logs never contain contract text or file names.
  • Invite-only accounts, an atomic monthly quota and an admin panel that sees per-analysis token cost but never the contract itself; a golden set of sample contracts guards prompt and model changes.

Features

  • PDF and DOCX upload with text extraction.
  • Asynchronous analysis with status polling.
  • A result screen with risk cards, missing-clause warnings and a plain-language summary.
  • A print-ready report.
  • A history list, with the original file and text available again.
  • A monthly analysis quota that the admin can adjust.
  • Invite-only accounts and an admin panel with users, invitations, analyses and a problem log.
  • Automatic purge of contract text, raw file and used invitations after 30 days, plus instant delete.
  • An admin screen for model, effort and key settings.

Stack

  • .NET
  • ASP.NET Core
  • EF Core
  • PostgreSQL
  • Claude API
  • React
  • Vite
  • TypeScript
  • Docker
  • GitHub Actions

AI in this project

In the product

  • One Claude call analyses the whole uploaded service agreement (no chunking) and returns risky clauses (clause number, low, medium or high, category, reason, suggested fix), missing clauses and a plain-English summary. The model, effort level and key are read from the encrypted settings on every analysis.
  • The output is forced through a strict tool schema, so it is structured data rather than free text.
  • Guards: a clause number that does not literally appear in the contract text makes the whole result be rejected, an empty summary is rejected, and the prompt forbids stating legal conclusions or inventing section numbers. Failed calls are still counted in the cost record.
  • No OCR: a scanned PDF yields no text. A person reads the result and nothing happens automatically; a "not legal advice" notice is required in the interface.
  • A development tool runs a golden set of 10 contracts against the real API to catch regressions. It asks for approval and shows an estimated cost first, after a first day that used up the credit.

In how it was built

  • 80 of 101 commits carry a Claude co-author trailer.
  • The project rule file requires red-green test-driven development with the real terminal output, coverage reported per layer, a golden-set check where a missed risky clause blocks, and it bans padding coverage with weak assertions.

Key flows

Steps

From upload to risk report

  1. Step 1 of 5: Upload

    A signed-in user uploads a PDF or DOCX contract; the monthly quota is checked and consumed atomically.

  2. Step 2 of 5: Queued analysis

    The API answers 202 Accepted with an analysis id, and the client polls its status while the worker runs.

  3. Step 3 of 5: Structured output

    Claude returns the analysis through the tool schema; clause references are validated against the document before anything is stored.

  4. Step 4 of 5: Results

    Risk cards, missing clauses and a plain-language summary appear together with the not-legal-advice notice, ready to print as a report.

  5. Step 5 of 5: Retention

    The file and its text are deleted automatically after 30 days, or at once when the user asks.

Limitations

The golden set is synthetic and not yet reviewed by a lawyer, so it measures regressions, not legal accuracy; the product analyses English-language contracts.

Want something like this?

Tell me about your project — I reply within two working days.

Start a project