Skip to content

Repository files navigation

🚀 KontractIQ

Enterprise-Grade AI Contract Intelligence Platform

Status Python Streamlit


🌟 Overview

This document provides a comprehensive overview of KontractIQ, including its architecture, features, workflows, AI capabilities, technology stack, implementation details, user experience, security considerations, and future roadmap. It has been professionally structured and optimized for GitHub with clean formatting, badges, tables, diagrams, callouts, and well-organized sections to ensure excellent readability for recruiters, hiring managers, collaborators, and open-source contributors.


KONTRACTIQ — COMPREHENSIVE PROJECT DOCUMENTATION

A FAANG-Level Contract Intelligence Platform


📋 TABLE OF CONTENTS

  1. Executive Summary
  2. Project Identity & Branding
  3. The Problem Statement
  4. Solution Overview
  5. Core Features
  6. Pages & Navigation
  7. Technology Stack
  8. System Architecture
  9. Deployment Architecture
  10. Unique Differentiators
  11. Competitor Comparison
  12. Future Enhancements
  13. Project Metrics
  14. User Guide
  15. Conclusion

1. EXECUTIVE SUMMARY

Overview

KontractIQ is a production-ready, enterprise-grade contract intelligence platform that revolutionizes how organizations analyze, manage, and extract value from their contract portfolios. Built for Streamlit Community Cloud with zero financial cost, this platform serves legal, procurement, compliance, and business teams who need to analyze contracts faster and more intelligently than manual review allows.

The Innovation

The platform represents a fundamental shift from traditional contract analysis tools that examine documents in isolation. Instead, KontractIQ provides a holistic, portfolio-wide approach that:

  • Detects numeric and date inconsistencies across multiple contracts simultaneously
  • Provides rule-based AI risk detection with active learning capabilities
  • Generates professionally branded reports suitable for executive presentations and compliance audits

Core Promise

Promise Status
100% free with no financial cost
Zero API keys required for core features
Professional white and blue UI
Deployable on Streamlit Cloud in one click
Open source with no vendor lock-in
Works within 1GB memory limit
100% private - session-based storage

Key Metrics

Metric Value
Core Features 12
Pages 15
Clause Types Extracted 8
Report Types 4
Contract Templates 6
File Types Supported 3 (PDF, DOCX, TXT)
Max Contracts Per Session 20
Max File Size 10MB
Memory Usage <800MB

2. PROJECT IDENTITY & BRANDING

Brand Foundation

Name & Meaning

Aspect Value
Name KontractIQ
Pronunciation Kon-trakt-eye-q
Meaning Contract + Intelligence Quotient
Tagline "Intelligence for every clause."
Icon ⚖️ (Gavel / Justice Scale)

The name derives from the fusion of "Contract" and "Intelligence Quotient," reflecting the platform's mission to bring measurable intelligence to contract analysis.


Complete Color System

Primary Blues (Seven-Tier System)

Role Color Name Hex Code Usage
Primary Base Deepest Navy #0A2647 Headers, hero sections, primary text
Primary Dark Rich Navy #1B3A5C Secondary dark backgrounds
Primary Main Corporate Blue #2C5F8A Primary buttons, active states, links
Primary Light Vibrant Blue #4A7FA5 Hover states, secondary buttons
Primary Accent Sky Blue #7BA5C4 Borders, subtle highlights, footer text
Primary Soft Pale Blue #B8D4E8 Disabled states, light backgrounds
Primary BG Ice Blue #E8F1F8 Main page background

Neutrals

Role Color Name Hex Code Usage
Pure White White #FFFFFF Cards, modals, inputs
Off White Background White #F8FAFE Alternative card backgrounds
Light Gray Border Light #E2E8F0 Borders, dividers
Medium Gray Placeholder #94A3B8 Placeholder text, icons
Dark Gray Secondary Text #475569 Labels, secondary information
Deep Navy Primary Text #0A2647 Headings, primary text

Semantic Colors (Risk & Status)

Role Hex Code Background Hex Usage
Success #0D9488 #E6F7F5 Positive numbers, success messages
Warning #D97706 #FEF3C7 Risk indicators, warnings
Danger #DC2626 #FEE2E2 Critical risks, negative numbers
Info #3B82F6 #EFF6FF Informational messages

Typography System

Type Size Weight Usage
Display 30px 600 Hero numbers, balance tiles
Title 1 22px 600 Section headers
Title 2 20px 600 Card titles
Headline 18px 600 Modal headers
Body Large 16px 500 Important information
Body 14px 400 Regular text
Small 13px 500 List items, contract names
Caption 12px 500 Labels, badges
Micro 11px 500 Timestamps, helper text
Footer 10px 500 Report footers, legal disclaimers

Spacing System

Token Value Usage
xs 4px Small gaps between icons and text
sm 8px Grid gaps, chip gaps
md 12px List item gaps, card padding
lg 16px Section padding, card padding
xl 18px Body padding
xxl 22px Hero padding
xxxl 32px Large section spacing

Border Radius System

Token Value Usage
sm 8px Icons, small elements
md 12px Chips, small cards, buttons
lg 16px Cards, tiles, modals
xl 20px Balance tile, hero cards
xxl 24px Large containers
full 50% Avatars, circular icons

Shadow System

Token Value Usage
sm 0 1px 2px rgba(10, 38, 71, 0.05) Default cards
md 0 4px 6px rgba(10, 38, 71, 0.07) Elevated cards
lg 0 10px 15px rgba(10, 38, 71, 0.08) Modals, dropdowns
xl 0 20px 25px rgba(10, 38, 71, 0.10) Hero sections
hover 0 8px 20px rgba(10, 38, 71, 0.10) Card hover states

3. THE PROBLEM STATEMENT

The Contract Management Crisis

Organizations today manage hundreds or thousands of contracts across diverse stakeholder groups including vendors, suppliers, employees, partners, and customers. This distributed contract landscape creates significant challenges that traditional manual review processes cannot adequately address.


