Skip to content

siddhart3000/contractscan-ai

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

📄 ContractScan AI

AI-Powered Contract Risk & Intelligence Analyzer

🔗 Live Application: https://contractscan-ai-pejjpdbqmcuqqgyyoaiw9a.streamlit.app/


🚀 Problem Statement

Legal contracts are complex, lengthy, and difficult for non-lawyers to interpret. Manual review is slow and often misses hidden risk clauses.

ContractScan AI solves this by using a large language model (LLaMA 3.3 70B via Groq) to:

  • Extract key contractual clauses
  • Detect legal & financial risks
  • Classify risk severity
  • Provide plain-English summaries
  • Return structured, machine-readable JSON

✨ Key Features

  • 📂 Upload contract PDFs (up to 200MB)
  • 📝 Paste raw contract text
  • 🤖 AI-driven clause extraction
  • ⚠️ Risk classification (High / Medium / Low)
  • 📊 Structured JSON response
  • 📘 Plain-English executive summary
  • 🎯 Clean, responsive Streamlit UI
  • ☁️ Cloud deployment (Streamlit Community Cloud)
  • 🔐 Secure API key handling via environment variables

🧠 System Architecture

User Input (PDF/Text)
        ↓
PDF Text Extraction (pdfplumber)
        ↓
Structured Prompt Engineering
        ↓
Groq LLaMA 3.3 70B API
        ↓
Strict JSON Response
        ↓
Parsed & Rendered Risk Dashboard

🏗️ Tech Stack

Layer Technology
Frontend Streamlit
Backend Logic Python
LLM Provider Groq API
Model LLaMA 3.3 70B Versatile
PDF Parsing pdfplumber
Environment Handling python-dotenv

📊 Example AI Output Structure

{
  "summary": "This contract defines employment terms between Company A and Employee B.",
  "parties": ["Company A", "Employee B"],
  "risk_flags": [
    {
      "clause": "Non-compete",
      "risk_level": "HIGH",
      "reason": "Restrictive 3-year non-compete period"
    }
  ],
  "recommendations": [
    "Negotiate non-compete duration",
    "Clarify termination conditions"
  ]
}

⚙️ Local Setup

1️⃣ Clone Repository

git clone https://github.com/siddhart3000/contractscan-ai.git
cd contractscan-ai

2️⃣ Create Virtual Environment

python -m venv venv
source venv/bin/activate      # Mac/Linux
venv\Scripts\activate         # Windows

3️⃣ Install Dependencies

pip install -r requirements.txt

4️⃣ Configure Environment Variable

Create .env file:

GROQ_API_KEY=your_groq_api_key_here

Get API key from: https://console.groq.com/keys

5️⃣ Run Application

streamlit run app.py

Access at: http://localhost:8501


☁️ Deployment

  • Deployed on Streamlit Community Cloud
  • Environment variables securely configured
  • Automatic redeploy on GitHub push
  • Public production-ready URL available

Live App: https://contractscan-ai-pejjpdbqmcuqqgyyoaiw9a.streamlit.app/


🔐 Security & Best Practices

  • API keys are NOT stored in repository
  • .env is excluded via .gitignore
  • Secrets managed securely in deployment
  • Strict JSON schema enforced in model response
  • Input validation implemented

🎯 Evaluation Alignment (AI Engineer Task 01)

✔ LLM API Integration ✔ Structured Information Extraction ✔ Risk Categorization Logic ✔ Clean & Functional UI ✔ Secure Deployment ✔ Public GitHub Repository ✔ Working Live Demo


📈 Future Enhancements

  • Predictive dispute probability scoring
  • Financial impact projection
  • Contract comparison engine
  • Downloadable PDF risk report
  • Job offer / campus drive analyzer module
  • Multi-language contract support

👨‍💻 Author

Siddharth Singh AI Enthusiast | DSA Developer | Data Visualizer B.Tech CSE @ LPU (2022–2026)

GitHub: https://github.com/siddhart3000


📜 License

This project is built for educational and evaluation purposes.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages