Project Info
π
Inspiration
Business contracts often carry hidden risks that can affect compliance, finances, or security β yet reviewing them manually is slow, subjective, and prone to oversight. Our team wanted to build an AI system that helps organizations evaluate vendor risk before signing a deal, in real time. We were inspired by the growing use of AI in due diligence and compliance automation and wanted to make risk intelligence accessible even to small teams without requiring a dedicated legal department. π§ What We Built Contract Simplifier is a real-time, AI-powered risk analysis system that identifies, evaluates, and visualizes potential vendor risks before an organization enters into a business contract. It combines LangGraph, ChromaDB, Bright Data, FastAPI, and React to form an intelligent end-to-end pipeline: User enters a query such as βAnalyze Tesla with high criticality.β The backend orchestrates multiple components: LangGraph controls the AI workflow as a state machine. Bright Data scrapes credible company data in real time. ChromaDB stores and retrieves context embeddings. OpenAI GPT-4 analyzes risk factors and scores vendors. The React frontend displays a live-streaming visualization of each analysis stage, showing how data moves from collection to insight. The React frontend displays a live-streaming visualization of each analysis stage, showing how data moves from collection to insight. This flow allows users to see the reasoning behind AI-driven conclusions, increasing transparency and trust. βοΈ How We Built It We followed a modular micro-frontend and microservice approach: Backend (FastAPI + LangGraph): Designed a pipeline with multiple βnodesβ for classification, scraping, validation, and LLM evaluation. Implemented streaming responses via Server-Sent Events (SSE) for real-time updates. Integrated ChromaDB as a semantic memory layer for contextual recall. Backend (FastAPI + LangGraph): Designed a pipeline with multiple βnodesβ for classification, scraping, validation, and LLM evaluation. Implemented streaming responses via Server-Sent Events (SSE) for real-time updates. Integrated ChromaDB as a semantic memory layer for contextual recall. Frontend (React + Tailwind CSS): Developed a split-screen interface β chat panel on the left, risk visualization on the right. Used animated progress indicators to show each step of the risk workflow. Rendered color-coded risk scores with smooth transitions and responsive layout. Frontend (React + Tailwind CSS): Developed a split-screen interface β chat panel on the left, risk visualization on the right. Used animated progress indicators to show each step of the risk workflow. Rendered color-coded risk scores with smooth transitions and responsive layout. Data Layer: Leveraged Bright Data for trusted source collection. Applied domain-based filtering to prioritize credible sites (e.g., .gov, .edu, Bloomberg, Reuters). Data Layer: Leveraged Bright Data for trusted source collection. Applied domain-based filtering to prioritize credible sites (e.g., .gov, .edu, Bloomberg, Reuters). π Key Features AI Risk Scoring across four critical dimensions: π¦ Financial Risk π Security Risk π Reputation Risk π§© Resilience Strength AI Risk Scoring across four critical dimensions: π¦ Financial Risk π Security Risk π Reputation Risk π§© Resilience Strength Streaming Visualization: View live updates of the analysis pipeline. Streaming Visualization: View live updates of the analysis pipeline. Source Verification: Automatically filters unreliable or duplicate data. Source Verification: Automatically filters unreliable or duplicate data. Vector Search with ChromaDB: Enhances context relevance for LLM queries. Vector Search with ChromaDB: Enhances context relevance for LLM queries. Smart Classification: Detects whether the user request is a risk query or general chat. Smart Classification: Detects whether the user request is a risk query or general chat. π§© Architecture Overview π‘ What We Learned AI pipelines benefit from clear state management. LangGraph helped us structure complex workflows that involved multiple data sources and LLM reasoning stages. Streaming enhances user trust. Showing every step of analysis makes AI decisions more explainable and engaging. Data credibility is crucial. Many scraped sources are unreliable, so integrating domain verification was key. Frontend performance tuning matters. Handling SSE in React required careful optimization to avoid UI lag during real-time updates. Cross-team collaboration is smoother with modular design. Each team member could iterate independently on backend, frontend, or AI pipeline. π§ Challenges We Faced Latency management: AI and web scraping operations can be slow, so we used asynchronous FastAPI tasks and caching. LLM consistency: Different runs could produce slightly varied risk ratings, so we implemented post-processing checks. Data validation: Ensuring only credible, non-duplicate sources reached the model required multiple iterations of our filtering logic. Frontend synchronization: Coordinating the live streaming events with changing backend states was initially tricky but solved using an event-driven architecture. π Impact The system demonstrates how AI can act as an assistant for contract risk evaluation β performing tasks that would normally take analysts hours. By providing real-time transparency, contextual memory, and automated reasoning, Contract Simplifier has the potential to help organizations reduce decision-making time and improve compliance readiness. π§° Tech Stack π§ͺ Future Enhancements Batch contract analysis for multiple vendors Integration with CRM or ERP systems Historical risk trend tracking PDF report export Multilingual support Custom risk factor weighting π€ Team Sanjay Sakthivel β AI & Backend (LangGraph, ChromaDB, FastAPI) Aman Nindra β Frontend & Streaming & Database Integration (React, Tailwind, Firebase, AWS) Rajbir Longia β Web Scraping & API Integration (Bright Data, REST) β€οΈ Closing Thoughts We built Contract Simplifier to show how AI can transform due diligence from a static checklist into a dynamic, explainable, and data-driven process. Itβs not just about predicting risk β itβs about understanding it in real time. βContracts define trust. Our AI ensures that trust is measurable.β
π‘οΈ Contract Simplifier
A real-time AI-powered contract risk analysis system that helps organizations assess vendor risks before entering business contracts. Built with LangGraph, FastAPI, and React with live streaming capabilities.
π Table of Contents
- Features
- Architecture
- Demo
- Installation
- Usage
- API Documentation
- Project Structure
- Configuration
- Contributing
- License
β¨ Features
π€ AI-Powered Analysis
- Intelligent Classification: Automatically detects risk analysis requests vs. general queries
- Multi-Source Data Gathering: Fetches information from multiple web sources
- Source Verification: Validates source credibility and filters unreliable information
- Vector Database Integration: Stores and retrieves relevant context using ChromaDB
- LLM Risk Scoring: Comprehensive risk assessment across multiple dimensions
π Real-Time Processing
- Live Streaming UI: Watch the analysis pipeline execute in real-time
- Stage-by-Stage Updates: See each processing step as it happens
- Progress Indicators: Visual feedback for every stage of analysis
- Status Messages: Detailed information about what's being processed
π¨ Modern Interface
- Split-Screen Design: Chat on the left, analysis visualization on the right
- Responsive Components: Beautiful UI built with React and Tailwind CSS
- Color-Coded Risk Scores: Easy-to-understand visual risk indicators
- Smooth Animations: Professional transitions and loading states
π Comprehensive Risk Assessment
Analyzes vendors across four key dimensions:
- Financial Risk (1-5): Stability, revenue, debt, market position
- Security Risk (1-5): Data breaches, vulnerabilities, compliance
- Reputation Risk (1-5): Legal issues, public perception, controversies
- Resilience Strength (1-5): Recovery capability, partnerships, certifications
ποΈ Architecture
βββββββββββββββ ββββββββββββββββ βββββββββββββββ
β React β ββSSEβββΊβ FastAPI β ββββββββΊβ LangGraph β
β Frontend β β Backend β β Pipeline β
βββββββββββββββ ββββββββββββββββ βββββββββββββββ
β β
βΌ βΌ
ββββββββββββββββ βββββββββββββββ
β Web Scraper β β ChromaDB β
ββββββββββββββββ βββββββββββββββ
β β
βΌ βΌ
ββββββββββββββββ βββββββββββββββ
β OpenAI β β Vector β
β LLM API β β Storage β
ββββββββββββββββ βββββββββββββββ
Tech Stack
Backend:
- Python 3.8+
- FastAPI - Modern web framework with async support
- LangGraph - State machine for AI workflows
- LangChain - LLM orchestration
- ChromaDB - Vector database for semantic search
- OpenAI GPT-4 - Language model for analysis
Frontend:
- React 18+
- Tailwind CSS - Utility-first styling
- Lucide Icons - Beautiful icon set
- Server-Sent Events (SSE) - Real-time streaming
π₯ Demo
Chat Interface
User: Analyze Tesla with high criticality
Assistant: π Risk Report for Tesla
β’ Financial Risk: 2/5
β’ Security Risk: 3/5
β’ Reputation Risk: 2/5
β’ Resilience Strength: 4/5
β Recommendation: PROCEED WITH PROTECTIONS
Real-Time Processing View
β Classifying request...
β Extracting company details...
β³ Fetching external data...
ββ Found 15 sources
β³ Verifying sources...
ββ Verified 12 high-trust sources
β³ Generating risk analysis...
π Installation
Prerequisites
- Python 3.8 or higher
- Node.js 16 or higher
- OpenAI API key
- Git
Backend Setup
- Clone the repository
git clone https://github.com/yourusername/contract-risk-analyzer.git
cd contract-risk-analyzer
- Create virtual environment
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
- Install Python dependencies
cd backend
pip install -r requirements.txt
- Set up environment variables
cp .env
Edit .env and add your API keys:
OPENAI_API_KEY=your_openai_api_key_here
CHROMA_HOST=chroma_url
CHROMA_PORT=chroma_port
BRIGHT_DATA_KEY=your_bright_data_key_api
-
Initialize ChromaDB Run ChromaDB using Dockers
-
Run the backend
uvicorn main:app --reload --port 8000
Backend will be available at http://localhost:8000
Frontend Setup
- Navigate to frontend directory
cd ../frontend
- Install dependencies
npm install
# or
yarn install
- Configure backend URL
Edit src/config.js if needed:
export const BACKEND_URL = 'http://localhost:8000';
- Run the development server
npm start
# or
yarn start
Frontend will be available at http://localhost:3000
π Usage
Advanced Risk Analysis
- Open the application in your browser
- Type in the chat:
"Analyze Tesla with high criticality" - Watch the real-time processing on the right panel
- Review the comprehensive risk report
General Questions
Ask general questions about contracts or the tool:
"What can you do?""What is contract risk?""How do you analyze companies?"
API Usage
Non-Streaming Endpoint
curl -X POST http://localhost:8000/chat \
-H "Content-Type: application/json" \
-d '{
"user_id": "user123",
"message": "Analyze Apple with medium criticality"
}'
Streaming Endpoint
curl -N -X POST http://localhost:8000/chat/stream \
-H "Content-Type: application/json" \
-d '{
"user_id": "user123",
"message": "Analyze Microsoft with high criticality"
}'
π API Documentation
Endpoints
POST /chat/stream
Real-time streaming endpoint for chat interactions.
Request:
{
"user_id": "string",
"message": "string"
}
Response: Server-Sent Events (SSE)
// Stage start event
data: {"type": "stage_start", "stage": "fetch_external_data", "message": "Searching..."}
// Stage complete event
data: {"type": "stage_complete", "stage": "fetch_external_data", "message": "Found 15 sources"}
// Final result event
data: {"type": "final", "mode": "risk_report", "assistant_reply": "...", "risk_report": {...}}
// Stream end
data: {"type": "done"}
POST /chat
Non-streaming endpoint for simple requests.
Request:
{
"userId": "string",
"userMessage": "string"
}
Response:
{
"success": true,
"response": "string",
"full_state": {
"assistant_reply": "string",
"risk_report": {...}
}
}
GET /health
Health check endpoint.
Response:
{
"status": "healthy"
}
π Project Structure
contract-risk-analyzer/
βββ backend/
β βββ main.py # FastAPI application
β βββ requirements.txt # Python dependencies
β βββ graphs/
β β βββ contractbot.py # LangGraph workflow
β βββ utils/
β β βββ stream_runner.py # Streaming pipeline
β β βββ webScraper.py # Web scraping utilities
β β βββ jsonConverter.py # LLM JSON helpers
β βββ db/
β βββ chromaClient.py # Vector database client
βββ frontend/
β βββ src/
β β βββ App.js # Main React component
β β βββ components/
β β β βββ ChatPanel.js # Chat interface
β β β βββ RiskAnalysisPanel.js # Analysis visualization
β β βββ config.js # Configuration
β βββ package.json # Node dependencies
β βββ public/
βββ .env.example # Environment variables template
βββ .gitignore
βββ README.md
βββ LICENSE
βοΈ Configuration
Environment Variables
Create a .env file in the backend directory:
# Required
OPENAI_API_KEY=sk-...
# Optional
BRAVE_API_KEY=... # For enhanced web search
CHROMA_PERSIST_DIRECTORY=./chroma_db
LOG_LEVEL=INFO
LangGraph Configuration
Customize the analysis pipeline in backend/graphs/contractbot.py:
# Adjust risk thresholds
RISK_THRESHOLDS = {
"proceed": {"max_risk": 2.5, "min_resilience": 4},
"proceed_with_protections": {"max_risk": 3.8, "min_resilience": 3},
"reject": {"min_risk": 3.9, "max_resilience": 2}
}
# Customize trusted domains for source verification
TRUSTED_DOMAINS = [
".gov", ".edu", ".org",
"reuters.com", "bloomberg.com",
"wsj.com", "forbes.com"
]
π§ͺ Testing
Run Backend Tests
cd backend
pytest tests/ -v
Run Frontend Tests
cd frontend
npm test
Manual Testing
Test the streaming endpoint:
curl -N -X POST http://localhost:8000/chat/stream \
-H "Content-Type: application/json" \
-d '{"user_id": "test", "message": "Analyze Google with high criticality"}'
π€ Contributing
Contributions are welcome! Please follow these steps:
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
Development Guidelines
- Follow PEP 8 for Python code
- Use ESLint for JavaScript/React code
- Write tests for new features
- Update documentation as needed
- Keep commits atomic and well-described
π Known Issues
- Large companies may take longer to analyze (30-60 seconds)
- Rate limiting may occur with high request volumes
- Some sources may not be accessible due to paywalls
πΊοΈ Roadmap
- Add support for batch analysis
- Implement user authentication
- Add historical analysis tracking
- Support for custom risk criteria
- Export reports as PDF
- Multi-language support
- Integration with CRM systems
π License
This project is licensed under the MIT License - see the LICENSE file for details.
π₯ Authors
- Sanjay Sakthivel - YourGitHub
- Aman Nindra - YourGitHub
- Rajbir Longia - YourGitHub
π Acknowledgments
- OpenAI for GPT-4 API
- LangChain team for the amazing framework
- ChromaDB for vector storage
- FastAPI for the excellent web framework
- React community for UI components
π Links
Made with β€οΈ by Contract Simplifier
β Star this repo if you find it helpful!
Analysis
View
Metric
- 15
- 14
- 7
Figures cover GitHub contributors during the hackathon window. A co-authored commit counts in full for each author, so per-member totals add up to more than the whole-team figures.
Technology
- CSSIn code
- FastAPIIn code
- FirebaseIn code
- HTMLIn code
- JavaScriptIn code
- LangChainIn code
- OpenAIIn code
- PythonIn code
- ReactIn code
- Tailwind CSSIn code
- TypeScriptIn code
- AWSClaimed
11 of 12 appear in the indexed code. 1 claimed on Devpost could not be matched to code, which may simply mean the tool leaves no trace in the repository.
AI coding agents
No AI coding agent signals were found in this repository.
Detected from committed agent config files and commit authorship. Absence of a signal is not proof an agent was unused.
Codebase size
Source size
2.7 MB
Source files
112
Counts recognized source files only; vendored directories, binaries and lockfiles are excluded, so this is smaller than the repository on disk.
Repository
sanjay872/Contract-Simplify
793 files Β· 208.5 MB Β· @ 24b7207
Structure
Interface
14 files Β· 2%Screens, components and styles rendered to the user.
API & routing
11 files Β· 1%Request entry points: routes, handlers and controllers.
Application logic
23 files Β· 3%Domain rules, services and shared utilities.
Data & schema
2 files Β· 0%Schema definitions, migrations and data access.
Supporting
Layers are inferred from where files sit in the tree, not from reading the code. A project that names its directories unconventionally will read oddly here β open the file browser to check anything the diagram implies.
Languages
- JavaScript77%
- CSS16%
- Python3%
- TypeScript3%
- Markdown1%
- HTML0%
Share of indexed source by file size. Binary and vendored files are excluded.
Dependencies
web/package.json
npm Β· 29- @nutrient-sdk/viewer
- @tailwindcss/vite
- class-variance-authority
- clsx
- firebase
- lucide-react
- pandoc
- pdfjs-dist
- react
- react-dom
- react-icons
- react-pdf
- react-router-dom
- tailwind-merge
- tailwindcss
- +14 more
server/requirements.txt
pypi Β· 12- boto3
- bs4
- chromadb
- fastapi
- langchain
- langchain-openai
- langgraph
- openai
- pydantic
- python-dotenv
- python-multipart
- uvicorn
requirements.txt
pypi Β· 7- boto3
- chromadb
- dotenv
- fastapi
- openai
- pdfplumber
- requests
Declared in the repositoryβs manifests at the indexed commit. A declared package is not proof it is used, and runtime dependencies are listed first.
This projectβs features have not been analysed yet.
Export this project's context (description, README, evidence, key source files) to chat with an AI agent elsewhere.