Problem 1: Time-Consuming Discovery

The Issue

Legal and procurement teams spend hours reading through contracts to find specific clauses like termination notice periods, liability caps, or payment terms. A single contract review typically requires 30 to 60 minutes of focused attention.

The Impact

  • Teams waste thousands of hours annually on manual discovery
  • Strategic work suffers as resources are pulled into administrative tasks
  • The problem compounds as contract volumes grow
  • Creates a scaling crisis that many organizations cannot effectively manage

The Root Cause

Contracts are stored as static documents without searchable metadata or indexes. Finding specific information requires reading each document individually, and there's no way to query across documents for specific terms or concepts.


Problem 2: Missed Inconsistencies

The Issue

When contracts use different payment terms (30 days vs 60 days vs 90 days) or liability caps ($1M vs $5M vs unlimited), these contradictions are rarely caught during manual review. Teams review contracts in isolation, missing critical inconsistencies across their vendor portfolio.

The Impact

  • Creates significant risk blind spots
  • Leads to inconsistent treatment of vendors and partners
  • Results in financial exposure from inconsistent terms
  • Makes portfolio-wide standardization impossible

The Root Cause

Manual review focuses on individual documents, not portfolio patterns. Without automated cross-document analysis, inconsistencies remain invisible to reviewers.


Problem 3: Version Confusion

The Issue

Organizations often maintain multiple versions of similar contracts (MSA v1, MSA v2, amendments, rider documents). Manually comparing versions is error-prone, time-consuming, and often incomplete.

The Impact

  • Working with outdated terms
  • Missing critical amendments
  • Legal exposure from inconsistent application
  • Problems intensify during organizational changes

The Root Cause

No systematic way to track and compare contract versions. Document management systems provide version history but don't highlight meaningful differences.


Problem 4: Scattered Knowledge

The Issue

Contract knowledge lives inside documents, not in a searchable database. When someone asks "which vendors have unlimited liability?" or "who has 30-day payment terms?", there's no easy way to answer without re-reviewing every contract.

The Impact

  • Prevents understanding of contractual exposure
  • Weakens negotiation position
  • Misses opportunities for standardization
  • Creates information asymmetry

The Root Cause

Contracts are structured as documents, not as data. The information they contain isn't organized in a way that enables querying and analysis.


Problem 5: Static Risk Detection

The Issue

Risk identification is manual and inconsistent across reviewers. One reviewer might flag auto-renewal as high risk while another misses it entirely. There's no systematic way to learn from past reviews.

The Impact

  • Creates compliance gaps
  • Increases regulatory exposure
  • Misses opportunities to improve contract terms
  • No institutional memory of risk identification

The Root Cause

Risk identification relies on individual reviewer judgment rather than systematic, repeatable processes. There's no way to capture and share risk knowledge across teams.


Problem 6: No Creation Guidance

The Issue

When creating new contracts, teams start from blank documents or outdated templates. They miss standard clauses or include high-risk terms because they have no real-time guidance or warnings.

The Impact

  • Inconsistent contract quality
  • Missed opportunities to include favorable terms
  • Propagation of problematic language
  • Each contract represents fresh opportunity to introduce risk

The Root Cause

No structured contract creation process with real-time guidance. Contract creation relies on institutional knowledge that isn't captured or accessible.


4. SOLUTION OVERVIEW

How KontractIQ Solves Each Problem

Problem KontractIQ Solution
Time-consuming discovery TF-IDF + keyword search finds clauses in seconds
Missed inconsistencies CrossCheck compares numeric/date values across contracts
Version confusion Intelligent diff shows significant changes
Scattered knowledge Centralized searchable repository with 8 clause types
Static risk detection Session-based feedback with export/import
No creation guidance Templates with rule-based warnings

Core Capabilities

Capability Description
Upload PDF, DOCX, TXT - single or batch, 10MB limit, 20 contract max
Parse Extract clean text, detect scanned PDFs
Extract Identify 8 clause types with confidence scoring
Search TF-IDF + BM25 hybrid search with relevance ranking
Compare Version-to-version diff with change categorization
CrossCheck Find numeric/date contradictions across contracts
RiskScan Flag risk indicators, export/import rules
Ask AI chat with free Groq API (optional)
Create Contract templates with rule-based warnings
Report Professional PDF and HTML reports with branded footer
Demo Mode Sample contracts to test without uploading

Design Principles

Principle Implementation
Zero Financial Cost No API keys required for core features
Privacy First Session-based storage, no permanent cloud storage
Accessible WCAG AA/AAA compliant
Professional White and blue theme with perfect contrast
Deployable Fits within Streamlit Cloud 1GB memory

5. CORE FEATURES DEEP DIVE

Feature 1: Multi-Contract Upload

Functionality

The upload system accepts PDF, DOCX, and TXT files with support for batch upload of multiple contracts simultaneously. Users can drag and drop files or use the file browser interface. The system validates file types, sizes, and total contract count before processing.

Technical Implementation

  • Uses Streamlit's file_uploader with accept_multiple_files enabled
  • Comprehensive validation pipeline for each file
  • DocumentParser class handles specialized parsing for each file type

User Experience

  • Drag-and-drop interface with visual feedback
  • Progress indicators for each file
  • Scanned PDF detection with clear warnings
  • Contract limit counter (0/20)
  • Uploaded contracts list with management capabilities

Limits Enforced

Limit Value Reason
Max contracts per session 20 Memory limit
Max file size 10MB Streamlit limit
Max pages per contract 50 Processing time
Scanned PDF Detected + rejected No OCR support

Feature 2: Contract Parsing Engine

Functionality

The parsing engine extracts clean text from uploaded documents, handling three file formats with specialized parsers. The system includes intelligent fallback mechanisms for challenging PDF files.

PDF Parsing

  • Primary: PyPDF2 for speed
  • Fallback: pdfplumber for better extraction
  • Detection: Scanned PDF identification if text < 100 characters

DOCX Parsing

  • Uses python-docx library
  • Extracts paragraphs while preserving structure
  • Handles both simple and complex Word documents

