# rosbel/crawl-n-snap architecture

> Architecture diagram of the GitHub repository rosbel/crawl-n-snap, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-03-31). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/rosbel/crawl-n-snap
- Repository: https://github.com/rosbel/crawl-n-snap

## Overview

##### Project Type and Purpose
- This is a CLI tool built in TypeScript that leverages Playwright to take website screenshots at various resolutions.
- It includes functionality for optionally crawling linked pages on a website and capturing screenshots for each.
- The tool also supports multiple browsers (Chromium, Firefox, WebKit) and presets for desktop/mobile devices.

##### Analyzing the File Structure
- Top-Level Files & Configurations: Files such as .eslintrc.json, .prettierrc, package.json, tsconfig.json, and vitest.config.ts show that the project follows strict code style, type safety, and testing conventions.
- Directories:
- The src directory contains the core code. The main entry (src/index.ts) and test files (e.g., src/link-extraction.test.ts, src/utils.test.ts) indicate that key functionalities (like link extraction and utility operations) are modularized.
- The static folder likely holds any additional assets (e.g., images, templates – though for a CLI tool these might be rare).
- The .github directory with workflows shows that CI/CD is automated, running tests, linting, and npm publishing.

##### Relationships and Data Flow
- From CLI “crawl-n-snap command” → Argument Parser → Core Engine.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% CLI Layer
    subgraph "CLI Layer"
        cli["CLI (crawl-n-snap command)"]:::internal
        parser["Command Argument Parser"]:::internal
    end

    %% Core Processing
    subgraph "Core Processing"
        engine["Core Engine"]:::internal
        screenshot["Screenshot Manager"]:::internal
        crawler["Web Crawler (optional)"]:::internal
        output["Output/Storage Handler"]:::internal
    end

    %% External Dependencies
    subgraph "External Dependencies"
        playwright["Playwright API"]:::external
        browsers["Browser Binaries (Chromium,Firefox,WebKit)"]:::external
    end

    %% Development Tools
    subgraph "Development Tools"
        cicd["CI/CD Pipeline"]:::ci
        testing["Testing (Vitest)"]:::ci
        quality["Code Quality Tools"]:::ci
    end

    %% Connections: CLI to Core
    cli -->|"parses"| parser
    parser -->|"delegates to"| engine

    %% Core branching
    engine -->|"orchestrates"| screenshot
    engine -->|"orchestrates"| crawler
    engine -->|"manages"| output

    %% External Integration
    screenshot -->|"calls API"| playwright
    crawler -->|"calls API"| playwright
    playwright -->|"launches"| browsers

    %% Development interlinks
    cicd -->|"triggers tests/lint"| engine
    testing -->|"validates"| engine
    quality -->|"ensures standards"| engine

    %% Click Events
    click cli "https://github.com/rosbel/crawl-n-snap/blob/main/src/index.ts"
    click parser "https://github.com/rosbel/crawl-n-snap/blob/main/src/index.ts"
    click engine "https://github.com/rosbel/crawl-n-snap/blob/main/src/index.ts"
    click screenshot "https://github.com/rosbel/crawl-n-snap/blob/main/src/utils.ts"
    click crawler "https://github.com/rosbel/crawl-n-snap/blob/main/src/link-extraction.test.ts"
    click output "https://github.com/rosbel/crawl-n-snap/blob/main/src/index.ts"
    click cicd "https://github.com/rosbel/crawl-n-snap/tree/main/.github/workflows"
    click testing "https://github.com/rosbel/crawl-n-snap/blob/main/vitest.config.ts"
    click quality "https://github.com/rosbel/crawl-n-snap/blob/main/.eslintrc.json"

    %% Styles
    classDef internal fill:#BEE3F8,stroke:#2C5282,stroke-width:2px;
    classDef external fill:#FBD38D,stroke:#D69E2E,stroke-width:2px;
    classDef ci fill:#C6F6D5,stroke:#38A169,stroke-width:2px;
```
