# kalebu/plagiarism-checker-python architecture

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

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

## Overview

##### Project Type and Purpose
- Type: A CLI text-similarity tool (not a web or full-stack app).
- Purpose: Read all “.txt” files in a directory, convert each document into a numeric vector, compute pairwise cosine similarities, and output the scores.

##### File Structure
- Top-level files:
– app.py: main script
– requirements.txt: Python dependencies (e.g., numpy, scikit-learn or custom code)
– README.md: documentation
- Sample documents: fatma.txt, john.txt, juma.txt
- pictures/: assets for README only (not part of runtime)

##### Key Components
a. Input Loader
– Reads all .txt files from the project directory
– Outputs raw text strings
b. Preprocessing Module
– (Optional) Tokenization, case‐folding, stop‐word removal
– Outputs cleaned token lists or raw text if no preprocessing
c. Vectorization Module
– Transforms text into numeric arrays (e.g., term‐frequency vectors or TF-IDF using sklearn’s TfidfVectorizer)
– Outputs document‐vectors matrix
d. Similarity Engine
– Computes cosine similarity between every pair of document vectors
– Outputs a similarity score matrix or list of tuples
e. Output Module
– Formats and prints results to the console, e.g.:
(‘john.txt’, ‘juma.txt’, 0.5466)
f. External Libraries
– Python runtime
– numpy, scikit-learn (or pure-Python vector math code)

##### Relationships and Data Flows
– Filesystem → Input Loader
– Input Loader → Preprocessing
– Preprocessing → Vectorization
– Vectorization → Similarity Engine
– Similarity Engine → Output Module → Console

##### Architectural Patterns and Design Principles
- Single-responsibility: each module does one thing (load, preprocess, vectorize, compute, output).
- Pipelines/data flow: linear sequence from raw input to final output.
- Extensibility point: the vectorization block can be swapped out for the “Pysimilar” library or another algorithm.

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "Plagiarism-checker-Python Architecture"
        direction TB
        IL["Input Loader"]:::processing
        PP["Preprocessing Module"]:::processing
        VM["Vectorization Module"]:::processing
        SE["Similarity Engine"]:::processing
        OM["Output Module"]:::output
    end

    DS1["fatma.txt"]:::dataSource
    DS2["john.txt"]:::dataSource
    DS3["juma.txt"]:::dataSource
    ELE["requirements.txt"]:::external
    DOC["README.md"]:::external
    PIC["pictures/"]:::external
    Console["Console"]:::output

    DS1 -->|"raw text"| IL
    DS2 -->|"raw text"| IL
    DS3 -->|"raw text"| IL
    IL -->|"raw text"| PP
    PP -->|"tokens"| VM
    VM -->|"vectors"| SE
    SE -->|"scores"| OM
    OM -->|"console output"| Console

    IL -->|"uses"| ELE
    PP -->|"uses"| ELE
    VM -->|"uses"| ELE
    SE -->|"uses"| ELE
    OM -->|"uses"| ELE

    DOC -.->|"documentation"| IL
    PIC -.->|"assets"| DOC

    click IL "https://github.com/kalebu/plagiarism-checker-python/blob/master/app.py"
    click PP "https://github.com/kalebu/plagiarism-checker-python/blob/master/app.py"
    click VM "https://github.com/kalebu/plagiarism-checker-python/blob/master/app.py"
    click SE "https://github.com/kalebu/plagiarism-checker-python/blob/master/app.py"
    click OM "https://github.com/kalebu/plagiarism-checker-python/blob/master/app.py"
    click ELE "https://github.com/kalebu/plagiarism-checker-python/blob/master/requirements.txt"
    click DS1 "https://github.com/kalebu/plagiarism-checker-python/blob/master/fatma.txt"
    click DS2 "https://github.com/kalebu/plagiarism-checker-python/blob/master/john.txt"
    click DS3 "https://github.com/kalebu/plagiarism-checker-python/blob/master/juma.txt"
    click DOC "https://github.com/kalebu/plagiarism-checker-python/blob/master/README.md"
    click PIC "https://github.com/kalebu/plagiarism-checker-python/tree/master/pictures/"

    classDef dataSource fill:#D0E6FF,stroke:#0366d6,color:#0366d6;
    classDef processing fill:#D4F4DD,stroke:#228B22,color:#228B22;
    classDef output fill:#FFE4B3,stroke:#FF8C00,color:#FF8C00;
    classDef external fill:#F0F0F0,stroke:#A9A9A9,color:#555;
```
