How rishi-is-cool/leaselens-india works
LeaseLens accepts lease files and currently returns extracted, segmented clauses; the sampled frontend identifies itself as a Phase 1 segmentation check. The backend also contains a document-explanation pipeline for risk labels, jurisdiction/topic-scoped statute retrieval, grounded explanations, and cross-clause connections. The README describes Postgres-backed document and statute storage. The graph follows calls visible in sampled source and documented capabilities; unsampled frontend API wiring and analysis internals are represented only where their paths and responsibilities are supported.
Main entry points: documents.py Document endpoints · pipeline.py Explanation orchestration · App.tsx Upload and results UI · api.py Risk classification
Components 22
LeaseLens frontend
- Upload and results UI
frontend/src/App.tsx - Frontend API client
frontend/src/api.ts
API and ingestion
- API application
backend/app/main.py - Document endpoints
backend/app/routers/documents.py - Text extraction
backend/app/ingestion/extract.py - Clause segmentation
backend/app/ingestion/segment.py - Upload retention
backend/app/retention.py
Clause analysis
- Explanation orchestration
backend/app/explain/pipeline.py - Risk classification
backend/app/classifier/api.py - Trained fallback
backend/app/classifier/trained.py - LLM classifier
backend/app/classifier/llm.py - Topic tagging
backend/app/explain/topics.py - Statute retrieval
backend/app/statute_kb/retrieval.py - Explanation generation
backend/app/explain/generate.py - Citation grounding
backend/app/explain/grounding.py - Cross-clause analysis
backend/app/explain/cross_clause.py - Shared LLM client
backend/app/llm_client.py
Persistence and providers
- Database access
backend/app/db.py - Document and clause models
backend/app/models.py - Postgres
Other components
- Lease uploader
- LLM provider
Connections 23
- Lease uploader → Upload and results UI: uploads lease
- Upload and results UI → Frontend API client: sends file
- Frontend API client → Document endpoints: calls upload API
- API application → Document endpoints: registers routes
- Document endpoints → Upload retention: purges expired
- Document endpoints → Text extraction: extracts text
- Document endpoints → Clause segmentation: segments paragraphs
- Document endpoints → Database access: opens session
- Document endpoints → Document and clause models: creates records
- Database access → Postgres: reads and writes
- Upload and results UI → Frontend API client: checks health
- Explanation orchestration → Risk classification: classifies clauses
- Explanation orchestration → Topic tagging: tags topics
- Explanation orchestration → Statute retrieval: retrieves statutes
- Explanation orchestration → Explanation generation: generates explanations
- Explanation orchestration → Citation grounding: checks grounding
- Explanation orchestration → Cross-clause analysis: checks clause pairs
- Risk classification → Trained fallback: uses fallback
- Risk classification → LLM classifier: uses LLM
- Explanation generation → Shared LLM client: requests completion
- Cross-clause analysis → Shared LLM client: requests completion
- Shared LLM client → LLM provider: sends chat request
- LLM classifier → LLM provider: sends chat request