TXT Parsing

  • UTF-8 encoding with Latin-1 fallback
  • Handles various line endings
  • Broad character encoding compatibility

Scanned PDF Detection

If extracted text is less than 100 characters, the system flags the document as likely scanned and provides clear instructions to the user.


Feature 3: Clause Extraction Engine

Functionality

Identifies and extracts 8 key clause types using a hybrid approach combining regex pattern matching and SpaCy NLP.

8 Clause Types Extracted

Clause Type Detection Method
Governing Law Pattern matching + state detection
Payment Terms Pattern + number extraction
Liability Cap Pattern + value extraction
Termination Notice Pattern + number extraction
Confidentiality Period Keyword + duration extraction
Renewal Terms Pattern + auto-detection
Indemnification Keyword + party detection
Force Majeure Keyword + event detection

Extraction Methods

Each clause type has specific detection patterns optimized for accuracy and performance. The system uses compiled regex patterns for speed, with SpaCy providing additional NLP capabilities when needed.

Output Format

  • Clause type identified
  • Extracted text snippet
  • Page location (if available)
  • Contract source
  • Confidence score (0-1)
  • Review recommendation flag

Feature 4: Hybrid Contract Search

Functionality

Combines TF-IDF, BM25, and metadata filtering to provide comprehensive search across all uploaded contracts. Results are ranked by relevance using Reciprocal Rank Fusion.

Search Methods

Method Technology Purpose
Keyword Search BM25 algorithm Exact term matching
Similarity Search TF-IDF + Cosine Find related concepts
Metadata Filter Session state Filter by contract name, date
Hybrid Fusion Reciprocal Rank Fusion Combined relevance ranking

Example Queries That Work

  • "payment terms 30 days"
  • "liability cap"
  • "termination notice period"
  • "indemnification"
  • "force majeure"

Technical Specifications

  • TF-IDF with 10,000 max features
  • BM25 with k1=1.5, b=0.75, epsilon=0.25
  • N-gram range: 1-3
  • Stop word removal for English

Feature 5: Intelligent Version Comparison

Functionality

Compares two versions of a contract and highlights differences with color-coded visual diff and comprehensive change analysis.

Change Detection

Change Type Highlight Style Description
Added Text Green background Lines present in new version
Removed Text Red strikethrough Lines present in original only
Modified Text Yellow background Lines with content changes
Formatting Ignored Whitespace changes only

Analysis Features

  • Total added lines count
  • Total removed lines count
  • Total modified lines count
  • Similarity percentage
  • Change distribution by type
  • Change impact assessment (minor/moderate/major)

Use Cases

  • Compare original vs amended agreements
  • Track changes between contract versions
  • Review redlined documents
  • Identify substantive changes

Feature 6: Cross-Contract Inconsistency Detection

Functionality

Analyzes all uploaded contracts to find conflicting numeric and date values across your contract portfolio.

What It Detects

Comparison Type Example Contradiction
Payment Terms 30 days vs 60 days vs 90 days
Liability Caps $1M vs $5M vs Unlimited
Termination Notice 30 days vs 60 days
Governing Law CA vs NY vs DE
Confidentiality Period 1 year vs 3 years vs 5 years
Renewal Terms Auto-renew vs manual renewal

"Show Me the Norm" Feature

Metric Status
Most common value across your contracts
Percentage of contracts using norm
List of deviating contracts

Output Format

  • Clause type analyzed
  • Conflict detection (true/false)
  • All values found across contracts
  • Most common value with percentage
  • List of contracts that deviate
  • Actionable recommendation

Feature 7: Risk Indicator Discovery with Active Learning

Functionality

Scans contracts for predefined risk indicators and allows users to customize risk rules with export/import functionality.

Predefined Risk Indicators

Risk Type Default Severity
Unlimited Liability Critical
Auto-Renewal High
No Termination for Convenience Medium
Broad Indemnification Medium
Short Payment Terms (7/10/14/15 days) Medium
Missing Governing Law Low
Missing Confidentiality Duration Low

Active Learning Mechanism

  • Adjust severity levels for any risk type
  • Add custom risk patterns with regex
  • Export risk rules as JSON files
  • Import previously exported rules

Risk Trend Analysis

Shows current risk snapshot with comparison to previous import when users import their saved rules.


Feature 8: AI Contract Assistant

Functionality

Provides AI-powered chat interface for contract questions using Groq API (free tier).

Requirements

  • User provides their own Groq API key
  • Optional feature, not required for core functionality
  • Free API key available at console.groq.com

Capabilities

  • Answer questions about contract content
  • Summarize contract terms
  • Explain clause implications
  • Extract specific information
  • Compare contracts

Supported Models

  • Mixtral-8x7b-32768 (default)
  • Llama3-70b-8192
  • Gemma2-9b-it
  • Llama3-8b-8192

Local Fallback

When no API key is provided, the system provides enhanced keyword matching to find relevant contract sections.


Feature 9: Contract Template Library

Functionality

Provides 6 fillable contract templates with real-time validation and rule-based warnings.

Included Templates

Template Use Case
NDA (Unilateral) One-way confidentiality
NDA (Mutual) Two-way confidentiality
Master Services Agreement Ongoing vendor relationship
Independent Contractor Agreement Freelancers/consultants
Employment Offer Letter Hiring employees
Software License Agreement Software sales

Template Features

Feature Status
Fillable Fields
Smart Defaults
Real-time Validation
Rule-based Warnings

Rule-Based Warning Examples

Field Value Warning
Liability Cap Unlimited High risk warning
Liability Cap $100,000 Below standard warning
Liability Cap $1,000,000 Standard checkmark
Payment Terms 7 days Very short warning
Payment Terms 15 days Short warning
Payment Terms 30 days Standard checkmark

Feature 10: Executive Dashboard

Functionality

Provides a high-level overview of all contracts and key metrics.

