# sarusadgac/google-trends-data-fetcher architecture

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

- Interactive diagram: https://gitdiagram.com/sarusadgac/google-trends-data-fetcher
- Repository: https://github.com/sarusadgac/google-trends-data-fetcher

## Overview

##### Main Components

a. Data Collection Layer
- Google Trends API Interface
- Data Fetcher Service (main.py)
- Country-specific handlers (countries.py)
- Flag data handler (flags.py)

b. Storage Layer
- JSON Data Store (json_data directory)
- Text Data Store (text_data directory)

c. Presentation Layer
- HTML Generator (generate_html.py)
- Web Interface (index.html)

d. Automation Layer
- GitHub Actions Workflow (.github/workflows/main.yml)

##### Component Relationships

**[GitHub Actions Workflow]**
- ↓
**[Data Collection Layer]**
- ↙           ↘
**[JSON Store]  [Text Store]**
- ↘           ↙
**[HTML Generator]**
- ↓
**[Web Interface]**

##### Important Details

a. Data Flow Annotations:
- Periodic data collection (timing from GitHub Actions)
- Data transformation paths
- Storage write/read operations

b. Component Descriptions:
- Country-specific data collection
- Flag integration
- Data format transformations (JSON/Text)
- HTML generation process

##### Technical Specifications

- File formats (JSON, TXT, HTML)
- Update frequency
- Number of supported countries (51)
- Data types collected (search trends)

##### Integration Points

External service connections:
- Google Trends API
- Flag CDN (flagcdn.com)
- GitHub Pages (if used for hosting)

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph "Automation Layer"
        GHA["GitHub Actions Workflow"]
    end

    subgraph "Data Collection Layer"
        DC["Data Fetcher"]
        CH["Country Handlers"]
        FH["Flag Handler"]
        GT["Google Trends API"]
    end

    subgraph "Storage Layer"
        JS[("JSON Store")]
        TS[("Text Store")]
    end

    subgraph "Presentation Layer"
        HG["HTML Generator"]
        WI["Web Interface"]
    end

    %% Relationships
    GHA --> DC
    DC --> CH
    DC --> FH
    CH --> GT
    CH --> JS
    CH --> TS
    FH --> HG
    JS --> HG
    TS --> HG
    HG --> WI

    %% Click Events
    click GHA "https://github.com/sarusadgac/Google-Trends-Data-Fetcher/blob/main//.github/workflows/main.yml"
    click DC "https://github.com/sarusadgac/Google-Trends-Data-Fetcher/blob/main/main.py"
    click CH "https://github.com/sarusadgac/Google-Trends-Data-Fetcher/blob/main/countries.py"
    click FH "https://github.com/sarusadgac/Google-Trends-Data-Fetcher/blob/main/flags.py"
    click JS "https://github.com/sarusadgac/Google-Trends-Data-Fetcher/tree/main//json_data/"
    click TS "https://github.com/sarusadgac/Google-Trends-Data-Fetcher/tree/main//text_data/"
    click HG "https://github.com/sarusadgac/Google-Trends-Data-Fetcher/blob/main/generate_html.py"
    click WI "https://github.com/sarusadgac/Google-Trends-Data-Fetcher/blob/main/index.html"

    %% Styling
    classDef automation fill:#f4f4f4,stroke:#333
    classDef collection fill:#dae8fc,stroke:#6c8ebf
    classDef storage fill:#d5e8d4,stroke:#82b366
    classDef presentation fill:#ffe6cc,stroke:#d79b00
    classDef api fill:#f8cecc,stroke:#b85450

    class GHA automation
    class DC,CH,FH collection
    class JS,TS storage
    class HG,WI presentation
    class GT api

    %% Legend
    subgraph Legend
        L1["Automation Component"]:::automation
        L2["Data Collection Component"]:::collection
        L3[("Storage Component")]:::storage
        L4["Presentation Component"]:::presentation
        L5["External API"]:::api
    end
```
