How jatin-05/lexgraph works
This is a research-oriented contract intelligence API. Its principal workflow accepts a contract, converts it into cached chunks with document structure and provenance, extracts parties and contractual facts per chunk, validates those facts deterministically, and assembles a contract representation. The API also exposes legacy PDF parsing/section-building debug routes and a Docling inspection route. The README describes reference resolution and structure-aware retrieval/question answering as future work; those are shown as planned, not established runtime stages. Relationships are limited to calls shown in excerpts or flows explicitly documented in the README.
Main entry points: pipeline.py Processing pipeline · main.py FastAPI routes · extractor.py Semantic extractor · document_parser.py PDF parser
Components 21
API and configuration
- FastAPI routes
apps/api/app/main.py - App settings
apps/api/app/config.py - Supabase client
apps/api/app/db/supabase.py
Document ingestion
- Docling conversion
apps/api/app/services/document/converter.py - PDF parser
apps/api/app/services/parsing/document_parser.py - Legacy section builder
apps/api/app/services/structure/clause_segmenter.py
Contract intelligence
- Processing pipeline
apps/api/app/services/processing/pipeline.py - Structure builder
apps/api/app/services/structure/builder.py - Semantic extractor
apps/api/app/services/extraction/extractor.py - Semantic validator
apps/api/app/services/validation/semantic_validator.py
Models and representation
- Canonical document models
apps/api/app/models/document.py - Structure models
apps/api/app/services/structure/models.py - Extraction models
apps/api/app/services/extraction/models.py - Validation models
apps/api/app/services/validation/models.py - Processing models
apps/api/app/services/processing/models.py - Contract schema
apps/api/app/services/contract/schema.py
Planned capabilities
- Reference resolver
apps/api/app/services/reationships/resolver.py - Structure-aware retrieval
- Evidence-backed Q&A
Other components
- Contract user
- Local Ollama model
Connections 22
- Contract user → FastAPI routes: uploads contract
apps/api/app/main.py - FastAPI routes → Processing pipeline: processes contract
apps/api/app/main.py - FastAPI routes → PDF parser: parses PDF
apps/api/app/main.py - FastAPI routes → Legacy section builder: builds sections
apps/api/app/main.py - FastAPI routes → Docling conversion: inspects conversion
apps/api/app/main.py - FastAPI routes → App settings: loads settings
apps/api/app/main.py - FastAPI routes → Supabase client: checks client
apps/api/app/main.py - PDF parser → Canonical document models: returns document
apps/api/app/services/parsing/document_parser.py - Legacy section builder → Canonical document models: reads pages
apps/api/app/services/structure/clause_segmenter.py - Processing pipeline → Docling conversion: converts and chunks
README.md - Processing pipeline → Structure builder: builds structure
apps/api/app/services/processing/pipeline.py - Processing pipeline → Semantic extractor: extracts chunk facts
apps/api/app/services/processing/pipeline.py - Semantic extractor → App settings: loads model settings
apps/api/app/services/extraction/extractor.py - Semantic extractor → Local Ollama model: requests extraction
README.md - Processing pipeline → Semantic validator: validates extraction
apps/api/app/services/processing/pipeline.py - Semantic validator → Extraction models: checks extracted facts
apps/api/app/services/validation/semantic_validator.py - Structure builder → Structure models: builds structure data
apps/api/app/services/structure/builder.py - Processing pipeline → Processing models: assembles representation
apps/api/app/services/processing/pipeline.py - Processing pipeline → Contract schema: returns contract schema
- Processing pipeline → Validation models: returns validation report
apps/api/app/services/processing/pipeline.py - Reference resolver → Structure-aware retrieval: enables resolution-aware retrieval
README.md - Structure-aware retrieval → Evidence-backed Q&A: supports evidence-backed answers
README.md