Dashboard Components

  • Total contracts uploaded
  • Total clauses extracted
  • Risk summary by severity (Critical, High, Medium, Low)
  • Contract distribution charts
  • Recent activity feed
  • Quick action buttons
  • Demo mode launcher

Demo Mode

One-click button loads 3-5 sample contracts instantly, allowing users to explore all features without uploading their own files.


Feature 11: Clause Explorer

Functionality

Displays all extracted clauses organized by type, contract, and relevance.

Features

  • Filter by clause type (8 types available)
  • Search within clauses
  • Sort by contract, clause type, or relevance
  • Export clause data
  • View original context
  • Minimum confidence filter

View Options

  • Table view for structured data
  • Card view for visual browsing
  • Detail view for clause content

Feature 12: Professional Reports

Functionality

Generates professional branded reports in PDF and HTML formats.

Report Types

Report Type Contents
Full Analysis All contracts, all clauses, all risks
Risk Summary Only risk findings by severity
Clause Comparison Cross-contract clause comparison
Executive Summary High-level metrics and recommendations

Report Features

  • Branded header with KontractIQ logo
  • Professional white and blue theme
  • Tabular data with pandas DataFrames
  • Charts and visualizations (Plotly)
  • Risk indicators with color coding
  • Export to PDF and HTML
  • Download buttons

6. PAGES AND NAVIGATION STRUCTURE

Page Organization

The platform organizes 15 pages into 5 logical groups for intuitive navigation.


📁 CONTRACTS Group

Page 1: Dashboard (app.py)

Purpose: Main landing page with key metrics

Components:

  • Hero section with welcome message
  • Key metrics cards (contracts, clauses, risks)
  • Risk severity distribution chart
  • Recent contracts list
  • Quick action buttons for common tasks
  • Demo mode launcher

Page 2: Upload Contracts (pages/1_upload.py)

Purpose: Upload single or batch contracts

Features:

  • Drag-and-drop file uploader
  • Support for PDF, DOCX, TXT
  • Batch upload capability
  • Progress indicators
  • Scanned PDF detection
  • Contract limit counter (0/20)
  • Uploaded contracts list

Page 3: Contract Explorer (pages/2_contract_explorer.py)

Purpose: View and manage all contracts

Features:

  • List of all uploaded contracts
  • Contract metadata (name, size, pages, upload date)
  • Search and filter contracts
  • Delete individual contracts
  • Clear all contracts button
  • Contract preview functionality

Page 4: Clause Library (pages/3_clause_explorer.py)

Purpose: Browse extracted clauses

Features:

  • All extracted clauses organized by type
  • Filter by clause type (8 types)
  • Search within clauses
  • Sort options
  • Export clause data as CSV/JSON
  • View original context

🔍 ANALYSIS Group

Page 5: Search (pages/4_find.py)

Purpose: Hybrid search across all contracts

Features:

  • Search input with suggestions
  • Hybrid search (TF-IDF + BM25)
  • Result ranking with relevance scores
  • Highlight matched terms
  • Filter by contract
  • Export search results

Page 6: Compare (pages/5_compare.py)

Purpose: Version-to-version contract comparison

Features:

  • Two-column contract selector
  • Select version A and version B
  • Visual diff highlighting
  • Side-by-side or inline view
  • Change summary statistics
  • Export comparison report

Page 7: CrossCheck (pages/6_crosscheck.py)

Purpose: Find numeric/date contradictions

Features:

  • Automatic cross-contract analysis
  • Numeric/date contradiction detection
  • Show me the norm feature
  • List of deviating contracts
  • Recommendations for each conflict
  • Export inconsistency report

Page 8: RiskScan (pages/7_riskscan.py)

Purpose: Risk detection with export/import

Features:

  • Risk detection across all contracts
  • Risk summary by severity
  • Detailed risk findings per contract
  • Adjust severity levels
  • Add custom risk patterns
  • Export risk rules as JSON
  • Import previously exported rules

📊 INSIGHTS Group

Page 9: Vendor Consistency (pages/10_vendor_consistency.py)

Purpose: Analyze vendor contract patterns

Features:

  • Analyze contracts by vendor
  • Vendor comparison metrics
  • Find inconsistent terms by vendor
  • Vendor risk scoring
  • Export vendor analysis report

Page 10: Anomaly Detection (pages/11_anomaly_detection.py)

Purpose: Find unusual contract terms

Features:

  • Statistical anomaly detection
  • Unusual term patterns
  • Outlier identification
  • Review recommendations
  • Export anomaly report

🤖 AI FEATURES Group

Page 11: AI Chat (pages/8_ask.py)

Purpose: Ask questions about contracts

Features:

  • Chat interface for contract questions
  • Optional Groq API key input
  • Local fallback for no API key
  • Conversation history
  • Copy responses to clipboard
  • Clear conversation button

Page 12: Create Contract (pages/9_create.py)

Purpose: Generate contracts from templates

Features:

  • Contract template selection (6 templates)
  • Fillable form fields
  • Real-time validation
  • Rule-based warnings
  • Preview generated contract
  • Download as DOCX or TXT

📄 OUTPUTS Group

Page 13: Reports (pages/12_reports.py)

Purpose: Generate PDF/HTML reports

Features:

  • Report type selection (4 types)
  • Contract selection for report
  • Format selection (PDF or HTML)
  • Generate and preview report
  • Download report button

Page 14: System Metrics (pages/13_metrics.py)

Purpose: Monitor system performance

Features:

  • Memory usage monitor
  • Contract count and limits
  • Processing time statistics
  • Session information
  • Export session data

7. TECHNOLOGY STACK DETAILS

Frontend Technologies

Component Technology Version
UI Framework Streamlit 1.32.0
Charts Plotly 5.18.0
Data Tables Pandas 2.0.3
Icons Tabler Icons N/A

Streamlit 1.32.0

The core UI framework provides reactive components, session state management, and seamless deployment to Streamlit Cloud. Streamlit's component model enables rapid development of data applications with minimal boilerplate.

Plotly 5.18.0

