MCPcopy Index your code
hub / github.com/Open-Source-Legal/OpenContracts

github.com/Open-Source-Legal/OpenContracts @v3.0.0.b4

Chat with this repo
repository ↗ · DeepWiki ↗ · release v3.0.0.b4 ↗ · + Follow
11,966 symbols 44,365 edges 1,493 files 6,675 documented · 56% updated todayv3.0.0.b4 · 2026-02-08★ 1,3888 open issues
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

OpenContracts

OpenContracts (Demo)

Open source document intelligence. Self-hosted, AI-powered, and built for teams who need to own their data.

Sponsor


Backend CI/CD codecov
Meta code style - black types - Mypy imports - isort License - AGPL-3.0

What is OpenContracts?

OpenContracts is an AGPL-3.0 licensed platform for document analysis, annotation, and collaboration. It combines document management with AI-powered analysis tools, discussion threads, and structured data extraction.

Core Capabilities

  • Document Processing — Upload PDFs and text files, automatically extract structure with ML-based parsers
  • Annotation & Analysis — Highlight, label, and analyze documents with custom annotation schemas
  • AI Agents — Chat with documents using configurable AI assistants that can search and analyze content
  • Collaboration — Threaded discussions with @mentions, voting, and moderation at corpus and document levels
  • Data Extraction — Extract structured data from hundreds of documents using agent-powered queries
  • Version Control — Track document changes, restore previous versions, soft delete with recovery

Quick Look

Document Annotation

PDF Processing

Text Format Support

Txt Processing

Structured Data Extraction

Data Grid

Custom Analytics

Analyzer Annotations


Features

Document Management

  • Organize documents into collections (Corpuses) with folder hierarchies
  • Fine-grained permissions with public/private visibility controls
  • Document versioning with full history and restore capability
  • Bulk upload and batch operations

Parsing & Processing

  • Pluggable parser architecture supporting multiple backends:
  • Docling — ML-based structure extraction (default)
  • LlamaParse — Cloud-based parsing with layout extraction
  • Text/Markdown — Simple text extraction
  • Automatic vector embeddings for semantic search (powered by pgvector)
  • Structural annotation extraction (headers, paragraphs, tables)

Annotation Tools

  • Multi-page annotation support
  • Custom label schemas with validation
  • Relationship mapping between annotations
  • Import/export in standard formats

AI & LLM Integration

  • Built on PydanticAI for structured LLM interactions
  • Configurable AI agents with tool access (search, document loading, annotation queries)
  • Real-time streaming responses via WebSocket
  • Conversation history with context management

Collaboration (New in v3.0.0.b3)

  • Threaded discussions at global, corpus, and document levels
  • @mentions for documents, corpuses, and AI agents
  • Upvoting/downvoting with reputation tracking
  • Thread pinning, locking, and moderation controls
  • User profiles with activity feeds and statistics
  • Badges and achievements for community engagement
  • Leaderboards showing top contributors

Data Extraction

  • Define extraction schemas with multiple question types
  • Run extractions across document collections
  • Review and validate extracted data in grid view
  • Export results in structured formats

Documentation

Browse the full documentation at jsv4.github.io/OpenContracts or in the repo:

Guide Description
Quick Start Get running with Docker in minutes
Key Concepts Core workflows and terminology
PDF Data Format How text maps to PDF coordinates
LLM Framework PydanticAI integration and agents
Vector Stores Semantic search architecture
Pipeline Overview Parser and embedder system
Custom Extractors Build your own data extraction tasks
v3.0.0.b3 Release Notes Latest features and migration guide

Architecture

Data Format

OpenContracts uses a standardized format for representing text and layout on PDF pages, enabling portable annotations across tools:

Data Format

Processing Pipeline

The modular pipeline supports custom parsers, embedders, and thumbnail generators:

Pipeline Diagram

Each component inherits from a base class with a defined interface: - Parsers — Extract text and structure from documents - Embedders — Generate vector embeddings for search - Thumbnailers — Create document previews

See the pipeline documentation for details on creating custom components.


Deployment

Quick Start (Development)

