How jsv4/opencontracts works
This project is a full‐stack enterprise document analytics platform built around analyzing, annotating, and extracting data from documents (primarily PDFs and text formats). It uses a Django/Python backend that is integrated with a highly modular, pluggable document processing pipeline (parsers, embedders, thumbnailers) and a React/TypeScript frontend. There are several supporting components such as Docker configuration for local and production deployments, CI/CD pipelines, and integrations with vector databases (pgvector), GraphQL, and LlamaIndex for data extraction.
Main Components
• Frontend Application – Built with React (located under the “frontend” directory). This component includes pages and UI widgets for document management, annotation, data grid displays, and querying.
• Backend API and Web Application – Mainly built with Django (see “opencontractserver”, “config” directories, and “manage.py”). It handles business logic, authentication, document and annotation storage, and rendering of GraphQL endpoints.
• Document Processing Pipelines – A modular pipeline system (documented in the “docs/pipelines” folder) including custom parsers (e.g., Docling, NLM-Ingest), embedders, and thumbnail generators. These components are key for extracting text, generating vector embeddings, and creating document previews.
• Celery Services – Background workers for asynchronous tasks related to document parsing, analysis, and data extraction. These can be shown as separate worker components in the backend.
• Database Layer – Postgres is used along with pgvector for handling both structured metadata and vector embeddings. The project contains SQL initialization and maintenance scripts (see “compose/production/postgres”).
• Reverse Proxy and Deployment Components – Docker Compose configurations for local and production setup including reverse proxy setup (via Traefik) and various container orchestration files.
• External Integrations – LlamaIndex integration for enhanced vector search and data extraction workflows, as well as integration with external analyzers and annotation interfaces.
Relationships and Interactions
• The Frontend communicates with the Backend via REST APIs and GraphQL endpoints.
• The Backend processes incoming document uploads, kicks off Celery tasks for document processing (parsing, embedding, thumbnailing), and stores results in the Postgres database.
• The Document Processing Pipeline is triggered from the Backend and can be extended via a plug-in architecture.
• The system supports real-time notifications and websockets (see “config/websocket”) to keep the frontend updated with document annotation or analysis statuses.
• External services (e.g., LlamaIndex, authentication providers such as Auth0) are integrated via API calls and middleware.
Architectural Patterns and Technologies
• MVC/MVT Pattern – The Django application adheres to the Model-View-Template pattern.
• Microservices/Plugin Architecture – The pluggable document processing pipelines allow for easy extension of parsers, embedders, and thumbnail generators.
• Asynchronous Task Processing – Celery-based background processing of heavy tasks ensures responsiveness.
• Containerized Deployment – Docker Compose configuration for both production and local environments, including separate services for Django, Celery, Postgres, and Traefik.
• Modern Frontend Architecture – The React application with TypeScript, state management (using context and hooks), and integration with GraphQL.
Details
• Clear dependency paths and add notes regarding the pluggable architecture design for custom pipelines.