How karankarpe22/terms-of-service-red-flag-scanner works
This is a web-based ToS scanner: users submit PDF or pasted text, then receive segmented and categorized clauses, attention flags, cross-clause relationships, and grounded explanations or document Q&A. The API routes orchestrate ingestion and analysis; the browser presents results. Retrieval supports concern-focused queries, and Gemini can provide explanations, with deterministic mock mode also documented. Edges follow the route imports listed in the SOURCE INDEX and explicit README capabilities; unsampled implementation details are not inferred.
Main entry points: routes.py API routes · client.py Explanation and Q&A · embedder.py Text embeddings · app.js Web interface
Components 15
User interface
- Web interface
frontend/app.js - API routes
backend/api/routes.py
Document ingestion
- Document extraction
backend/document/extractor.py - Text cleaning
backend/document/cleaner.py - Clause segmentation
backend/document/segmenter.py - Document registry
backend/document/store.py
Clause analysis
- Clause classification
backend/analysis/classifier.py - Attention levels
backend/analysis/attention.py - Clause relationships
backend/analysis/relationships.py
Retrieval and explanations
- Text embeddings
backend/retrieval/embedder.py - Clause retrieval
backend/retrieval/vector_store.py - Explanation and Q&A
backend/llm/client.py - Evidence validator
backend/llm/validator.py
Other components
- User
- Google Gemini
Connections 16
- User → Web interface: submits document
README.md - Web interface → API routes: uses API
README.md - API routes → Document extraction: extracts text
backend/api/routes.py - Document extraction → Text cleaning: normalizes text
backend/document/extractor.py - API routes → Clause segmentation: segments clauses
backend/api/routes.py - API routes → Document registry: stores document
backend/api/routes.py - API routes → Clause classification: classifies clauses
backend/api/routes.py - API routes → Attention levels: assigns attention
backend/api/routes.py - API routes → Clause relationships: detects relationships
backend/api/routes.py - API routes → Clause retrieval: indexes and retrieves
backend/api/routes.py - Clause classification → Text embeddings: embeds categories
backend/analysis/classifier.py - Clause relationships → Text embeddings: compares semantics
backend/analysis/relationships.py - Clause retrieval → Text embeddings: embeds queries
backend/retrieval/vector_store.py - API routes → Explanation and Q&A: requests explanations
backend/api/routes.py - Explanation and Q&A → Evidence validator: validates evidence
backend/llm/client.py - Explanation and Q&A → Google Gemini: generates responses
README.md