Enterprise-grade Contract Comparison, Redlining & Legal Intelligence Platform.
- Clause-level semantic comparison (similarity + entailment/contradiction labels)
- Legal risk detection (structured findings + buyer/seller bias + rationale)
- DOCX redlining with tracked changes + in-document anchors (Word comments)
- Production-ready architecture (API / Vector DB / LLM Routing / Agents / Workers)
- Tenant isolation (DB + object store + vector filters)
- Observability (structured logs, OpenTelemetry hooks) + Audit events
- Modular model routing + per-tenant cost control + deterministic fallbacks
cp .env.example .env
cp apps/api/.env.example apps/api/.env
cp apps/web/.env.example apps/web/.envSet in apps/api/.env:
OPENAI_API_KEY=...(optional; platform will fallback where possible)APP_ENV=devTENANT_DAILY_COST_BUDGET_USD=10
docker compose up --build- UI: http://localhost:3000
- API docs: http://localhost:8000/docs
The Next.js UI uses route-groups to separate the public website and the product UI:
- Public website:
apps/web/app/(marketing)—/,/pricing,/security,/docs - Product UI:
apps/web/app/(app)— dashboard, uploads, compare runs, findings, redlining, billing, audit
This keeps the product navigation shell consistent while allowing a clean, marketing-oriented landing site.
- In UI → Upload
- Choose a contract (DOCX recommended for redlining; PDF supported with OCR)
- Wait for ingestion (worker extracts text, chunks, clauses, embeddings)
You now have:
- Original file in object storage
- Extracted clauses in DB
- Vector index in Qdrant
- UI → Compare
- Select Old and New versions
- Review:
- similarity scores
- entailment/contradiction labels (NLI)
- change summaries per clause_type
API:
POST /v1/contracts/compare
- UI → Contract → Runs
- Trigger or review the latest agent run
- Output is explainable:
- risk level
- buyer/seller bias
- findings + rationales
Backend:
- Supervisor plans and budgets the run
- Risk agent produces structured findings
- Negotiation agent is optional (advice only)
- UI → Redline
- Select old/new DOCX contracts
- Download:
- Redlined DOCX (Word Track Changes)
- Clause Report JSON (audit-friendly)
Redlined DOCX includes Word comments as anchors:
- a summary comment
- per-changed clause_type comments with stable clause IDs
API:
POST /v1/redline/docx
- UI → Contract → Ask
- Ask: “What is the termination notice period?”
- Get:
- answer (grounded)
- evidence snippets (explainable)
API:
POST /v1/qa/ask
See:
docs/ENTERPRISE_DEPLOYMENT.mddocs/MODEL_STRATEGY.md
Key properties:
- OIDC/JWKS authentication
- tenant isolation end-to-end
- tiered model routing (tier1/tier2/tier3) + per-tenant daily budgets
- multi-agent workflows are declarative YAML under
configs/workflows/
model_tier1andmodel_tier2are configurable inapps/api/cip/settings.py- Daily tenant budget (USD):
tenant_daily_cost_budget_usd - When budget is exceeded:
- LLM calls are blocked
- agents switch to deterministic/local fallbacks
- outputs include warnings
apps/api: FastAPI + ingestion + agents + RAG + redliningapps/web: Next.js UIconfigs/workflows: declarative multi-agent workflowsdocs: architecture, security, enterprise deployment, model strategyinfra/helm: Kubernetes templates (approved version)
- Tenant isolation: DB + MinIO keys + Qdrant filters
- Audit trail: append-only
events - Observability: structured logs + OpenTelemetry hooks
- Prompt registry: versioned prompts with stage mapping
This project uses the Business Source License 1.1 (BSL 1.1).
- Change Date: 2029-10-01
- Change License: Apache License, Version 2.0
- Additional Use Grant: You may not use the Licensed Work to provide a commercial hosted or managed service to third parties.
See LICENSE for the full text.
Author: Fan Luo