How advaitkj123/plagiarism_project_iai works
Purpose and entry points
This is a local full-stack plagiarism-analysis tool for comparing submitted technical text against a small indexed library of .txt and .pdf documents. The Python service starts from backend/app.py (also supported by run_server.bat); the browser dashboard starts through Vite at frontend/src/main.jsx, rendering frontend/src/App.jsx.
Client dashboard
The React application provides the user workflow: submit or select manuscript content, manage library documents, invoke analysis, display sentence-level attribution and aggregate metrics, and print/export results. The UI is concentrated in:
• frontend/src/main.jsx
• frontend/src/App.jsx
• frontend/src/App.css
It communicates with the Flask API rather than performing similarity analysis locally.
HTTP/API boundary
Flask routes in backend/app.py form the application boundary between the browser and the analysis engine. This layer handles request parsing, CORS-enabled frontend access, file-oriented CRUD operations, and serializes analysis/report results. It also owns filesystem-facing interactions with the local corpus under data/.
Analysis engine
backend/engine.py is the core decision component. It extracts text from PDF or plain-text corpus entries, applies math/LaTeX-aware regular-expression cleanup, tokenizes content into sentences, and compares candidate sentences to library content using TF-IDF vectors and cosine similarity:
• backend/engine.py
• backend/utils.py
The output drives both per-sentence flags/source attribution and summary signals such as similarity averages and counts.
Corpus and document boundary
data/ is the persistent, filesystem-backed research library; it is not a database or remote search service. Mixed source formats are supported, with PDFs requiring PyMuPDF extraction and text files read directly:
• data/Assignment.pdf
• data/ieee_notes.txt
• data/test1.txt
Uploads/additions and deletions pass through the API before becoming part of the corpus used by later analysis.
Primary flow
1. React collects submitted text or a file and requests analysis through Flask.
2. Flask delegates document loading and comparison to the engine.
3. The engine normalizes mathematical notation, sentence-splits the submission, builds/uses TF-IDF similarity comparisons against corpus text, and identifies threshold-exceeding overlaps.
4. Flask returns structured flags, source references, and aggregate metrics.
5. React renders results and relies on print CSS for browser-based PDF report export.
Runtime and dependencies
The backend runs on Python 3.11 with Flask, Flask-CORS, scikit-learn, NLTK, and PyMuPDF; dependency intent is represented by requirements.txt. The frontend runs on Node.js with React 18 and Vite, defined by frontend/package.json. There are no indicated cloud services, databases, authentication providers, or asynchronous job infrastructure; analysis is synchronous and local.
Main entry points: app.py Flask API · engine.py Similarity engine · App.jsx Analysis dashboard · requirements.txt Backend dependencies
Components 14
Browser dashboard
- Vite client runtime
frontend/package.json - React entry point
frontend/src/main.jsx - Analysis dashboard · Submission, library management, results, and report export.
frontend/src/App.jsx - Print styling · Supports browser print/PDF report export.
frontend/src/App.css
Python service
- Flask API · Parses requests, enables CORS, manages corpus files, and serializes results.
backend/app.py - Similarity engine · Produces sentence attribution, flags, and aggregate similarity metrics.
backend/engine.py - Text normalization · Math/LaTex-aware cleanup and sentence tokenization.
backend/utils.py - PDF text extraction
- TF-IDF comparison · Cosine similarity identifies threshold-exceeding overlaps.
- Backend dependencies · Flask, Flask-CORS, scikit-learn, NLTK, and PyMuPDF.
requirements.txt
Local corpus
- Research library · Persistent mixed PDF and text source documents.
- Assignment PDF
data/Assignment.pdf - IEEE notes
data/ieee_notes.txt - Test text
data/test1.txt
Connections 16
- Vite client runtime → React entry point: starts
- React entry point → Analysis dashboard: renders
- Analysis dashboard → Print styling: uses
- Analysis dashboard → Flask API: analysis and library HTTP requests
- Flask API → Similarity engine: delegates analysis
- Flask API → Research library: uploads, lists, and deletes files
- Similarity engine → Text normalization: normalizes and splits text
- Similarity engine → TF-IDF comparison: builds vectors and scores similarity
- Similarity engine → Research library: loads comparison sources
- Research library → Assignment PDF: contains
- Research library → IEEE notes: contains
- Research library → Test text: contains
- Assignment PDF → PDF text extraction: text extracted by
- Backend dependencies → Flask API: provides runtime packages
- Backend dependencies → Similarity engine: provides analysis packages
- Flask API → Analysis dashboard: flags, sources, and metrics response