A Python contract-review tool with an interactive dashboard.
It reads contract PDFs, sends the extracted text to Claude, scores each contract for business risk, flags risky clauses, and saves the output to JSON and CSV.
Then the dashboard turns those results into a clear executive view.
Know the risk before you sign.
- Reads every PDF inside the
contracts/folder. - Extracts contract text with
pdfplumber. - Sends each contract to the Claude API for structured risk analysis.
- Produces detailed results in
results.json. - Produces a spreadsheet summary in
results.csv. - Shows the results in a single-page dashboard:
index.html. - Keeps API keys private through
.envand.gitignore.
The dashboard is built as one self-contained HTML file:
index.html
It loads:
results.csvfor the contract register and KPI counts.results.jsonfor detailed summaries, red flags, and clause-level findings.
Dashboard views include:
- Executive summary
- Risk distribution
- Priority contracts
- Recurring risk areas
- Full contract register
- Contract detail drawer
Risk tiers are standardized and transparent:
Low 0-39
Medium 40-69
High 70-100
The dashboard also derives the displayed tier from the score, so the visual counts stay consistent with the data.
The risk score comes from Claude's contract analysis.
The final risk tier is controlled by Python.
This means the model does not decide the final tier label. The script applies fixed thresholds after the score is returned:
Low = 0-39
Medium = 40-69
High = 70-100This keeps results.json, results.csv, and the dashboard aligned.
Current reconciled sample counts:
| Tier | Count |
|---|---|
| Low | 7 |
| Medium | 11 |
| High | 7 |
| Total | 25 |
| File | Purpose |
|---|---|
analyze_contracts.py |
Main Python script that extracts text, calls Claude, applies risk-tier thresholds, and writes outputs |
index.html |
Interactive dashboard for reviewing the results |
results.json |
Full detailed analysis for each contract |
results.csv |
Flattened spreadsheet summary |
requirements.txt |
Python dependencies |
.env.example |
Shows the required API key format |
.gitignore |
Keeps .env, virtual environments, and cache files out of Git |
contracts/ |
Folder for PDF contracts |
You need:
- Python 3
- An Anthropic API key
- Contract PDFs
Install the Python packages:
pip3 install -r requirements.txtCreate a file named .env in the project folder:
ANTHROPIC_API_KEY=your_key_here
Replace your_key_here with your real Anthropic key.
Do not commit .env.
It is already ignored by Git.
Place PDF contracts in:
contracts/
Then run:
python3 analyze_contracts.pyThe script will create or update:
results.json
results.csv
Because the dashboard loads local CSV and JSON files, open it through a local server.
From the project folder:
python3 -m http.server 8011Then open:
http://localhost:8011/index.html
Do not double-click index.html.
Most browsers block local file loading from file://.
- The real API key belongs only in
.env. .envis ignored by Git..env.exampleshows the format without exposing secrets.- Sample contracts are fictional and used for testing.
This project includes:
- A working Python analyzer
- Standardized risk-tier logic
- Reconciled JSON and CSV outputs
- A polished single-page dashboard
- 25 sample contracts for testing
Built by Acey Magallanes as a practical AI automation portfolio project.