# architshukla/plagiarism-checker architecture

> Architecture diagram of the GitHub repository architshukla/plagiarism-checker, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-08-25). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/architshukla/plagiarism-checker
- Repository: https://github.com/architshukla/plagiarism-checker

## Overview

#### Purpose and execution model
This is a server-hosted document plagiarism checker. A PHP/Bootstrap UI accepts a document, invokes a Python analysis pipeline, and exposes persisted output/logs. The standalone analyzer can also run as `python scripts/main.py <input> <output>`.

#### User-facing PHP entry points
- `index.php` is the primary upload/check interface.
- `processFile.php` handles uploaded-file processing and likely bridges PHP requests to the analysis scripts.
- `executeScripts.php` is the execution boundary for launching backend work.
- `logs.php` and `readLogs.php` expose prior analysis status or results.

The browser layer is static Bootstrap/jQuery assets under `assets/css/bootstrap.css`, `assets/js/bootstrap.js`, and `assets/js/jquery.js`.

#### Document ingestion and normalization
Uploaded source files are staged in `temp/` (represented by `temp/Placeholder.md`). The Python backend supports text plus office/PDF formats through format-specific tools:
- DOCX extraction: `scripts/extractdocx.py`
- DOC/PPT conversion binaries: `scripts/catdoc.exe`, `scripts/catppt.exe`
- PDF text extraction: `scripts/pdftotext32.exe`, `scripts/pdftotext64.exe`

This is a critical trust and process boundary: PHP-provided filenames/paths ultimately feed local command execution and parsers.

#### Plagiarism-analysis pipeline
`scripts/main.py` orchestrates the core workflow: derive n-gram queries from extracted source text, search for candidate web pages, compare candidate content to the source/query, and write average similarity results to an output text file. `scripts/getq.py` is the likely query-generation stage, while `scripts/htmlstrip.py` converts fetched HTML into comparable text.

Primary flow: uploaded document → extracted plain text → generated n-gram search queries → online search results/URLs → fetched and stripped page text → per-result similarity → aggregated output.

#### Similarity engine
`scripts/cosineSim.py` provides the text-comparison mechanism used to score query/source text against web-page content. Similarity is therefore lexical/vector-based rather than a stored corpus or ML service. Intermediate/sample artifacts (`scripts/sampleText.txt`, `scripts/sampleOut.txt`) indicate file-oriented input/output contracts between stages.

#### External services, runtimes, and dependencies
The application requires a PHP-capable web server and a Python runtime (apparently Python 2-era dependencies). The pipeline depends on Google Search APIs for discovery and Internet access to retrieve result pages. DOCX support uses `python-docx` and its dependencies (`PIL`, `lxml`, `python-dateutil`); Linux deployments may instead rely on installed `pdftotext`/`catdoc`.

Windows Python location is configured through `config/config.txt`, making PHP-to-Python invocation deployment-specific.

#### Persistence and operational boundaries
`temp/` is mutable upload workspace; output and operational history are mediated by the PHP log endpoints (`logs.php`, `readLogs.php`). The repository has no database or asynchronous worker structure visible: request handlers likely synchronously start Python and exchange data through filesystem paths/output files. This creates coupling among web-server permissions, executable availability, temp-file lifecycle, and external search/network latency.

