# git-for-windows/track-website-changes architecture

> Architecture diagram of the GitHub repository git-for-windows/track-website-changes, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-04-04). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/git-for-windows/track-website-changes
- Repository: https://github.com/git-for-windows/track-website-changes

## Overview

##### Project Type & Purpose
- This repository is a specialized tool for monitoring website updates for components (specifically for less and PCRE2) that do not offer conventional release feeds.
- Its goal is to detect updates by checking if website contents have changed using HTTP HEAD requests (comparing the Last-Modified header) and to use pattern matching to extract version information.
- Upon detecting a new release and ensuring no duplicate issues exist, it automatically opens an issue (ticket) to track that update.

##### Analyzing the File Structure
- The primary configuration and automation are handled via GitHub workflows located in the .github/workflows directory:
- Example workflows: keepalive.yml and track-website-changes.yml.
- There’s a .github/cached directory which holds cached copies of website content along with timestamp or “last-modified” info (e.g., less.html, less.last-modified, gnupg.* files).
- The repository contains two JavaScript files:
- extract-title-and-body.js: Likely responsible for parsing the website content to pinpoint the component’s title, body, or version details.
- open-issue.js: A script that interacts with GitHub (or another ticketing system) to create new issues when an update is detected.
- Additionally, standard files like README.md and LICENSE provide background and legal information.

##### Key Components
a. GitHub Workflows:
b. Monitoring System:
- “Website Checker” component that sends HEAD requests to target websites to compare Last-Modified headers.
- “Content Cache” (using the .github/cached directory) storing previously downloaded and parsed website content.
c. Parsing & Issue Automation:
- “Content Parser” component (represented by extract-title-and-body.js) that applies pattern matching on fetched content.
- “Issue Creator” component (represented by open-issue.js) that checks for duplicate issues and opens a ticket if a new release is detected.
d. External Interaction:
- "Websites (less, PCRE2, etc.)": show these external services providing release information via their web pages.
- "GitHub Issues": which receives the new issues/tickets triggered by the Issue Creator.

##### Relationships & Data Flow
- The “Content Cache” to decide whether the site content has changed (compare current vs cached last-modified dates).
- The external “Websites” component to reference where data is fetched from.
- If changes are detected, show data flow to the “Content Parser” which processes the HTML content.
- From the “Content Parser”, indicate subsequent data flow to the “Issue Creator” that will create a new GitHub Issue.
- Optionally, include a “Keepalive Workflow” component connected to the repository’s overall health maintenance.

##### Architectural Patterns & Technologies
- This design employs a modular and pipeline approach with distinct responsibilities: fetching data, caching, parsing, and issue creation.
- That the system relies on scheduled GitHub workflows (CI/CD pipeline pattern) to drive automation.
- Use of HEAD requests (to reduce unnecessary downloads), caching for efficiency, and pattern matching for content differentiation.
- Mention that even though the project is simple in structure, it separates concerns into distinct scripts and workflows—a best practice in automation.

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "Input/External"
        ES("Websites (less, PCRE2, etc.)"):::external
    end

    subgraph "Processing"
        WM("Workflow: Monitor Website Changes"):::workflow
        WK("Workflow: Keepalive"):::workflow
        WC("Website Checker"):::automation
        CC("Content Cache"):::automation
        CP("Content Parser"):::automation
        IC("Issue Creator"):::automation
        RH("Repository Health"):::health
    end

    subgraph "Output"
        GI("GitHub Issues"):::output
    end

    %% Connections
    WM -->|"triggers"| WC
    WC -->|"check_cache"| CC
    WC -->|"HEAD_request"| ES
    WC -->|"update_detected"| CP
    CP -->|"parsed_data"| IC
    IC -->|"create_issue"| GI
    WK -->|"maintains"| RH

    %% Click Events
    click WM "https://github.com/git-for-windows/track-website-changes/blob/main/.github/workflows/track-website-changes.yml"
    click WK "https://github.com/git-for-windows/track-website-changes/blob/main/.github/workflows/keepalive.yml"
    click CC "https://github.com/git-for-windows/track-website-changes/tree/main/.github/cached"
    click CP "https://github.com/git-for-windows/track-website-changes/blob/main/extract-title-and-body.js"
    click IC "https://github.com/git-for-windows/track-website-changes/blob/main/open-issue.js"

    %% Styles
    classDef workflow fill:#f2d7d5,stroke:#c0392b,stroke-width:2px;
    classDef automation fill:#d5f5e3,stroke:#27ae60,stroke-width:2px;
    classDef external fill:#d6eaf8,stroke:#2980b9,stroke-width:2px;
    classDef output fill:#f9e79f,stroke:#f1c40f,stroke-width:2px;
    classDef health fill:#fceabb,stroke:#f08a24,stroke-width:2px;
```