Interactive charting library provides visual analytics with rich interactivity. Charts are fully responsive and support hover details, zooming, and panning. Plotly integrates seamlessly with Streamlit through st.plotly_chart.

Pandas 2.0.3

Data manipulation library handles all tabular data operations including contract metadata, clause extraction results, risk findings, and report data. Pandas provides efficient data structures for analysis and export.


Backend Technologies

Component Technology Version
Language Python 3.10+
Session State Streamlit Built-in

Python 3.10+

The core programming language provides robust data processing, natural language processing, and machine learning capabilities. Python's extensive library ecosystem enables all platform features.

Streamlit Session State

Built-in session management provides persistence for contract data, clauses, risks, and user preferences. Session state enables the privacy-first architecture with no external database required.


Document Processing Technologies

Component Technology Version
PDF Parsing PyPDF2 3.0.1
PDF Fallback pdfplumber 0.10.3
DOCX Parsing python-docx 1.1.0

PyPDF2 3.0.1

Primary PDF parsing library provides fast text extraction from standard PDF files. PyPDF2 handles most text-based PDFs efficiently and is the first-choice parser for speed.

pdfplumber 0.10.3

Secondary PDF parsing library provides better text extraction from challenging PDFs. pdfplumber is used as a fallback when PyPDF2 extraction yields insufficient text.

python-docx 1.1.0

Microsoft Word document parsing library extracts text from DOCX files. python-docx preserves basic document structure while extracting all paragraph text.


AI & Machine Learning Technologies

Component Technology Memory
Search scikit-learn (TF-IDF) 15MB
Keyword Search rank_bm25 (BM25) 10MB
Similarity cosine_similarity 5MB
NLP SpaCy (en_core_web_sm) 40MB

scikit-learn 1.3.2 (TF-IDF)

Machine learning library provides TF-IDF vectorization for semantic search. The TfidfVectorizer creates document vectors with 10,000 max features, stop word removal, and n-gram range of 1-3.

rank_bm25 0.2.2 (BM25)

Information retrieval library provides BM25 scoring for exact keyword matching. The BM25Okapi implementation includes k1=1.5, b=0.75, and epsilon=0.25 parameters optimized for contract text.

SpaCy 3.7.2 (en_core_web_sm)

Natural language processing library provides clause detection and entity recognition. The small English model (40MB) balances accuracy with memory efficiency, loading lazily only when needed.


Optional AI Technologies

Component Technology Free Tier
LLM Groq API 30 req/min
Model mixtral-8x7b-32768 Free

Groq API

Cloud-based LLM API provides intelligent contract Q&A with free tier access. Groq offers 30 requests per minute for the mixtral-8x7b-32768 model.


Report Generation Technologies

Component Technology Version
PDF Generation ReportLab 4.0.7
HTML Templates Jinja2 3.1.2

ReportLab 4.0.7

PDF generation library creates professional reports with proper formatting. ReportLab handles page layout, tables, charts, and branding.

Jinja2 3.1.2

HTML template engine generates interactive web reports. Jinja2 templates include styling, interactivity, and responsive design.


Utilities

Component Technology Version
Environment python-dotenv 1.0.0
System Monitoring psutil N/A

python-dotenv 1.0.0

Environment variable management handles configuration and secrets. dotenv loads .env files for local development and Streamlit secrets for production.

psutil

System monitoring library provides memory usage tracking. psutil enables the System Metrics page with real-time performance data.


Requirements.txt

# Core
streamlit==1.32.0
pandas==2.0.3
numpy==1.24.3
plotly==5.18.0

# Document Processing
PyPDF2==3.0.1
pdfplumber==0.10.3
python-docx==1.1.0

# Search & ML (Lightweight)
scikit-learn==1.3.2
rank-bm25==0.2.2

# NLP
spacy==3.7.2

# Reports
reportlab==4.0.7
jinja2==3.1.2

# Utilities
python-dotenv==1.0.0

8. SYSTEM ARCHITECTURE DEEP DIVE

High-Level Architecture

The platform follows a clean three-tier architecture with clear separation of concerns:

┌─────────────────────────────────────────────────────────────────────────────┐
│                              PRESENTATION LAYER                            │
│                        Streamlit Application (15 Pages)                    │
│                                                                             │
│  ┌──────────┐ ┌──────────┐ ┌──────────┐ ┌──────────┐ ┌──────────┐       │
│  │Dashboard │ │  Upload  │ │ Explorer │ │  Search  │ │  Compare │       │
│  └──────────┘ └──────────┘ └──────────┘ └──────────┘ └──────────┘       │
│  ┌──────────┐ ┌──────────┐ ┌──────────┐ ┌──────────┐ ┌──────────┐       │
│  │CrossCheck│ │ RiskScan │ │  Vendor  │ │ Anomaly  │ │ AI Chat  │       │
│  └──────────┘ └──────────┘ └──────────┘ └──────────┘ └──────────┘       │
│  ┌──────────┐ ┌──────────┐ ┌──────────┐ ┌──────────┐                    │
│  │  Create  │ │ Reports  │ │ Metrics  │ │  Clause  │                    │
│  └──────────┘ └──────────┘ └──────────┘ └──────────┘                    │
└─────────────────────────────────────────────────────────────────────────────┘
                                    │
                                    ▼
┌─────────────────────────────────────────────────────────────────────────────┐
│                              BUSINESS LOGIC LAYER                          │
│                            Core Modules (8 Modules)                        │
│                                                                             │
│  ┌──────────────┐ ┌──────────────┐ ┌──────────────┐ ┌──────────────┐    │
│  │   Parser     │ │  Extractor   │ │   Search     │ │  Comparator  │    │
│  └──────────────┘ └──────────────┘ └──────────────┘ └──────────────┘    │
│  ┌──────────────┐ ┌──────────────┐ ┌──────────────┐ ┌──────────────┐    │
│  │  CrossCheck  │ │  RiskScan    │ │   Templates  │ │   Reports    │    │
│  └──────────────┘ └──────────────┘ └──────────────┘ └──────────────┘    │
└─────────────────────────────────────────────────────────────────────────────┘
                                    │
                                    ▼