git clone https://github.com/JSv4/OpenContracts.git
cd OpenContracts
docker compose -f local.yml up

Production

Run migrations before starting services:

# Apply database migrations
docker compose -f production.yml --profile migrate up migrate

# Start services
docker compose -f production.yml up -d

The migration service runs once to avoid race conditions and ensures all tables are created before dependent services start.


Telemetry

OpenContracts collects anonymous usage data to guide development priorities. We collect: - Installation events (unique installation ID) - Feature usage statistics (analyzer runs, extracts created) - Aggregate counts (documents, users, queries)

We do not collect document contents, extracted data, user identities, or query contents.

Disabling Telemetry

Backend telemetry (server-side events): Set TELEMETRY_ENABLED=False in your Django settings.

Frontend analytics (browser-side tracking via PostHog): Leave REACT_APP_POSTHOG_API_KEY unset or empty in frontend/public/env-config.js. The frontend also respects the browser's Do Not Track setting and requires explicit user consent before any tracking occurs.


Supported Formats

Currently supported: - PDF (full layout and annotation support) - Text-based formats (plaintext, Markdown)

Coming soon: DOCX viewing and annotation powered by Docxodus, an open source in-browser Word document viewer. This will enable the same annotation and analysis workflows for Word documents that currently exist for PDFs.


Acknowledgements

This project builds on work from:

The data extraction grid UI draws inspiration from NLMatics' innovative approach to document querying:

NLMatics Grid


License

AGPL-3.0 — See LICENSE for details.

Extension points exported contracts — how you extend this code

CreateAndSearchBarProps (Interface)
* Props for the CreateAndSearchBar component.
frontend/src/components/layout/CreateAndSearchBar.tsx
MockFolderOptions (Interface)
* Mock folder data factory for testing
frontend/tests/folders/utils/mockFolderData.ts
Env (Interface)
(no doc)
cloudflare-og-worker/src/types.ts
Window (Interface)
(no doc)
frontend/playwright/index.tsx
NavMenuUserProps (Interface)
* User display properties accessed by NavMenu. * Covers both Auth0 User (name) and local UserType (username).
frontend/src/components/layout/NavMenu.tsx
BreadcrumbFixtureProps (Interface)
* Test fixtures for folder components * These are separate components that can be imported and mounted in tests
frontend/tests/folders/utils/testFixtures.tsx
ParsedRoute (Interface)
(no doc)
cloudflare-og-worker/src/types.ts
AnalysisTraySelectorProps (Interface)
* Props for AnalysisTraySelector
frontend/src/components/analyses/AnalysisTraySelector.tsx

Core symbols most depended-on inside this repo

create
called by 3110
opencontractserver/llms/api.py
get
called by 1695
opencontractserver/mcp/server.py
info
called by 1292
frontend/src/utils/routingLogger.ts
error
called by 877
frontend/src/utils/routingLogger.ts
set_permissions_for_obj_to_user
called by 697
opencontractserver/utils/permissioning.py
debug
called by 539
frontend/src/utils/routingLogger.ts
save
called by 517
opencontractserver/users/models.py
get
called by 444
config/admin_auth/views.py

Shape

Method 6,009
Function 2,402
Class 2,111
Interface 1,038
Route 391
Enum 15

Languages

Python76%
TypeScript24%

Modules by API surface

opencontractserver/mcp/tests/test_mcp.py264 symbols
config/graphql/graphene_types.py243 symbols
config/graphql/mutations.py240 symbols
frontend/src/graphql/mutations.ts197 symbols
opencontractserver/tests/test_llm_tools.py163 symbols
frontend/src/graphql/queries.ts152 symbols
opencontractserver/tests/test_document_folder_service.py135 symbols
config/graphql/queries.py122 symbols
opencontractserver/tests/test_conversation_search.py111 symbols
opencontractserver/tests/test_multimodal_embedder_unit.py98 symbols
opencontractserver/tests/test_pipeline_settings.py92 symbols
opencontractserver/tests/test_admin_auth.py90 symbols

Datastores touched

opencontractsDatabase · 1 repos

For agents

$ claude mcp add OpenContracts \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact