How ddcodepl/wally works
Project Type and Purpose
• Wally is a Python-based utility designed to track visual and content changes on web pages. It takes screenshots (using a headless browser) and uses image processing (OpenCV, NumPy) to detect differences. It can operate in batch mode and send Slack notifications when changes occur.
• The project includes integration with Selenium (for browser automation), Firefox extensions (via xpi files) for enhanced browsing, and Docker support for deployment.
File Structure
• Top-Level Files:
• Dockerfile and docker-compose.yml: Provide a containerized environment for easy deployment.
• main.py: Acts as the central entry point for execution.
• requirements.txt: Lists all Python dependencies.
• README.md: Provides instructions, configuration details, and usage examples.
• Directories:
• config: Contains configuration scripts (especially config_example.py) that set up critical parameters like URLs and screen sizes.
• extensions: Contains Firefox extension packages (e.g., uBlock and IDC) which are used to customize the headless browser environment.
• utils: Contains utility modules (compare.py, slack.py, utils.py) that implement supporting functionality such as image comparison and Slack notifications.
Extract Insights from the README
• The README explains that the system uses a headless browser (default is Firefox with extensions) to capture screenshots, and it leverages Slack for notifications.
• It instructs that all necessary configuration should be provided in the config file, outlining tracked URLs and required screen widths.
• The project supports both local and containerized execution, indicating modularity in deployment.
Main Components
a. Core Components:
• Front Controller / Main Execution: Represented by main.py, which orchestrates the tasks.
• Configuration Module: Represent the config directory, highlighting the importance of config/config.py as the required configuration source.
• Browser Automation Module: This is the integration with Selenium, encapsulating how a headless browser is used to render pages and apply extensions.
• Utilities: Include components for image comparison (using NumPy and OpenCV) and sending notifications via Slack (show utilities module).
• Extensions Management: A component dedicated to loading and using Firefox extensions from the extensions directory.
b. Auxiliary Components:
• Docker Environment: Illustrate the Dockerfile and docker-compose.yml’s role in containerized deployment.
• Third-Party Dependencies: Mark libraries like Selenium, NumPy, OpenCV, and Slack connectors.
Relationships and Interactions
• Main.py serves as the orchestrator: it reads configuration parameters, calls utility functions for comparing images, and triggers the Selenium lifecycle to take screenshots.
• The configuration module feeds URLs, screen sizes, and extension details into main.py.
• The browser automation component (Selenium) uses the plugins found in extensions to ensure proper page rendering.
• Once screenshots are taken, the comparison utility detects changes, and if any discrepancies are found, the Slack utility is invoked to notify users.
• Docker setup encapsulates the entire workflow, ensuring the right environment is set up to run these interactions.
Architectural Patterns and Design Principles
• Modular Design: The separation into configuration, main application logic, and utilities emphasizes modularity.
• Separation of Concerns: Different functionalities (web automation, image comparison, and notifications) are segregated into their own modules.
• Containerization: Docker is used to ensure consistency across deployment environments.
• Extensibility: With a dedicated extensions folder and clear configuration instructions, new browsers or plugins can be integrated without changing the core logic.
Detailed Outline
• “Main Application (main.py)” at the center.
• “Image Processing & Comparison (utils/compare.py, OpenCV, NumPy)” connected from the browser module, showing how screenshots are processed.
• “Notification System (utils/slack.py, Slack API)” receiving output from the comparison component.
• Optionally encapsulate the entire system within a Docker container block if emphasizing deployment.