┌─────────────────────────────────────────────────────────────────────────────┐
│                                DATA LAYER                                  │
│                          Session State (Memory < 500MB)                    │
│                                                                             │
│  ┌─────────────────────────────────────────────────────────────────────┐   │
│  │  • Uploaded contracts (text + metadata) - Max 20 contracts         │   │
│  │  • Extracted clauses - Max 8 types × 20 contracts                  │   │
│  │  • Risk findings - Session only                                    │   │
│  │  • User feedback - Exportable as JSON                              │   │
│  └─────────────────────────────────────────────────────────────────────┘   │
└─────────────────────────────────────────────────────────────────────────────┘

Component Architecture

Upload Component

  • Handles file validation, parsing, and contract creation
  • Uses DocumentParser for text extraction
  • Creates Contract objects with metadata

Parser Component

  • Extracts text from PDF, DOCX, and TXT files
  • Implements multiple parsing strategies for PDF files
  • Falls back from PyPDF2 to pdfplumber as needed

Extractor Component

  • Identifies and extracts 8 clause types
  • Uses regex patterns and SpaCy NLP
  • Returns Clause objects with confidence scores

Search Component

  • Implements hybrid TF-IDF + BM25 search
  • Handles document indexing, query processing, and result ranking
  • Uses Reciprocal Rank Fusion for combined ranking

Compare Component

  • Provides intelligent version comparison
  • Categorizes changes, calculates similarity
  • Generates insights and change statistics

CrossCheck Component

  • Analyzes contracts for numeric and date inconsistencies
  • Identifies payment term, liability cap, termination notice variations
  • Generates recommendations for standardization

RiskScan Component

  • Scans contracts for risk indicators
  • Handles rule management and risk detection
  • Provides severity classification and recommendations

Ask Component

  • Provides AI-powered contract Q&A
  • Integrates with Groq API
  • Includes local fallback for keyword-based answers

Create Component

  • Generates contracts from templates
  • Handles field validation and warning generation
  • Renders professional contract documents

Report Component

  • Generates professional PDF and HTML reports
  • Creates comprehensive analysis with charts and tables
  • Provides branded reporting with professional formatting

Data Flow Architecture

Upload Flow

User Uploads File → File Validation → Document Parsing → 
Text Extraction → Contract Creation → Session Storage

Extraction Flow

Contract Text → Clause Extraction → Confidence Scoring → 
Clause Storage → Session Update

Search Flow

User Query → Query Processing → TF-IDF + BM25 Search → 
Rank Fusion → Result Display

CrossCheck Flow

Contract Collection → Value Extraction → Pattern Analysis → 
Norm Identification → Deviation Detection → Recommendation Generation

RiskScan Flow

Contract Collection → Rule Application → Risk Detection → 
Severity Classification → Result Storage

Report Flow

Data Collection → Template Rendering → Chart Generation → 
PDF/HTML Creation → Download

Memory Optimization Strategy

Session State

  • Stores only essential data with efficient data structures
  • Contracts store text truncation to 100,000 characters
  • Clauses store limited text snippets
  • Risks store minimal metadata

TF-IDF Vectorizer

  • Limited to 10,000 max features
  • Stop word removal reduces vocabulary
  • N-gram range limited to 1-3

BM25 Index

  • Efficient sparse representation
  • Optimized parameters for contract text

SpaCy Model

  • Lazy loading only when needed
  • Small English model (40MB) for memory efficiency

Text Truncation

  • Contract text limited to 100,000 characters
  • Clause text limited to 1,000 characters
  • Preview text limited to 200 characters

Memory Usage Estimates

Component Memory Usage
Session State (20 contracts) 200-300MB
TF-IDF Vectorizer 15MB
BM25 Index 10MB
SpaCy Model 40MB
Application Code 50MB
Overhead 100MB
Total 500-800MB

Security Architecture

Session-Based Storage

  • No data ever persists to the cloud
  • All contract data remains in the browser session
  • Session termination automatically clears all data

No External Dependencies

  • Core features work without any API keys
  • No external services required for primary functionality

Input Validation

  • All file uploads are validated for type, size, and content
  • Search queries are sanitized
  • Form inputs are validated

HTTPS Only

  • Streamlit Cloud enforces HTTPS for all connections
  • Data transmission is encrypted

No Vulnerable Dependencies

  • All dependencies are current versions
  • No known vulnerabilities
  • Regular updates ensure security

9. DEPLOYMENT ARCHITECTURE

Streamlit Cloud Deployment

Requirements

Requirement Specification
Hosting Streamlit Community Cloud (free)
Source Control GitHub repository
Python Version 3.10+
Memory 1GB (sufficient with optimizations)
Storage Session-based only

Deployment Process

  1. Push code to GitHub repository
  2. Go to share.streamlit.io
  3. Connect GitHub account
  4. Select repository and branch
  5. Set main file to app.py
  6. Click Deploy

Configuration File (.streamlit/config.toml)

[theme]
primaryColor = "#2C5F8A"
backgroundColor = "#E8F1F8"
secondaryBackgroundColor = "#FFFFFF"
textColor = "#0A2647"
font = "sans serif"

[server]
maxUploadSize = 10
enableXsrfProtection = true
enableCORS = false

[browser]
gatherUsageStats = false

[runner]
magicEnabled = false
installTracer = false

Environment Variables (Optional)

# .streamlit/secrets.toml
# Optional - only for AI Chat feature
GROQ_API_KEY = "your_groq_api_key_here"

# Optional - disable telemetry
STREAMLIT_TELEMETRY = "false"

Local Development

Requirements

Component Minimum Recommended
RAM 4GB 8GB
Storage 1GB free 2GB free
CPU Any modern CPU Intel i5 / Ryzen 5
OS Windows, Mac, Linux Any

Setup Process

  1. Clone repository
  2. Create virtual environment
  3. Install dependencies
  4. Download SpaCy model
  5. Run streamlit run app.py

