How vikasprajapati-01/plagiarism_check_tool works
Purpose and Entry Points
This is a dataset-quality system for Excel/CSV files: it identifies duplicate, semantically similar, AI-generated, web-plagiarized, and license-restricted content, then produces JSON and Excel outputs. The backend FastAPI application starts at backend/app/main.py; versioned REST routes are assembled in backend/app/api/v1/router.py. The primary user interface is the Next.js analyzer at frontend/app/analyze/page.tsx.
API and Client Boundary
The frontend uploads files and selected detection methods to the Python API, using NEXT_PUBLIC_API_BASE. It can first request column discovery, then run the unified pipeline, preview its result, and request downloadable reports/cleaned workbooks. Primary API surfaces are:
• backend/app/api/v1/pipeline.py — column discovery and pipeline execution.
• backend/app/api/v1/reports.py — combined and cleaned Excel exports.
• backend/app/api/v1/compare.py — standalone cross-workbook comparison/export.
Ingestion and Provenance
The preprocessing stage reads CSV/XLSX files, selects a requested or auto-detected target column, normalizes content, and emits per-cell entries retaining file, sheet, row, and column provenance. That traceability is the boundary between raw workbooks and detector services, and enables later row deletion/report highlighting.
• backend/app/services/preprocessor.py
• backend/app/core/models.py
Unified Detection Orchestration
pipeline_runner coordinates only the methods requested by the API, executes detectors in memory, aggregates findings into a PipelineRunResult, and separates row/cell duplicate findings from web/AI findings. Cross-file comparison is conditional on XLSX inputs.
• backend/app/services/pipeline_runner.py
• backend/app/api/v1/pipeline.py
• backend/app/services/cross_compare.py
Similarity Detection Stages
Duplicate detection is layered: SHA-256 catches identical content; fuzzy matching evaluates lexical near-matches; semantic matching embeds text and compares cosine similarity. Thresholds and model names are environment-backed application settings rather than frontend-controlled implementation details.
• backend/app/services/exact_match.py
• backend/app/services/fuzzy_match.py
• backend/app/services/semantic_match.py
• backend/app/core/config.py
ML, Web, and Compliance Boundaries
Semantic matching uses SBERT and AI scoring uses GPT-2 perplexity. Both models are loaded once through a startup-oriented singleton cache, avoiding repeated model initialization per request. Web scanning is an external-network boundary: DuckDuckGo discovers candidate sources, then HTTP/BeautifulSoup retrieves and compares page text under timeout/retry limits. License analysis recognizes SPDX/copyright signals.
• backend/app/core/model_cache.py
• backend/app/services/ai_detector.py
• backend/app/services/web_scanner.py
• backend/app/services/license_detector.py
Reporting and Remediation
Report endpoints convert pipeline results into a three-sheet, optionally color-coded Excel workbook. The cleaned-workbook flow receives original XLSX uploads plus result JSON, removes flagged duplicate/plagiarized rows while preserving headers, and returns one workbook or a ZIP for multiple files. This is a post-processing boundary: original files are needed again because pipeline results are structured findings, not persisted workbook mutations.
• backend/app/api/v1/reports.py
• frontend/app/components/PreviewPanel.tsx
Runtime and Infrastructure
Backend runtime is Python/FastAPI with pandas/openpyxl for workbook I/O, sentence-transformers/transformers for local ML inference, and DuckDuckGo plus remote HTTP sites for web checks. Frontend runtime is Next.js 16/React 19 TypeScript using the App Router. Models may be pre-fetched with backend/scripts/download_models.py; no database, queue, or cloud deployment infrastructure is represented in this repository.
Main entry points: pipeline_runner.py Pipeline runner · router.py v1 route assembly · pipeline.py Pipeline API · reports.py Reports API
Components 20
Next.js client
- Analyzer UI · Uploads workbooks, selects methods, and requests results.
frontend/app/analyze/page.tsx - Results preview · Previews findings and initiates report downloads.
frontend/app/components/PreviewPanel.tsx
FastAPI API
- FastAPI app
backend/app/main.py - v1 route assembly
backend/app/api/v1/router.py - Pipeline API · Discovers columns and runs requested detection methods.
backend/app/api/v1/pipeline.py - Reports API · Exports result reports and cleaned workbooks.
backend/app/api/v1/reports.py - Comparison API · Runs standalone cross-workbook comparison and export.
backend/app/api/v1/compare.py
Detection pipeline
- Workbook preprocessing · Reads CSV/XLSX, selects a column, normalizes cells, and preserves provenance.
backend/app/services/preprocessor.py - Provenance models · Defines per-cell entries and pipeline result structures.
backend/app/core/models.py - Pipeline runner · Executes requested detectors in memory and aggregates findings.
backend/app/services/pipeline_runner.py - Exact matching
backend/app/services/exact_match.py - Fuzzy matching
backend/app/services/fuzzy_match.py - Semantic matching
backend/app/services/semantic_match.py - Cross-workbook comparison · Runs conditionally for XLSX inputs.
backend/app/services/cross_compare.py - AI content scoring
backend/app/services/ai_detector.py - Web plagiarism scan · Searches candidate sources and compares retrieved page text.
backend/app/services/web_scanner.py - License analysis · Recognizes SPDX and copyright signals.
backend/app/services/license_detector.py - Model cache · Loads SBERT and GPT-2 once per backend runtime.
backend/app/core/model_cache.py - Detection settings · Supplies environment-backed thresholds and model names.
backend/app/core/config.py
External services
- Search and web sources · DuckDuckGo and remote HTTP pages.
Connections 25
- Analyzer UI → Pipeline API: uploads files and methods
- Analyzer UI → Reports API: requests exports
- Analyzer UI → Comparison API: requests comparison
- Pipeline API → Pipeline runner: runs pipeline
- Pipeline API → Workbook preprocessing: discovers columns
- Pipeline runner → Workbook preprocessing: ingests cells
- Workbook preprocessing → Provenance models: emits provenance entries
- Pipeline runner → Exact matching: requested method
- Pipeline runner → Fuzzy matching: requested method
- Pipeline runner → Semantic matching: requested method
- Pipeline runner → AI content scoring: requested method
- Pipeline runner → Web plagiarism scan: requested method
- Pipeline runner → License analysis: requested method
- Pipeline runner → Cross-workbook comparison: XLSX only
- Semantic matching → Model cache: uses SBERT
- AI content scoring → Model cache: uses GPT-2
- Detection settings → Fuzzy matching: thresholds
- Detection settings → Semantic matching: thresholds and model
- Web plagiarism scan → Search and web sources: searches and fetches
- Reports API → Provenance models: reads result JSON
- Reports API → Results preview: returns workbooks
- FastAPI app → v1 route assembly: mounts
- v1 route assembly → Pipeline API: registers
- v1 route assembly → Reports API: registers
- v1 route assembly → Comparison API: registers