OSS legal tooling integrations: matter typing, Dropbox layout, sale workflow, redline viewer

✅ merged · #2 · beautech-aero/legal-platform ← beautech-aero/legal-platform · opened 18d ago by igor-ctrl · merged 18d ago by igor-ctrl · self · +836-8 across 17 files · ↗ on GitHub

From the PR description

Context

Research-driven scaffolding inspired by the OSS legal-tech catalogs the user surfaced (opensource.legal, OpenContracts, Free Law Project) and the GC's clarifications on how the team actually thinks about matters and the canonical Dropbox folder convention.

Full research memo lives at `~/.claude/plans/i-came-across-htis-zany-deer.md` (local). Six-phase roadmap, four phases shipped here.

Summary

Phase Commit What
1 `fb6828c` Schema + UI for `matter_type`, `esn`, Dropbox subfolder stage on documents, executed-version flag
2 `8d82b6a` `parseDropboxLayout()` + Dropbox import handler tags docs and backfills counterparty/ESN
5 `c0d94bd` Sale Transaction Closing Tracker system workflow (encodes GC's 26-stage Mermaid)
4 `b6f13ee` `DocxRedlineView` using react-docxodus-viewer (move-detection on tracked changes)

Key decisions (matched against GC's input)

  • Don't rename `matter`. GC confirmed it's the right legal term. Transaction is a TYPE of matter (`matter_type` enum: lease | sale | amendment | nda | loi | kyc | side_letter | general_admin | other).
  • Canonical Dropbox layout is the contract between Dropbox and our DB: `Legal/{Counterparty}/{ESN}/{NN ...}/[NN Amend/]`. Parser is case-insensitive on folder names, returns nulls when a path doesn't match (sync should tolerate ad-hoc paths). `01 Executed Agreements` is the only stage that flags a version as executed.
  • Salesforce remains the system of record for deal-flow state. The Sale Transaction Closing Tracker is an LLM-generated read-only snapshot, not a state machine.
  • Phase 4 is viewer-only. Python-Redlines / .NET runtime is deferred - incoming amendments already carry tracked-change markers, so the immediate value is rendering them, not computing them.

What's NOT in this PR

  • Migration not applied to any DB. Apply with: `psql $DATABASE_URL -f backend/migrations/002_matter_type_and_canonical_layout.sql` (additive, idempotent).
  • DocxRedlineView is not wired into existing UI. Component is exported and ready; integration point is intentionally a follow-on (likely: trigger when `dropbox_subfolder_stage='03_amendments'`, or a viewer toggle on existing DocxView).
  • Phase 3 (document parser) is pending a decision. User asked about OpenDataLoader vs Firecrawl Parse instead of Free Law's Doctor - research notes below.
  • Phase 6 (annotation data model port from OpenContracts) deferred until clause-highlighting UI is scoped.

Phase 3 research (for the decision)

Tool License Local? OCR Pros Cons
OpenDataLoader PDF Apache-2.0 100% local Built-in (80+ langs) #1 in benchmarks; bounding boxes match our existing `[[page:N\ \
Firecrawl Parse Hosted SaaS No (API) Built-in (Fast/Auto/OCR modes) Drop-in API; 50MB max; many formats Vendor dependency; per-page cost; data egress
Doctor (Free Law) BSD-2 Self-hosted Built-in Mature, used by CourtListener Python+Tesseract container to maintain

Recommendation: OpenDataLoader - Apache-2.0 + local + npm-installable + benchmark-leading + bounding-box citations align with our existing tabular-review citation contract.

Test plan

  • Apply migration 002 to a non-prod DB; verify `projects.matter_type` defaults to `lease` for existing rows
  • Create a new matter via NewProjectModal with `matter_type=sale` and `esn=195622`; verify both persist
  • Toggle `matter_type` and view ESN in MatterCommandCenter
  • Run a Dropbox import on a path like `Legal/Delta/195622/03 Amendments/02 Amend/draft.docx` and confirm:
    • document.dropbox_subfolder_stage = `03_amendments`
    • document.dropbox_amendment_index = 2
    • matter counterparty/esn auto-populate (only if matter has them blank)
  • Run a Dropbox import where path = `Legal/Delta/195622/01 Executed Agreements/Lease - Signed.pdf`; confirm `document_versions.is_executed=true`
  • Run "Sale Transaction Closing Tracker" workflow on a sale matter with seeded docs; verify all 26 stages are surfaced with statuses inferred from the Dropbox layout
  • Mount `DocxRedlineView` on a test page with a known amendment DOCX; verify move-detection visualization

Our analysis

Scaffold OSS legal-tech integrations around matter typing and Dropbox layout — read the full analysis →

Think the analysis missed something the PR description covers?

Capture this PR into my fork

Download a Markdown prompt that tells Claude how to port every commit in this PR into your working tree. Run it via claude -p < capture-pull-2.md from inside the repo you want the changes in.

⬇ Download capture-pull-2.md