# sowpnil-roy/openplag architecture

> Architecture diagram of the GitHub repository sowpnil-roy/openplag, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-12-03). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/sowpnil-roy/openplag
- Repository: https://github.com/sowpnil-roy/openplag

## Overview

OpenPlag is a self-hosted English and Bangla plagiarism-detection product with a web UI and REST API. A user submits a document or pasted text; the backend extracts text, runs detection and source search, then stores a report that can be reviewed in the UI or exported. Separate branches support corpus administration, teacher/class workflows, and developer integrations such as API keys and signed webhooks. The graph reflects documented capabilities and indexed references; several internal stage-to-stage calls are not shown in the excerpts, so those links are omitted.

Main entry points: [`backend/app/workers/pipeline.py`](https://github.com/sowpnil-roy/openplag/blob/main/backend/app/workers/pipeline.py) (Scan pipeline), [`backend/app/api/v1/__init__.py`](https://github.com/sowpnil-roy/openplag/blob/main/backend/app/api/v1/__init__.py) (API routes), [`frontend/lib/api.ts`](https://github.com/sowpnil-roy/openplag/blob/main/frontend/lib/api.ts) (API client), [`backend/app/workers/tasks.py`](https://github.com/sowpnil-roy/openplag/blob/main/backend/app/workers/tasks.py) (Worker tasks)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web["Web experience"]
  node_webui["Web workflows<br/>[page.tsx]"]
  node_reportui["Report review<br/>[page.tsx]"]
  node_classui["Class workflows<br/>[page.tsx]"]
  node_api_client["API client<br/>[api.ts]"]
end

subgraph group_service["API and orchestration"]
  node_api["REST API<br/>[main.py]"]
  node_routes["API routes<br/>[__init__.py]"]
  node_submissions["Submission endpoints<br/>[submissions.py]"]
  node_class_routes["Class endpoints<br/>[classes.py]"]
  node_report_routes["Report endpoints<br/>[reports.py]"]
  node_worker_tasks["Worker tasks<br/>[tasks.py]"]
  node_pipeline["Scan pipeline<br/>[pipeline.py]"]
  node_reports["Report generation<br/>[pdf.py]"]
  node_webhook_api["Webhook management<br/>[webhooks.py]"]
end

subgraph group_detection["Detection and corpus"]
  node_extraction["Text extraction<br/>[extract.py]"]
  node_matching["Fingerprint matching<br/>[align.py]"]
  node_web_search["Web and scholarly search"]
  node_paraphrase["Paraphrase detection<br/>[embeddings.py]"]
  node_corpus_jobs["Corpus import and indexing<br/>[jobs.py]"]
end

subgraph group_data["State and integrations"]
  node_db[("Relational database<br/>[db.py]")]
  node_object_store[("Object storage<br/>[minio.py]")]
  node_webhook_delivery["Signed webhook delivery<br/>[webhooks.py]"]
end

node_user(("User"))
node_external_sources{{"Search and scholarly services"}}

node_user -->|"submits work"| node_webui
node_user -->|"uses API"| node_api_client
node_webui -.->|"requests API"| node_api_client
node_api_client -->|"calls REST API"| node_api
node_api -->|"mounts routes"| node_routes
node_routes -->|"registers"| node_submissions
node_routes -->|"registers"| node_class_routes
node_routes -->|"registers"| node_report_routes
node_submissions -.->|"dispatches scans"| node_worker_tasks
node_worker_tasks -->|"runs stages"| node_pipeline
node_pipeline -->|"extracts text"| node_extraction
node_pipeline -->|"matches passages"| node_matching
node_pipeline -->|"queries sources"| node_web_search
node_pipeline -->|"checks paraphrases"| node_paraphrase
node_external_sources -.->|"returns candidates"| node_web_search
node_corpus_jobs -->|"stores corpus text"| node_object_store
node_corpus_jobs -.->|"indexes corpus"| node_db
node_pipeline -.->|"records scan data"| node_db
node_pipeline -.->|"reads document text"| node_object_store
node_report_routes -->|"serves reports"| node_reportui
node_reportui -.->|"loads report data"| node_api_client
node_classui -->|"manages classes"| node_class_routes
node_pipeline -.->|"produces report"| node_reports
node_webhook_api -->|"tests delivery"| node_webhook_delivery
node_worker_tasks -->|"queues delivery"| node_webhook_delivery
node_webhook_delivery -.->|"posts events"| node_external_sources

click node_webui "https://github.com/sowpnil-roy/openplag/blob/main/frontend/app/check/page.tsx"
click node_reportui "https://github.com/sowpnil-roy/openplag/blob/main/frontend/app/reports/%5Bid%5D/page.tsx"
click node_classui "https://github.com/sowpnil-roy/openplag/blob/main/frontend/app/classes/%5Bid%5D/page.tsx"
click node_api_client "https://github.com/sowpnil-roy/openplag/blob/main/frontend/lib/api.ts"
click node_api "https://github.com/sowpnil-roy/openplag/blob/main/backend/app/main.py"
click node_routes "https://github.com/sowpnil-roy/openplag/blob/main/backend/app/api/v1/__init__.py"
click node_submissions "https://github.com/sowpnil-roy/openplag/blob/main/backend/app/api/v1/submissions.py"
click node_class_routes "https://github.com/sowpnil-roy/openplag/blob/main/backend/app/api/v1/classes.py"
click node_report_routes "https://github.com/sowpnil-roy/openplag/blob/main/backend/app/api/v1/reports.py"
click node_worker_tasks "https://github.com/sowpnil-roy/openplag/blob/main/backend/app/workers/tasks.py"
click node_pipeline "https://github.com/sowpnil-roy/openplag/blob/main/backend/app/workers/pipeline.py"
click node_extraction "https://github.com/sowpnil-roy/openplag/blob/main/backend/app/detection/extract.py"
click node_matching "https://github.com/sowpnil-roy/openplag/blob/main/backend/app/detection/align.py"
click node_web_search "https://github.com/sowpnil-roy/openplag/tree/main/backend/app/detection/providers"
click node_paraphrase "https://github.com/sowpnil-roy/openplag/blob/main/backend/app/detection/embeddings.py"
click node_corpus_jobs "https://github.com/sowpnil-roy/openplag/blob/main/backend/app/corpus/jobs.py"
click node_reports "https://github.com/sowpnil-roy/openplag/blob/main/backend/app/reports/pdf.py"
click node_db "https://github.com/sowpnil-roy/openplag/blob/main/backend/app/db.py"
click node_object_store "https://github.com/sowpnil-roy/openplag/blob/main/backend/app/storage/minio.py"
click node_webhook_api "https://github.com/sowpnil-roy/openplag/blob/main/backend/app/api/v1/webhooks.py"
click node_webhook_delivery "https://github.com/sowpnil-roy/openplag/blob/main/backend/app/workers/webhooks.py"

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_webui,node_reportui,node_classui,node_api_client,node_user toneBlue
class node_api,node_routes,node_submissions,node_class_routes,node_report_routes,node_worker_tasks,node_pipeline,node_reports,node_webhook_api toneAmber
class node_extraction,node_matching,node_web_search,node_paraphrase,node_corpus_jobs toneMint
class node_db,node_object_store,node_webhook_delivery toneRose
class node_external_sources toneIndigo
```

## Components

### Web experience

- [Web workflows](https://github.com/sowpnil-roy/openplag/blob/main/frontend/app/check/page.tsx): `frontend/app/check/page.tsx`
- [Report review](https://github.com/sowpnil-roy/openplag/blob/main/frontend/app/reports/%5Bid%5D/page.tsx): `frontend/app/reports/[id]/page.tsx`
- [Class workflows](https://github.com/sowpnil-roy/openplag/blob/main/frontend/app/classes/%5Bid%5D/page.tsx): `frontend/app/classes/[id]/page.tsx`
- [API client](https://github.com/sowpnil-roy/openplag/blob/main/frontend/lib/api.ts): `frontend/lib/api.ts`

### API and orchestration

- [REST API](https://github.com/sowpnil-roy/openplag/blob/main/backend/app/main.py): `backend/app/main.py`
- [API routes](https://github.com/sowpnil-roy/openplag/blob/main/backend/app/api/v1/__init__.py): `backend/app/api/v1/__init__.py`
- [Submission endpoints](https://github.com/sowpnil-roy/openplag/blob/main/backend/app/api/v1/submissions.py): `backend/app/api/v1/submissions.py`
- [Class endpoints](https://github.com/sowpnil-roy/openplag/blob/main/backend/app/api/v1/classes.py): `backend/app/api/v1/classes.py`
- [Report endpoints](https://github.com/sowpnil-roy/openplag/blob/main/backend/app/api/v1/reports.py): `backend/app/api/v1/reports.py`
- [Worker tasks](https://github.com/sowpnil-roy/openplag/blob/main/backend/app/workers/tasks.py): `backend/app/workers/tasks.py`
- [Scan pipeline](https://github.com/sowpnil-roy/openplag/blob/main/backend/app/workers/pipeline.py): `backend/app/workers/pipeline.py`
- [Report generation](https://github.com/sowpnil-roy/openplag/blob/main/backend/app/reports/pdf.py): `backend/app/reports/pdf.py`
- [Webhook management](https://github.com/sowpnil-roy/openplag/blob/main/backend/app/api/v1/webhooks.py): `backend/app/api/v1/webhooks.py`

### Detection and corpus

- [Text extraction](https://github.com/sowpnil-roy/openplag/blob/main/backend/app/detection/extract.py): `backend/app/detection/extract.py`
- [Fingerprint matching](https://github.com/sowpnil-roy/openplag/blob/main/backend/app/detection/align.py): `backend/app/detection/align.py`
- [Web and scholarly search](https://github.com/sowpnil-roy/openplag/tree/main/backend/app/detection/providers): `backend/app/detection/providers`
- [Paraphrase detection](https://github.com/sowpnil-roy/openplag/blob/main/backend/app/detection/embeddings.py): `backend/app/detection/embeddings.py`
- [Corpus import and indexing](https://github.com/sowpnil-roy/openplag/blob/main/backend/app/corpus/jobs.py): `backend/app/corpus/jobs.py`

### State and integrations

- [Relational database](https://github.com/sowpnil-roy/openplag/blob/main/backend/app/db.py): `backend/app/db.py`
- [Object storage](https://github.com/sowpnil-roy/openplag/blob/main/backend/app/storage/minio.py): `backend/app/storage/minio.py`
- [Signed webhook delivery](https://github.com/sowpnil-roy/openplag/blob/main/backend/app/workers/webhooks.py): `backend/app/workers/webhooks.py`

### Other components

- **User**
- **Search and scholarly services**

## Connections

- User → Web workflows: submits work
- User → API client: uses API
- Web workflows → API client: requests API
- API client → REST API: calls REST API
- REST API → API routes: mounts routes (evidence: `backend/app/main.py`)
- API routes → Submission endpoints: registers (evidence: `backend/app/api/v1/__init__.py`)
- API routes → Class endpoints: registers (evidence: `backend/app/api/v1/__init__.py`)
- API routes → Report endpoints: registers (evidence: `backend/app/api/v1/__init__.py`)
- Submission endpoints → Worker tasks: dispatches scans
- Worker tasks → Scan pipeline: runs stages (evidence: `backend/app/workers/tasks.py`)
- Scan pipeline → Text extraction: extracts text (evidence: `backend/app/workers/pipeline.py`)
- Scan pipeline → Fingerprint matching: matches passages (evidence: `backend/app/workers/pipeline.py`)
- Scan pipeline → Web and scholarly search: queries sources (evidence: `backend/app/workers/pipeline.py`)
- Scan pipeline → Paraphrase detection: checks paraphrases (evidence: `backend/app/workers/pipeline.py`)
- Search and scholarly services → Web and scholarly search: returns candidates
- Corpus import and indexing → Object storage: stores corpus text (evidence: `backend/app/corpus/jobs.py`)
- Corpus import and indexing → Relational database: indexes corpus
- Scan pipeline → Relational database: records scan data
- Scan pipeline → Object storage: reads document text (evidence: `backend/app/workers/pipeline.py`)
- Report endpoints → Report review: serves reports
- Report review → API client: loads report data
- Class workflows → Class endpoints: manages classes
- Scan pipeline → Report generation: produces report
- Webhook management → Signed webhook delivery: tests delivery (evidence: `backend/app/api/v1/webhooks.py`)
- Worker tasks → Signed webhook delivery: queues delivery (evidence: `backend/app/workers/tasks.py`)
- Signed webhook delivery → Search and scholarly services: posts events
