Code Comparator

A web change detection system, built during a software engineering internship and still in production.

The company was paying a monthly subscription for a tool that watched competitor and client websites for changes. I proposed building our own. What started as a suggestion became the main project of my internship, and the system has been running on their servers ever since.

Code Comparator control panel listing monitored domains, with a form to add a new monitor

The real problem

Comparing two versions of a web page is trivial. Telling a real change from noise is not. WordPress rewrites version parameters on every load, analytics tools inject timestamps, security plugins rotate tokens. A naive comparator fires alerts constantly, and within two weeks nobody reads them. Most of the work went into a normalisation layer that strips fifteen categories of dynamic parameters before anything is compared.

Code Comparator diff view with deleted and modified lines highlighted in red and orange, and a colour legend

Comparing against the right thing

The obvious approach compares every new capture against the original snapshot, which becomes useless within days — it only ever tells you the page differs from where it started. I built a stepped model instead: each capture is compared against the one immediately before it, so the alert answers the question the business actually has, which is what changed this time.

Iteration

The first version of that normalisation function had four patterns. The final one has fifteen categories — versioning, timestamps, cache-busting, tokens and nonces, build numbers, analytics parameters, CDN routing. Each was added after a specific false positive in production. The test suite documents them by name: Google Fonts with multiple parameters, OneSignal PHP timestamps, WooCommerce cart nonces.

How it works

An LCS-based diff engine with a Levenshtein similarity threshold, so a modified line reads as modified rather than as a delete plus an insert. Changes are colour-coded — red for removed, orange for new or changed, green for whitespace only. Three interfaces sit on top: a manual comparison page, a REST endpoint returning a plain status string, and a cron-driven monitor that emails when a watched page moves.

Code Comparator changes page showing the comparison date, the two compared pages and a deleted block of code
Code Comparator diff view of HTML source with deleted and modified lines highlighted

Handing it over

I documented the system for someone who would maintain it without me — a technical readme, a system diagram, and a step-by-step deployment checklist written in plain language for a non-programmer. It replaced the paid subscription and became part of how the company works.

· internal tool, login required

Sole developer, internship project · PHP, JavaScript, PHPMailer, cron · 2024–2025