10. UNIQUE DIFFERENTIATORS

What Makes KontractIQ Different

Differentiator KontractIQ Competitors
Cross-Contract Numeric Detection
Session Feedback with Export/Import
"Show Me the Norm" Feature Limited
Local/Session Deployment No (or expensive)
Template Rule-Based Warnings No
Scanned PDF Detection Varies
Demo Mode No
Open Source No
Zero Financial Cost No
Works on Streamlit Cloud 1GB N/A

Key Innovations

1. Cross-Contract Numeric Detection

Most tools analyze one contract in isolation. KontractIQ finds payment term, liability cap, and notice period conflicts across your entire contract portfolio.

2. Export/Import Risk Rules

Your risk preferences aren't lost between sessions. Download your rules as JSON and reuse them anytime.

3. Show Me the Norm

Instantly see the most common term across your contracts. Identify which contracts deviate from your portfolio norm.

4. Session-Based Architecture

No database required. Privacy-focused with no permanent storage. Deploys anywhere with zero infrastructure.

5. Demo Mode

Test all features without uploading files. Perfect for evaluation and demonstrations.


11. COMPETITOR COMPARISON

Enterprise Competitors

Aspect KontractIQ Evisort Kira Ironclad
Price $0 $50k+/year $42k+/year $30k+/year
Cross-Contract (Numeric)
Session Learning
Local/Session Deployment $$$
Open Source
Works in 1GB Memory
Demo Mode

Analysis

KontractIQ vs Evisort: Evisort charges $50,000+ per year. KontractIQ provides cross-contract numeric detection, session learning, local deployment, open source, and demo mode - all features Evisort lacks. KontractIQ works within 1GB memory, while Evisort requires enterprise infrastructure.

KontractIQ vs Kira: Kira Systems costs $42,000+ per year. Kira lacks cross-contract numeric detection, session learning, and local deployment. KontractIQ offers all these capabilities for free.

KontractIQ vs Ironclad: Ironclad charges $30,000+ per year. KontractIQ provides superior analysis capabilities with cross-contract inconsistency detection, active learning, and professional reporting.


Free/Open Source Competitors

Aspect KontractIQ ClauseGuard PAKTON RAG Analyzer
Price $0 Subscription $0 $0
Cross-Contract (Numeric)
Multi-Contract
Version Compare
Templates
Reports
Production Ready
Demo Mode

Analysis

KontractIQ vs ClauseGuard: ClauseGuard is a subscription-based tool with limited free tier. KontractIQ provides all features completely free. ClauseGuard lacks cross-contract numeric detection, multi-contract analysis, version comparison, templates, and professional reports.

KontractIQ vs PAKTON: PAKTON is open source but limited to basic contract extraction. KontractIQ provides comprehensive intelligence with 12 features, 15 pages, and professional reporting.

KontractIQ vs RAG Analyzer: RAG Analyzer is experimental and not production-ready. KontractIQ is fully production-ready with comprehensive features.


12. FUTURE ENHANCEMENTS

Phase 2 (3-6 Months)

Enhancement Priority
5 more clause types (13 total) High
Risk trend over time (with import history) High
PDF OCR support (Tesseract) Medium
Custom user templates Medium
Batch export all contracts as ZIP Low

Details

5 More Clause Types: Expanding to 13 clause types will capture more contract provisions. Planned additions include assignment, entire agreement, severability, waivers, and amendment clauses.

Risk Trend Over Time: With import history tracking, users will see how risk profiles change over time. This enables trend analysis and remediation tracking.

PDF OCR Support: Integration with Tesseract OCR will enable processing of scanned PDFs. This removes the biggest limitation for users with legacy scanned contract archives.


Phase 3 (6-12 Months)

Enhancement Priority
Optional sentence-transformers Medium
Anonymous peer comparison Medium
Team collaboration Medium
API access for programmatic use Low
Mobile app Low

Details

Optional Sentence-Transformers: User-opt-in for more advanced semantic search. Provides better relevance for complex queries while maintaining the option for lightweight operation.

Anonymous Peer Comparison: Opt-in data sharing for anonymous benchmarking. Organizations can compare their contract terms to industry peers.

Team Collaboration: Shared sessions for team analysis. Multiple users can work on the same contract portfolio simultaneously.


13. PROJECT METRICS AND SPECIFICATIONS

Feature Metrics

Metric Value
Clause Types Extracted (Phase 1) 8
Pages in App 15
Report Types 4
Risk Severity Levels 4
File Types Supported 3 (PDF, DOCX, TXT)
Max Contracts Per Session 20
Max File Size 10MB
Search Methods 3 (TF-IDF, BM25, Metadata)
Contract Templates 6
Quick Search Queries 8

Performance Metrics

Metric Value
Memory Usage <800MB (fits in 1GB)
Processing Time <5 seconds per contract
Search Speed <1 second for 20 contracts
Report Generation <10 seconds for full analysis

Code Metrics

Component Lines of Code
Core Modules ~3,000
Pages ~5,000
Components ~1,500
Models ~800
Utilities ~700
Total ~11,000

Unique Selling Points Summary

USP Description
Cross-Contract Numeric Detection Detects payment term, liability cap, notice period conflicts
Session Learning with Export Your risk rules exportable/importable
Zero Financial Cost Enterprise features at $0
Open Source No vendor lock-in
Professional Reports PDF and HTML with branding
Beautiful UI White and blue theme
Streamlit Deployable Fits in 1GB memory
Demo Mode Try instantly without uploading

14. USER GUIDE AND BEST PRACTICES

Getting Started

Step 1: Upload Contracts

Navigate to Upload Contracts and upload your PDF, DOCX, or TXT files. Use batch upload for efficiency. The system will parse and extract text automatically.

Step 2: Explore Dashboard

View key metrics on the Dashboard. Understand your contract portfolio health at a glance. Use quick actions for common tasks.

Step 3: Search Contracts

