The user wants a design for a "Duplicate Cluster Resolver." This is a system that takes a set of digital assets (likely web pages or documents) and groups them into clusters of duplicates or near-duplicates. The design needs to specifically address four components:
- URL Signals: Analyzing the URL structure itself.
- Content Hashes: Analyzing the actual binary/text content.
- Link Evidence: Analyzing how these assets are linked to or from other places.
- Action Suggestions: Deciding what to do with the duplicates once found (canonicalization, redirection, merging, etc.).
Target Audience: Likely a software engineer, data scientist, or SEO specialist looking for a high-level architectural design or a strategy document.
Tone: Technical, structured, and comprehensive.
Step-by-Step Design Process:
-
High-Level Architecture:
- Input: Stream or batch of URLs/Content.
- Processing: Feature extraction -> Similarity calculation -> Clustering -> Action generation.
- Output: Cluster map + Action plan.
-
Component 1: URL Signals (Syntactic Analysis)
- Goal: Quick, cheap filtering before fetching content.
- Techniques:
- Normalization (lowercase, stripping parameters, decoding).
- Path analysis (product ID vs. slug).
- Parameter sorting/filtering (UTM tags, session IDs).
- Heuristics (URL structure similarity, e.g., Levenshtein distance on paths).
- Output: A score or a boolean flag indicating "high likelihood of duplication" based solely on the string.
-
Component 2: Content Hashes (Semantic/Binary Analysis)
- Goal: Determine if the actual content is the same.
- Levels:
- Exact Match: MD5/SHA-256 of the raw HTML. (Strict)
- Normalized Match: Hash of the HTML after stripping whitespace, scripts, styles. (Better for dynamic footers).
- SimHash/MinHash (LSH): For near-duplicates (shingling). Captures "same article, slightly different template."
- Visual Hash: Screenshot comparison (perceptual hashing) for pages that look the same but have different code (rare but possible).
- Output: A set of fingerprints for each document.
-
Component 3: Link Evidence (Relational Analysis)
- Goal: Use the web graph to confirm relationships or find "parent" pages.
- Techniques:
- Canonical tags (
rel="canonical"): The explicit instruction.
- Internal linking structure: Does page A link to page B with the same anchor text?
- Redirect chains: Is one URL a 301/302 redirect to another?
- Backlink overlap: Do external sites treat them as the same entity?
- Sitemap priority/inheritance.
- Output: Directed edges indicating authority/origin.
-
Component 4: Clustering Logic (The "Resolver")
- Goal: Combine signals to form groups.
- Algorithm:
- Union-Find or Connected Components graph algorithm.
- Weighted scoring: URL (10%) + Content (70%) + Links (20%).
- Selection of "Primary" (Canonical): Criteria (highest PageRank/traffic, shortest URL, HTTPS vs HTTP, self-canonicalizing).
-
Component 5: Action Suggestions (The "Fix")
- Goal: Tell the user/engineer what to do.
- Actions:
- Canonicalization: Add
<link rel="canonical">.
- Redirect: 301 redirect secondary pages to the primary.
- NoIndex: Keep accessible but hide from search engines.
- Consolidation: Merge content if they are partial duplicates (e.g., Paginated content vs. View-All).
- Parameter Handling: Tell Google Search Console to ignore specific parameters.
-
Structure and Formatting:
- Use a hierarchical structure with clear headings.
- Use diagrams (Mermaid or textual representation) if possible.
- Include a "Decision Matrix" or "Scoring System" to make it concrete.
Refining the Content:
- URL Signals: Need to emphasize canonical URL generation vs. raw comparison.
- Content: Distinguish between "Identical" (Plagiarism) and "Functional Duplicate" (Printer friendly vs. Screen friendly). The prompt implies SEO/Web context mostly, so canonicalization is key.
- Link Evidence: Crucial for determining the authority of the representative URL.
- Actions: Needs to be actionable. Not just "these are dupes."
Drafting the Response (Iterative Refinement):
- Introduction: Define the scope (SEO/Database dedup).
- Phase 1: Discovery (URLs).
- Phase 2: Verification (Content).
- Phase 3: Context (Links).
- Phase 4: Resolution (Clustering).
- Phase 5: Action.
Self-Correction during drafting: I initially thought about just comparing strings. I need to make sure I mention semantic similarity. Two pages selling the same "red shoe" but with different descriptions are semantic duplicates, whereas exact hash matches are syntactic duplicates. I will stick primarily to exact/near-exact duplication for this design as "duplicate cluster" usually implies redundancy rather than just thematic similarity.
Let's formalize the "Action Suggestions" part. It shouldn't just be "Delete." It should be "Pick a winner and forward traffic."
Let's create a weighted scoring model example to make the design robust.
Final Polish:
Ensure the terminology is correct (SimHash, LSH, Canonical, 301, rel="alternate").
Plan:
- System Overview: High-level diagram description.
- Signal Layer 1: URL Syntactics: Normalization, Parameter stripping.
- Signal Layer 2: Content Fingerprinting: MinHash, SimHash, DOM diff.
- Signal Layer 3: Link Graph: Canonical tags, redirects, internal link equity.
- The Resolution Engine: Graph clustering, Representative election.
- Action Suggester: Specific directives based on cluster type.
This looks solid. I will generate the response based on this structure.
Designing a Duplicate Cluster Resolver requires a multi-layered approach that moves from cheap, syntactic checks to expensive, semantic analysis.
Here is a comprehensive system design for a Duplicate Cluster Resolver, broken down by signal layer, clustering logic, and action orchestration.
System Architecture Overview
The system functions as a pipeline:
- Ingestion: Fetch URL metadata and content.
- Signal Extraction: Generate fingerprints (URL, Hash, Links).
- Clustering: Group URLs into clusters using a Union-Find (Disjoint Set) structure.
- Resolution: Elect a "Canonical" representative for each cluster.
- Action: Output directives for CMS, Servers, or SEO teams.
Layer 1: URL Signals (Syntactic & Parameter Analysis)
Goal: Identify duplicates cheaply before downloading content.
1. Normalization & Normalization Keys
Before comparing URLs, apply aggressive normalization:
- Protocol Relative: Force HTTPS.
- Case Sensitivity: Lowercase the host and path (unless the server is known to be case-sensitive).
- Trailing Slashes: Add/remove consistently (usually add).
- WWW vs Non-WWW: Standardize to one version.
2. Parameter Filtering (Query String Stripping)
Many duplicates are caused by session IDs, tracking tokens, or sorting parameters (e.g., ?utm_source=twitter, ?session_id=123).
- Strategy: Maintain a whitelist of "content-changing parameters" (e.g.,
?page, ?category). Strip all others.
- Output: A "Stem URL" used for grouping.
3. Path Similarity
For Dynamic URLs (e.g., /product/12345-red-shirt vs /product/67890-blue-shirt):
- Use Regular Expression Tokenization to replace IDs with placeholders:
/product/{id}-{slug}.
- If the pattern matches, flag for content verification (don't auto-cluster yet).
Layer 2: Content Hashes (Fingerprinting)
Goal: Verify if the actual page content is identical or near-identical.
1. Exact Match (Hash Comparison)
- Mechanism: SHA-256 hash of the raw HTML body.
- Use Case: Identifying scrapers, printer-friendly versions, or HTTP/HTTPS duplicates.
2. Near-Duplicate (SimHash / MinHash)
HTML structure often stays the same while small details (timestamps, usernames, counters) change.
- Mechanism: Break HTML into shingles (overlapping n-grams). Hash the shingles and compare the overlap.
- Threshold: If similarity > 95%, treat as duplicate.
- DOM Fingerprinting: Strip all text and attributes, hash the remaining DOM skeleton (skeleton matches indicate template duplicates).
3. Visual Hash (Optional/Expensive)
- Mechanism: Screenshot rendering and Perceptual Hashing (pHash).
- Use Case: Detecting duplicates where the HTML differs significantly (e.g., different coding frameworks) but the user sees the exact same layout.
Layer 3: Link Evidence (Relational Analysis)
Goal: Use external context to determine which page is the "original" or most important.
1. Canonical Tags (rel="canonical")
The strongest signal.
- If URL A links to URL B as canonical, and URL B links to URL B as canonical -> Cluster {A, B} with B as representative.
2. Internal Link Graph (Centrality)
- Analyze which version is linked most frequently from the homepage or top-level navigation.
- Metric: PageRank or Indegree centrality. The version with the most internal "votes" is likely the primary.
3. Redirect Chains
- If URL A 301/302 redirects to URL B -> Merge into cluster.
- If URL A is a "soft 404" (returns 200 but looks like an error page) -> Exclude from clusters and flag for deletion.
Layer 4: Cluster Resolution Logic
Goal: Merge signals into distinct groups and elect a leader.
Algorithm: Weighted Scoring
Each URL in a cluster is scored to determine the "Canonical" version.
Scoring Formula:
Score=(w
- Auth: Is this on the root domain vs. a subdomain? Does it have backlinks?
- CanonicalSelfRef: Does the page explicitly declare itself canonical?
- URL_Cleanliness: Shorter URL, fewer parameters, HTTPS.
- Sitemaps: Is this URL present in
sitemap.xml?
Resolution Workflow
- Group: Create a Connected Component graph where edges represent "Duplicate Of" relationships (derived from Hash or URL signals).
- Elect: Select the node with the highest Score as the Canonical.
- Validate: Ensure the Canonical URL returns a
200 OK. If not, pick the runner-up.
Layer 5: Action Suggestions
Goal: Translate the cluster data into executable tasks.
The system should output a JSON object for every cluster containing specific actions.
Scenario A: Parameter Duplication (Same Domain)
- Signal:
example.com/shoes vs example.com/shoes?ref=menu.
- Action:
ADD_REL_CANONICAL
- Add
<link rel="canonical" href="example.com/shoes"> to the parameter version.
- Optional: Add
NOINDEX to the parameter version if traffic is negligible.
Scenario B: Protocol/Subdomain Duplication
- Signal:
http://example.com vs https://example.com.
- Action:
IMPLEMENT_301_REDIRECT
- Configure the server to 301 redirect all HTTP traffic to HTTPS.
- Reason: Consolidates link equity (SEO) strictly.
Scenario C: Cross-Domain Scrapers
- Signal: Your content appears on
spam-site.net.
- Action:
LEGAL_TAKEDOWN or DISAVOW_LINKS
- If you own both domains (e.g., regional variants), use
hreflang tags.
- If it's theft, generate a DMCA takedown notice.
Scenario D: Pagination / Filter Pages
- Signal:
/products?page=1 vs /products?page=2. Content hash is similar, but distinct products exist.
- Action:
NOINDEX_FOLLOW or REL_PREV_NEXT
- Do not canonicalize page 2 to page 1 (this is a common SEO mistake). Instead, mark them as distinct but part of a series.
Output Data Structure Example
{
"cluster_id": "abc-123",
"canonical_url": "https://www.example.com/products/widget",
"cluster_members": [
{
"url": "http://example.com/products/widget",
"action": "REDIRECT_301",
"reason": "Protocol upgrade"
},
{
"url": "https://example.com/products/widget?utm_source=email",
"action": "IGNORE_CANONICAL",
"reason": "Parameter variant; existing canonical tag is sufficient"
}
],
"confidence_score": 0.98,
"duplicate_type": "EXACT_HASH_MATCH"
}