How adimyth/ai-contract-review works
Contract Review AI lets a user upload a PDF/DOCX or choose a bundled sample, then streams a playbook-based legal pre-screening to the browser. The backend validates and extracts document text, runs structured AI extraction followed by clause analysis, and returns verdicts, clause findings, and auto-approved clauses over SSE. Users can also inspect the playbook and browse samples. The graph separates the two pipeline stages although both live in one module; unsampled implementation details are represented only where the README documents them.
Main entry points: main.py API routes · pipeline.py Contract extraction · app.js Review interface · playbook.py Legal positions
Components 14
Browser experience
- Review interface
frontend/app.js - Sample contracts
mock_contracts - Streaming results
frontend/app.js - Playbook display
frontend/app.js - Sample browser
frontend/app.js
Review backend
- API routes
backend/main.py - Document text parser
backend/parser.py
Contract analysis
- Contract extraction
backend/pipeline.py - Playbook analysis
backend/pipeline.py - Review data models
backend/models.py - Legal positions
backend/playbook.py
Other components
- Reviewer
- Anthropic API
- OpenAI API
Connections 19
- Reviewer → Review interface: uploads or selects
README.md - Review interface → API routes: submits review
frontend/app.js - API routes → Document text parser: extracts text
backend/main.py - API routes → Contract extraction: starts review
backend/main.py - Contract extraction → Playbook analysis: passes clauses
README.md - Contract extraction → Review data models: returns extraction
backend/pipeline.py - Playbook analysis → Legal positions: reads positions
backend/pipeline.py - Contract extraction → Anthropic API: calls when selected
backend/pipeline.py - Contract extraction → OpenAI API: calls when selected
backend/pipeline.py - Playbook analysis → Anthropic API: streams when selected
backend/pipeline.py - Playbook analysis → OpenAI API: streams when selected
backend/pipeline.py - Playbook analysis → Streaming results: streams findings
README.md - Streaming results → Review interface: renders review
frontend/app.js - Review interface → Sample browser: loads samples
frontend/app.js - Sample browser → API routes: requests sample list
README.md - API routes → Sample contracts: serves selected file
README.md - Review interface → Playbook display: loads rules
frontend/app.js - Playbook display → API routes: requests playbook
README.md - API routes → Legal positions: returns positions
backend/main.py