# zachrattner/scourhead architecture

> Architecture diagram of the GitHub repository zachrattner/scourhead, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-02-01). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/zachrattner/scourhead
- Repository: https://github.com/zachrattner/scourhead

## Overview

##### Main Components

a. User Interface Layer (Electron App)
- Main window components (setup-*.html files)
- Debug logging interface (debug-log.html)
- CSS theming system

b. Core Processing Layer
- Project Management
- Search Query Generation
- Browser Automation
- LLM Integration
- Data Extraction
- Export Functionality

c. External Services Integration
- Search Providers (Google, Bing, DuckDuckGo)
- Ollama LLM Service
- Playwright Browser Automation

**┌─ User Interface Layer ─────────────────────┐**
- ┌─────────┐ ┌─────────┐ ┌─────────────┐   │
- Setup UI │ │Debug UI │ │Results View │   │
- ┘ └─────────┘ └─────────────┘   │
- Core Processing Layer ───────────────────┐│
- ┌─────────┐ ┌─────────┐ ┌─────────────┐  │
- Project  │ │Search   │ │Data         │  │
- Manager  │ │Engine   │ │Processor    │  │
- ┘ └─────────┘ └─────────────┘  │
- Service Integration Layer ───────────────┤│
- ┌─────────┐ ┌─────────┐ ┌─────────────┐  │
- Search   │ │Ollama   │ │Playwright   │  │
- Providers│ │LLM      │ │Browser      │  │
- ┘ └─────────┘ └─────────────┘  │
- ┘

##### Key Relationships to Highlight

a. Data Flow
- User input → Query Generation → Search Execution
- Search Results → LLM Processing → Structured Data
- Structured Data → CSV Export

b. Service Integration
- Core → Search Providers
- Core → Ollama LLM
- Core → Playwright Browser

##### Important Implementation Details

- Separation between main process (src/main.ts) and renderer processes
- Role of preload scripts (src/preload.ts)
- File storage system for .scour files
- Stages pipeline from the src/util/stages directory

##### Technical Stack Indicators

- Electron
- TypeScript
- Playwright
- Ollama/Llama 3.2
- HTML/CSS

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Styles
    classDef ui fill:#3498db,stroke:#2980b9,color:white
    classDef core fill:#2ecc71,stroke:#27ae60,color:white
    classDef service fill:#e67e22,stroke:#d35400,color:white
    classDef config fill:#9b59b6,stroke:#8e44ad,color:white
    classDef test fill:#95a5a6,stroke:#7f8c8d,color:white

    %% User Interface Layer
    subgraph UI[User Interface Layer]
        MainWindow["Main Window Components"]
        DebugUI["Debug Interface"]
        ResultsView["Results View"]
        ThemeSystem["Theming System"]
    end

    %% Core Processing Layer
    subgraph Core[Core Processing Layer]
        MainProcess["Main Process"]
        PreloadScript["Preload Script"]
        ProjectMgr["Project Manager"]
        SearchEngine["Search Engine"]
        DataProcessor["Data Processor"]
        PipelineStages["Pipeline Stages"]
        Config["Configuration"]
    end

    %% Service Integration Layer
    subgraph Services[Service Integration Layer]
        SearchProviders["Search Providers"]
        OllamaLLM["Ollama LLM"]
        PlaywrightBrowser["Playwright Browser"]
    end

    %% Testing Layer
    subgraph Testing[Testing Infrastructure]
        CoreTests["Core Tests"]
        BuildConfig["Build Configuration"]
        PackageConfig["Package Configuration"]
    end

    %% Relationships
    MainWindow --> PreloadScript
    DebugUI --> PreloadScript
    PreloadScript --> MainProcess
    MainProcess --> ProjectMgr
    ProjectMgr --> SearchEngine
    SearchEngine --> SearchProviders
    SearchEngine --> PlaywrightBrowser
    DataProcessor --> OllamaLLM
    PipelineStages --> DataProcessor
    Config --> MainProcess

    %% Click Events
    click MainWindow "https://github.com/zachrattner/scourhead/blob/main/src/setup-*.html"
    click DebugUI "https://github.com/zachrattner/scourhead/blob/main/src/debug-log.html"
    click ThemeSystem "https://github.com/zachrattner/scourhead/tree/main/src/css/"
    click ProjectMgr "https://github.com/zachrattner/scourhead/blob/main/src/util/scourFileUtils.ts"
    click SearchEngine "https://github.com/zachrattner/scourhead/blob/main/src/util/stages/generateQueries.ts"
    click DataProcessor "https://github.com/zachrattner/scourhead/blob/main/src/util/extractHtml.ts"
    click PipelineStages "https://github.com/zachrattner/scourhead/tree/main/src/util/stages/"
    click SearchProviders "https://github.com/zachrattner/scourhead/tree/main/src/util/searchProviders/"
    click OllamaLLM "https://github.com/zachrattner/scourhead/blob/main/src/util/llmProviders/ollama.ts"
    click PlaywrightBrowser "https://github.com/zachrattner/scourhead/blob/main/src/util/stealthifyPlaywright.ts"
    click MainProcess "https://github.com/zachrattner/scourhead/blob/main/src/main.ts"
    click PreloadScript "https://github.com/zachrattner/scourhead/blob/main/src/preload.ts"
    click Config "https://github.com/zachrattner/scourhead/blob/main/src/util/preferences.ts"
    click CoreTests "https://github.com/zachrattner/scourhead/tree/main/src/tests/"
    click BuildConfig "https://github.com/zachrattner/scourhead/blob/main/tsconfig.json"
    click PackageConfig "https://github.com/zachrattner/scourhead/blob/main/package.json"

    %% Style Applications
    class MainWindow,DebugUI,ResultsView,ThemeSystem ui
    class MainProcess,PreloadScript,ProjectMgr,SearchEngine,DataProcessor,PipelineStages,Config core
    class SearchProviders,OllamaLLM,PlaywrightBrowser service
    class CoreTests,BuildConfig,PackageConfig test
```