Main entry points: [`scripts/main.py`](https://github.com/architshukla/plagiarism-checker/blob/master/scripts/main.py) (Analysis orchestrator), [`temp/Placeholder.md`](https://github.com/architshukla/plagiarism-checker/blob/master/temp/Placeholder.md) (Temporary workspace), [`processFile.php`](https://github.com/architshukla/plagiarism-checker/blob/master/processFile.php) (Upload processor), [`executeScripts.php`](https://github.com/architshukla/plagiarism-checker/blob/master/executeScripts.php) (Script launcher)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web["PHP web application"]
  node_browser["Browser UI<br/>Bootstrap/jQuery client"]
  node_index["Upload interface<br/>PHP entry point<br/>[index.php]"]
  node_process["Upload processor<br/>PHP handler<br/>[processFile.php]"]
  node_execute{{"Script launcher<br/>PHP execution boundary<br/>[executeScripts.php]"}}
  node_logs["Logs and results UI<br/>PHP endpoints<br/>[logs.php]"]
  node_workspace[("Temporary workspace<br/>mutable filesystem<br/>[Placeholder.md]")]
end

subgraph group_pipeline["Python analysis pipeline"]
  node_main["Analysis orchestrator<br/>Python CLI<br/>[main.py]"]
  node_extract["Document extraction<br/>format adapters<br/>[extractdocx.py]"]
  node_queries["Query generation<br/>n-gram generator<br/>[getq.py]"]
  node_search["Web candidate discovery<br/>search integration"]
  node_strip["HTML text normalization<br/>HTML stripper<br/>[htmlstrip.py]"]
  node_similarity["Similarity scoring<br/>lexical/vector comparison<br/>[cosineSim.py]"]
  node_output["Similarity output<br/>text result artifact<br/>[sampleOut.txt]"]
end

subgraph group_external["External tools and services"]
  node_converters{{"Office/PDF converters<br/>local executables<br/>[catdoc.exe]"}}
  node_google{{"Google Search APIs<br/>external search service"}}
  node_webpages["Candidate web pages<br/>Internet content"]
  node_runtime["Python runtime configuration<br/>deployment configuration<br/>[config.txt]"]
end

node_browser -->|"uploads document"| node_index
node_index -->|"submits upload"| node_process
node_process -->|"stages file"| node_workspace
node_process -->|"requests analysis"| node_execute
node_execute -.->|"uses Python path"| node_runtime
node_execute -->|"starts CLI pipeline"| node_main
node_workspace -->|"input/output paths"| node_main
node_main -->|"extracts source text"| node_extract
node_extract -->|"uses for DOC/PPT/PDF"| node_converters
node_extract -->|"plain text"| node_queries
node_queries -->|"n-gram queries"| node_search
node_search -->|"search requests"| node_google
node_google -->|"candidate URLs"| node_webpages
node_webpages -->|"fetched HTML"| node_strip
node_strip -->|"page text"| node_similarity
node_queries -->|"source/query text"| node_similarity
node_similarity -->|"per-result scores"| node_output
node_main -->|"aggregates averages"| node_output
node_output -->|"persists result file"| node_workspace
node_logs -->|"reads status/results"| node_workspace
node_browser -->|"views prior runs"| node_logs

click node_index "https://github.com/architshukla/plagiarism-checker/blob/master/index.php"
click node_process "https://github.com/architshukla/plagiarism-checker/blob/master/processFile.php"
click node_execute "https://github.com/architshukla/plagiarism-checker/blob/master/executeScripts.php"
click node_logs "https://github.com/architshukla/plagiarism-checker/blob/master/logs.php"
click node_workspace "https://github.com/architshukla/plagiarism-checker/blob/master/temp/Placeholder.md"
click node_main "https://github.com/architshukla/plagiarism-checker/blob/master/scripts/main.py"
click node_extract "https://github.com/architshukla/plagiarism-checker/blob/master/scripts/extractdocx.py"
click node_queries "https://github.com/architshukla/plagiarism-checker/blob/master/scripts/getq.py"
click node_strip "https://github.com/architshukla/plagiarism-checker/blob/master/scripts/htmlstrip.py"
click node_similarity "https://github.com/architshukla/plagiarism-checker/blob/master/scripts/cosineSim.py"
click node_output "https://github.com/architshukla/plagiarism-checker/blob/master/scripts/sampleOut.txt"
click node_converters "https://github.com/architshukla/plagiarism-checker/blob/master/scripts/catdoc.exe"
click node_runtime "https://github.com/architshukla/plagiarism-checker/blob/master/config/config.txt"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_browser,node_index,node_process,node_execute,node_logs,node_workspace toneBlue
class node_main,node_extract,node_queries,node_search,node_strip,node_similarity,node_output toneAmber
class node_converters,node_google,node_webpages,node_runtime toneMint
```

## Components

### PHP web application

- **Browser UI**: Bootstrap/jQuery client
- [Upload interface](https://github.com/architshukla/plagiarism-checker/blob/master/index.php): PHP entry point · `index.php`
- [Upload processor](https://github.com/architshukla/plagiarism-checker/blob/master/processFile.php): PHP handler · Stages uploads and bridges requests to analysis. · `processFile.php`
- [Script launcher](https://github.com/architshukla/plagiarism-checker/blob/master/executeScripts.php): PHP execution boundary · Launches local backend work from PHP-provided inputs. · `executeScripts.php`
- [Logs and results UI](https://github.com/architshukla/plagiarism-checker/blob/master/logs.php): PHP endpoints · `logs.php`
- [Temporary workspace](https://github.com/architshukla/plagiarism-checker/blob/master/temp/Placeholder.md): mutable filesystem · Upload staging and file-based pipeline exchange. · `temp/Placeholder.md`

### Python analysis pipeline

- [Analysis orchestrator](https://github.com/architshukla/plagiarism-checker/blob/master/scripts/main.py): Python CLI · Runs extraction, discovery, comparison, and output aggregation. · `scripts/main.py`
- [Document extraction](https://github.com/architshukla/plagiarism-checker/blob/master/scripts/extractdocx.py): format adapters · Converts supported documents into plain text. · `scripts/extractdocx.py`
- [Query generation](https://github.com/architshukla/plagiarism-checker/blob/master/scripts/getq.py): n-gram generator · `scripts/getq.py`
- **Web candidate discovery**: search integration
- [HTML text normalization](https://github.com/architshukla/plagiarism-checker/blob/master/scripts/htmlstrip.py): HTML stripper · `scripts/htmlstrip.py`
- [Similarity scoring](https://github.com/architshukla/plagiarism-checker/blob/master/scripts/cosineSim.py): lexical/vector comparison · Scores source or query text against candidate page text. · `scripts/cosineSim.py`
- [Similarity output](https://github.com/architshukla/plagiarism-checker/blob/master/scripts/sampleOut.txt): text result artifact · Stores aggregated average similarity results. · `scripts/sampleOut.txt`

### External tools and services

- [Office/PDF converters](https://github.com/architshukla/plagiarism-checker/blob/master/scripts/catdoc.exe): local executables · DOC, PPT, and PDF extraction binaries. · `scripts/catdoc.exe`
- **Google Search APIs**: external search service
- **Candidate web pages**: Internet content
- [Python runtime configuration](https://github.com/architshukla/plagiarism-checker/blob/master/config/config.txt): deployment configuration · Configures deployment-specific Python invocation. · `config/config.txt`

## Connections

- Browser UI → Upload interface: uploads document
- Upload interface → Upload processor: submits upload
- Upload processor → Temporary workspace: stages file
- Upload processor → Script launcher: requests analysis
- Script launcher → Python runtime configuration: uses Python path
- Script launcher → Analysis orchestrator: starts CLI pipeline
- Temporary workspace → Analysis orchestrator: input/output paths
- Analysis orchestrator → Document extraction: extracts source text
- Document extraction → Office/PDF converters: uses for DOC/PPT/PDF
- Document extraction → Query generation: plain text
- Query generation → Web candidate discovery: n-gram queries
- Web candidate discovery → Google Search APIs: search requests
- Google Search APIs → Candidate web pages: candidate URLs
- Candidate web pages → HTML text normalization: fetched HTML
- HTML text normalization → Similarity scoring: page text
- Query generation → Similarity scoring: source/query text
- Similarity scoring → Similarity output: per-result scores
- Analysis orchestrator → Similarity output: aggregates averages
- Similarity output → Temporary workspace: persists result file
- Logs and results UI → Temporary workspace: reads status/results
- Browser UI → Logs and results UI: views prior runs