Use Search to find specific clauses across all contracts. Filter results by contract, file type, or clause type. Export findings for offline analysis.

Step 4: Run CrossCheck

Analyze all contracts for inconsistencies. Review payment term, liability cap, and notice period variations. Identify deviations from portfolio norms.

Step 5: Scan for Risks

Run RiskScan to identify high-risk clauses. Review findings by severity. Adjust severity levels as needed. Export risk rules for team sharing.

Step 6: Generate Reports

Create professional reports for stakeholders. Choose from 4 report types. Export as PDF or HTML for distribution.


Best Practices

For Optimal Performance

  • Upload 5-10 contracts at a time for best results
  • Use text-based PDFs rather than scanned documents
  • Name contracts clearly for easy identification
  • Run CrossCheck after uploading all contracts
  • Export risk rules for team consistency

For Risk Management

  • Review critical risks immediately
  • Address high risks within 7 days
  • Monitor medium risks monthly
  • Track low risks quarterly
  • Export rules to share with team

For Reporting

  • Use Full Analysis for comprehensive reviews
  • Use Risk Summary for executive updates
  • Use Clause Comparison for standardization
  • Use Executive Summary for board presentations

For Contract Creation

  • Start with a template for consistency
  • Review all warnings before finalizing
  • Use smart defaults as starting points
  • Export as DOCX for professional formatting
  • Save templates for team use

Pro Tips

Tip Description
💡 Upload multiple contracts at once for cross-contract analysis
🎯 Use the Search feature to find specific clauses across all contracts
⚠️ Run RiskScan to identify high-risk clauses automatically
📊 Generate professional reports for stakeholders and compliance
🎮 Load demo data to explore all features without uploading
🔒 Your data stays private - all processing is session-based
📈 Check System Metrics to monitor memory usage and performance

Troubleshooting

Common Issues

Issue: PDF appears scanned

  • Solution: Use text-based PDFs or upload as DOCX/TXT
  • Detection: System automatically detects scanned PDFs

Issue: Memory limit reached

  • Solution: Reduce number of contracts or contract size
  • Detection: System Metrics page shows memory usage

Issue: Search returns no results

  • Solution: Try different keywords or broader query
  • Tip: Use quotes for exact phrases

Issue: RiskScan shows no risks

  • Solution: Check risk rules configuration
  • Tip: Add custom rules for specific risks

15. CONCLUSION

Project Summary

KontractIQ represents a significant advancement in contract intelligence technology. It combines enterprise-grade capabilities with complete accessibility, providing professional contract analysis tools to organizations of all sizes. The platform's 12 core features, 15 intuitive pages, and comprehensive reporting capabilities deliver value across legal, procurement, compliance, and business teams.


Key Achievements

Technical Excellence

The platform demonstrates sophisticated technical architecture with optimized memory usage, efficient algorithms, and robust error handling. The hybrid search engine combining TF-IDF and BM25 provides enterprise-grade search capabilities. The cross-contract inconsistency detection engine reveals insights that manual review cannot identify.

Design Excellence

The professional white and blue theme with complete design system delivers premium user experience. Consistent typography, spacing, colors, and interactions create a polished, professional application suitable for enterprise use.

Business Value

Organizations can analyze contracts faster than manual review, detect inconsistencies across their portfolio, compare versions intelligently, and generate professional reports for stakeholders. The platform's zero-cost model democratizes contract intelligence, making it accessible to organizations of all sizes.

Strategic Positioning

KontractIQ uniquely combines cross-contract numeric detection, active learning, session-based deployment, and zero financial cost. This combination of features is unmatched in both commercial and open-source alternatives.


Final Statement

KontractIQ is a production-ready, deployable contract intelligence platform built for Streamlit Community Cloud with zero financial cost. It helps legal, procurement, compliance, and business teams analyze contracts faster than manual review.

Unlike traditional tools that analyze one document in isolation, KontractIQ detects numeric and date inconsistencies across multiple contracts, provides rule-based AI, and generates professional branded reports.

The platform handles 20 contracts per session with 10MB file size limits, all within 1GB memory. It extracts 8 clause types, provides hybrid search, intelligent comparison, cross-contract inconsistency detection, risk scanning with active learning, and professional reporting.

With 15 pages and 12 core features, it provides comprehensive contract intelligence capabilities previously only available to large enterprises with significant budgets.

KontractIQ represents the future of contract intelligence: powerful, accessible, and free. It delivers on its core promise of "Intelligence for every clause" through thoughtful design, sophisticated technology, and unwavering commitment to user value.


Project Overview Summary

Aspect Summary
Name KontractIQ
Tagline "Intelligence for every clause."
Type Contract Intelligence Platform
Price $0 (100% free)
Deployment Streamlit Cloud (1-click)
Open Source Yes
Core Features 12 features
Pages 15 pages (grouped navigation)
Report Formats PDF and HTML with branded footer
API Required Optional (only for AI Chat)
Memory Usage <800MB (fits in 1GB)
Clause Types 8 (Phase 1), more coming
Contract Templates 6
Risk Severity Levels 4
File Types Supported 3 (PDF, DOCX, TXT)
Max Contracts Per Session 20
Max File Size 10MB
Search Methods 3 (TF-IDF, BM25, Metadata)

Developer Contact

Aspect Details
Developer Hassan Subhani
Email hassansubhani822@gmail.com
GitHub @Hassan0397
LinkedIn itshassansubhani

Acknowledgments

  • Streamlit for the amazing framework
  • Groq for free AI API access
  • All open-source libraries used in this project
  • The legal and procurement professionals who inspired this tool

License

This project is licensed under the MIT License.

MIT License

Copyright (c) 2026 KontractIQ

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

⚖️ KontractIQ — Intelligence for every clause.

This app is Built by Hassan Subhani

About

KontractIQ is an AI-powered contract intelligence platform that analyzes, compares, and extracts insights from contracts. It detects inconsistencies, identifies risks, and generates professional reports—all free and deployable on Streamlit Cloud.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages