# sms03/plagiarism-checking-code architecture

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

- Interactive diagram: https://gitdiagram.com/sms03/plagiarism-checking-code
- Repository: https://github.com/sms03/plagiarism-checking-code

## Overview

##### Main Components
- User Interface (CLI): Although simple, the script prompts the user for inputs such as the GitHub Personal Access Token, the repository path, and the number of lines per snippet.
- Input Handler/Controller: A portion of the script responsible for collecting and validating user inputs.
- Snippet Extraction Module: The logic that reads the target repository, splits the files into code snippets (with configurable snippet lengths), and prepares them for matching.
- GitHub API Client: A component that constructs and sends requests to the GitHub API with the provided token to search for similar code snippets.
- Response Processor & Output Generator: The logic that processes the API responses, determines if plagiarism (i.e., matching code) is detected, and outputs the results clearly to the command line.

##### Relationships and Interactions
- The CLI receives initial inputs from the user.
- The Input Handler processes these inputs and passes them to the Snippet Extraction Module.
- The Snippet Extraction Module identifies potential code snippets from the provided repository.
- For each snippet, the GitHub API Client sends out a search request.
- API responses are returned and processed by the Response Processor, which then routes the results to the Output Generator.
- The output is printed or logged so that the user can see if matches (indicative of potential plagiarism) are found.

##### Architectural Patterns and Principles
- Even though this is a fairly direct script, it is good practice to employ a modular approach by logically separating responsibilities (input handling, snippet extraction, API handling, and output).
- The design shows a clear separation of concerns and a pipeline-like flow where each module processes and forwards information to the next step.

##### Relevant Technologies and Frameworks
- Python 3.6+ is the runtime environment.
- The ‘requests’ library is used for interacting with the GitHub API.
- GitHub’s REST API is the external service for code search.

##### Elements
- Clear labels: Each component (CLI, Input Handler, Snippet Extractor, GitHub API Client, Response Processor, and Output Generator) should be clearly identified.

## Diagram (Mermaid)

```mermaid
flowchart TD
    User("User"):::actor
    CLI("CLI & Input Handler"):::io
    SE("Snippet Extraction Module"):::business
    API("GitHub API Client"):::external
    RO("Response Processor & Output Generator"):::io

    User -->|"provides_input"| CLI
    CLI -->|"validates_and_forwards"| SE
    SE -->|"extracts_snippets_and_calls"| API
    API -->|"returns_API_responses"| RO
    RO -->|"outputs_results"| User

    click CLI "https://github.com/sms03/plagiarism-checking-code/blob/main/script.py"
    click SE "https://github.com/sms03/plagiarism-checking-code/blob/main/script.py"
    click API "https://github.com/sms03/plagiarism-checking-code/blob/main/script.py"
    click RO "https://github.com/sms03/plagiarism-checking-code/blob/main/script.py"

    classDef actor fill:#FFF2CC,stroke:#B58900,stroke-width:2px;
    classDef io fill:#cce5ff,stroke:#1E90FF,stroke-width:2px;
    classDef business fill:#d4edda,stroke:#28a745,stroke-width:2px;
    classDef external fill:#f8d7da,stroke:#dc3545,stroke-width:2px;
```
