
CodeSniff | Hybrid Code Plagiarism Detector
A high-accuracy hybrid code plagiarism detector that combines K-gram Winnowing, weighted Jaccard, LCS, and JavaParser-based AST similarity to instantly detect Type 1-3 code clones.
"In a world where code is copied, CodeSniff sees what eyes can't."
CodeSniff is a token-based code similarity analyzer designed to detect plagiarism in Java source files. It uses the K-gram fingerprinting technique combined with the Winnowing algorithm the same approach used by Stanford's MOSS system to identify copied code even when variable names are changed, comments are removed, or statements are reordered.
Currently supporting Java with plans to expand to Python, C++, JavaScript and more in future releases through AI-powered semantic analysis.
β οΈ Current Version (v2.0): Supports Java source files only. Multi-language support planned for future releases.
- π Token-based similarity detection using K-gram algorithm
- πͺ Winnowing algorithm for efficient fingerprint selection
- π³ AST Structural Comparison via compiler-level parsing (JavaParser)
- π LCS Statement Alignment for flow-level similarity checks
- β Java source file upload and pairwise comparison
- π» Direct code paste for quick Java code analysis
- π Similarity percentage results table and detailed visual report
- βοΈ Configurable options β K-gram size, window size, ignore comments
- βοΈ Cloud Persistence & History tracking for authenticated users
- π Fully deployed on cloud infrastructure
| Technology | Purpose |
|---|---|
| HTML5 / CSS3 | UI structure and styling |
| Vanilla JavaScript | SPA routing and API calls |
| Vercel | Hosting and deployment |
| Technology | Purpose |
|---|---|
| Java 17 | Core language |
| Spring Boot 3.3.5 | REST API framework |
| Maven | Build and dependency management |
| Azure App Service F1 | Cloud hosting (24/7) |
| Technology | Purpose |
|---|---|
| In-Memory Cache | Temporary report storage |
| GitHub Actions | CI/CD pipeline |
| Nginx | Reverse proxy |
User Browser
β
βΌ
βββββββββββββββββββ
β Vercel β codesniff.tech
β (Frontend) β HTML + CSS + JS
ββββββββββ¬βββββββββ
β API calls
βΌ
βββββββββββββββββββββββββββ
β Azure App Service F1 β codesniff-backend.azurewebsites.net
β Spring Boot Backend β
β βββββββββββββββββββ β
β βAnalyzeControllerβ β
β ββββββββββ¬βββββββββ β
β β β
β ββββββββββΌβββββββββ β
β βSimilarityEngine β β
β ββββββββββ¬βββββββββ β
β β β
β ββββββββββΌβββββββββ β
β βTokenizer β β
β ββββββββββ¬βββββββββ β
β β β
β ββββββββββΌβββββββββ β
β βCodeNormalizer β β
β βββββββββββββββββββ β
βββββββββββββββββββββββββββ
Source Code A / B
βββββββββ΄ββββββββ
βΌ βΌ
[Raw Code] [Tokenizer]
β β
β ββββββββββββββββββββββββ
βΌ βΌ βΌ
[ASTBuilder] [CodeNormalizer] [StatementGrouper]
β β β
βΌ βΌ βΌ
[ASTComparator] [Winnowing] [LcsEngine]
β β β
βΌ βΌ βΌ
AST Score Jaccard & Coverage LCS Score
β β β
βββββββββββββββββΌβββββββββββββββββββββββ
βΌ
[Hybrid Score]
| Clone Type | Description | Detected |
|---|---|---|
| Type 1 | Exact copy | β |
| Type 2 | Renamed identifiers | β |
| Type 3 | Added/removed statements | β |
| Type 4 | Semantic similarity |
- Java 17+
- Maven 3.9+
# Clone the repository
git clone https://github.com/Kunal-htr/codesniff.git
# Navigate to project
cd codesniff
# Install dependencies
mvn clean installCreate src/main/resources/application.properties:
server.port=9090mvn spring-boot:runOpen http://localhost:9090 in your browser.
POST /api/analyze
Content-Type: application/jsonRequest Body:
{
"submissions": [
{ "name": "A.java", "content": "public class A { int sum(int[] a){int s=0;for(int i=0;i<a.length;i++){s+=a[i];}return s;} }" },
{ "name": "B.java", "content": "public class B { int total(int[] d){int t=0;for(int j=0;j<d.length;j++){t+=d[j];}return t;} }" }
],
"options": {
"omitComments": true,
"k": 6,
"window": 4
}
}Response:
{
"summary": [
{
"a": "A.java",
"b": "B.java",
"score": 1.0,
"jaccard": 1.0,
"coverage": 1.0,
"reportId": "d741ca12-a16f-40c2-9ee6-4e59f427ee0e"
}
]
}GET /api/report/{id}Response:
{
"nameA": "A.java",
"nameB": "B.java",
"jaccard": 1.0,
"coverage": 1.0,
"lcs": 1.0,
"ast": 1.0,
"hybrid": 1.0,
"verdict": "High",
"verdictDescription": "High similarity detected. There is a high probability of direct copy/paste or minimal rewriting.",
"operatorDivergent": false,
"metadata": {
"k": 6,
"window": 4,
"omitComments": true,
"fingerprintMatchCount": 15,
"fingerprintCountA": 15,
"fingerprintCountB": 15
}
}GET /api/healthCodeSniff is alive!
CodeSniff v2.0 introduces strict input validation and centralized exception handling. Requests are validated using Jakarta Bean Validation before reaching the analysis engine.
submissions: Must have between 1 and 200 files per batch.name&content: Must not be blank.k: Must be between 3 and 64.window: Must be between 1 and 128.
When a validation constraint is violated, or a report ID is not found, the API returns a structured error object instead of raw stack traces:
{
"error": "Bad Request",
"message": "Validation failed: submissions[0].content: Submission content must not be blank",
"status": 400,
"timestamp": 1784260000000
}codesniff/
βββ src/
β βββ main/
β βββ java/
β β βββ backend/
β β βββ App.java # Spring Boot entry point
β β βββ common/ # Global exceptions, DTOs & utilities
β β βββ config/ # Security, CORS & Rate Limiting configs
β β βββ modules/ # Domain-driven architecture modules
β β βββ report/ # Batch generation, PDF/CSV exports
β β βββ similarity/ # Core AST matching & Winnowing engine
β β βββ user/ # Authentication, JWT & Profile management
β βββ resources/
β βββ db/migration/ # Flyway SQL migrations
β βββ application.properties # Spring Boot config
βββ frontend/ # Frontend UI (Vercel deployment)
β βββ index.html # Main UI
β βββ app.js # Frontend logic & routing
β βββ style.css # Styling
βββ test_samples/ # Standard plagiarism test samples
βββ Dockerfile # Container config
βββ pom.xml # Maven config
git push to main
β
βΌ
GitHub Actions triggers
β
βΌ
Maven build + test
β
βΌ
Deploy to Azure App Service
β
βΌ
Live in ~50 seconds β
| Metric | Value |
|---|---|
| Average response time | ~200ms |
| Max file size | 1MB |
| Supported languages | All text-based |
| Concurrent comparisons | Multiple pairs |
| Module | Name | Status | Version |
|---|---|---|---|
| Module 1 | Similarity Engine | β Complete | v0.5 |
| Module 2 | Report & Visualization | β Complete | v1.0 |
| Module 3 | Authentication and Security | β Complete | v1.5 |
| Module 4 | Database & Storage Integration | β Complete | v2.0 |
| Module 5 | Future AI Integration | π Planned | v2.5 |
This project is licensed under the MIT License.
- Spring Boot
- Vercel
- Azure
- Winnowing Algorithm β Schleimer, Wilkerson, Aiken (2003)