How gitbrewhub/contract-obligation-agent works
Contract.AI accepts PDF/DOCX contracts and returns structured obligations with source evidence, verification status, deadlines, and risk signals for review. Its principal workflow is orchestrated by LangGraph and persists results for Flask API access and a React review interface. The graph preserves the documented processing stages and the separate ingestion, retrieval, and persistence layers. Some frontend/API details and implementation internals are unsampled; those connections are shown only where the README documents them.
Main entry points: nodes.py Workflow Stages · contract_pipeline.py Contract Pipeline · retrieval.py Evidence Retrieval · repository.py Record Repository
Components 21
Workflow
- LangGraph Workflow
graph/workflow.py - Workflow Stages
graph/nodes.py - Contract Pipeline
pipeline/contract_pipeline.py
Analysis
- Obligation Extraction
agents/extraction_agent.py - NVIDIA Client
agents/nvidia_client.py - Schema Validation
agents/validation.py - Source Verification
agents/verification_agent.py - Deadline Parsing
utils/deadline_parser.py - Risk Analysis
agents/risk_engine.py
Ingestion & Data
- Text Ingestion
ingestion/loader.py - PDF / DOCX Parsers
ingestion/pdf_parser.py - Text Chunking
ingestion/chunker.py - Text Embeddings
ingestion/embedder.py - Evidence Retrieval
database/retrieval.py - Record Repository
database/repository.py - PostgreSQL + pgvector
database/schema.sql
Review Product
- Flask REST API
backend/app.py - Contract Review UI
frontend/src/App.jsx
Other components
- Contract Reviewer
- PDF / DOCX Contract
- NVIDIA-hosted LLM
Connections 33
- Contract Reviewer → Contract Review UI: uploads contract
README.md - PDF / DOCX Contract → Flask REST API: submits document
README.md - Flask REST API → LangGraph Workflow: starts workflow
backend/app.py - LangGraph Workflow → Workflow Stages: dispatches stages
graph/workflow.py - Workflow Stages → Text Ingestion: extracts text
graph/nodes.py - Text Ingestion → PDF / DOCX Parsers: selects parser
ingestion/loader.py - Workflow Stages → Text Chunking: chunks text
graph/nodes.py - Workflow Stages → Text Embeddings: embeds chunks
graph/nodes.py - Workflow Stages → Obligation Extraction: extracts obligations
graph/nodes.py - Obligation Extraction → NVIDIA Client: calls client
agents/extraction_agent.py - NVIDIA Client → NVIDIA-hosted LLM: requests inference
README.md - Workflow Stages → Schema Validation: validates output
graph/nodes.py - Workflow Stages → Evidence Retrieval: retrieves evidence
graph/nodes.py - Evidence Retrieval → Text Embeddings: embeds query
database/retrieval.py - Workflow Stages → Source Verification: verifies evidence
graph/nodes.py - Source Verification → Text Embeddings: embeds passages
agents/verification_agent.py - Workflow Stages → Deadline Parsing: parses deadlines
graph/nodes.py - Workflow Stages → Risk Analysis: evaluates risk
graph/nodes.py - Workflow Stages → Record Repository: stores obligations
graph/nodes.py - Record Repository → PostgreSQL + pgvector: writes records
database/repository.py - Workflow Stages → Record Repository: stores chunks
graph/nodes.py - Record Repository → PostgreSQL + pgvector: writes chunks
database/repository.py - Workflow Stages → Evidence Retrieval: searches chunks
graph/nodes.py - Evidence Retrieval → PostgreSQL + pgvector: queries vectors
database/retrieval.py - Flask REST API → Evidence Retrieval: reads obligations
backend/app.py - Flask REST API → Contract Review UI: serves results
README.md - Contract Pipeline → Text Ingestion: extracts text
pipeline/contract_pipeline.py - Contract Pipeline → Obligation Extraction: extracts obligations
pipeline/contract_pipeline.py - Contract Pipeline → Schema Validation: validates output
pipeline/contract_pipeline.py - Contract Pipeline → Evidence Retrieval: retrieves evidence
pipeline/contract_pipeline.py - Contract Pipeline → Source Verification: verifies evidence
pipeline/contract_pipeline.py - Contract Pipeline → Risk Analysis: evaluates risk
pipeline/contract_pipeline.py - Contract Pipeline → Record Repository: stores results
pipeline/contract_pipeline.py