Inspiration

SMBs and freelancers sign contracts and invoices without a compliance team to catch buried red flags — hidden late fees, one-sided liability clauses, offshore payment terms. ClauseGuard gives anyone that same clause-level scrutiny, instantly.

What it does

Upload a PDF or paste a financial document, and ClauseGuard returns:

  • A 0–100 risk score (color-coded gauge)
  • A plain-English summary
  • Key terms extracted
  • Red flags with severity ratings (high/medium/low)
  • Actionable recommendations

Two built-in sample documents (risky invoice, clean contract) let anyone try it instantly, no upload needed.

How we built it

A single-page Streamlit app. pdfplumber extracts text from uploaded PDFs; the text is sent to Google's Gemini API with a strict prompt enforcing structured JSON output (score, summary, key terms, red flags, recommendations). Responses are sanitized and parsed before rendering. The UI uses custom CSS cards, an animated risk gauge, severity badges, and inline SVG icons instead of Streamlit's default styling. Session state manages document source and analysis results.

Challenges we ran into

Getting the model to reliably return clean JSON (not JSON wrapped in prose or markdown fences) took real prompt tuning — the app now strips fences and catches parse failures gracefully. Streamlit's rerun-on-interaction model also made state tricky: sample buttons, uploads, and pasted text all needed to coexist without triggering unwanted re-analysis.

Accomplishments that we're proud of

A polished, "real product" feel despite a tight solo build — custom gauge, card layout, and severity system. Built-in sample documents mean a live demo always works, even if upload or API calls fail.

What we learned

Prompt design is UI design when building on an LLM — the schema and constraints in the prompt determine how defensive the frontend needs to be. Trust is the real product: a risk analyzer is only useful if it fails gracefully and never shows a broken result.

What's next for ClauseGuard

  • Multi-document comparison against standard terms
  • Exportable PDF/markdown risk reports
  • Follow-up Q&A mode on uploaded documents
  • Batch analysis of multiple documents
  • Jurisdiction-aware compliance checks

Built With

python, streamlit, gemini-api, google-generativeai, pdfplumber, google-gemini, large-language-models, generative-ai, fintech, regtech, compliance, risk-analysis, nlp, json, css, html, prompt-engineering, financial-technology, contract-analysis, document-intelligence

Built With

Share this project:

Updates