# itu-helper/data-updater architecture

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

- Interactive diagram: https://gitdiagram.com/itu-helper/data-updater
- Repository: https://github.com/itu-helper/data-updater

## Overview

##### Main Components

a) Data Collection Layer:
- Various scrapers as individual components:
- Lesson Scraper
- Course Scraper
- Course Plan Scraper
- Misc Scraper (Building and program codes)
- Driver Manager component that handles web automation

b) Automation Layer:
- GitHub Actions Workflows (show as a separate component)
- Different scheduling patterns:
- 15-minute intervals for lessons
- Weekly schedules for courses and course plans
- Daily misc updates

c) Data Storage Layer:
- GitHub Repository (itu-helper/data)
- Data organization structure

d) Integration Points:
- Connection to ITU websites (data source)
- Connection to itu-helper/sdk (data consumer)

##### Component Relationships

- Data flow from ITU websites to scrapers
- Workflow triggers between GitHub Actions and scrapers
- Data storage flow to the data repository
- Integration with the SDK

##### Technical Details

- Python-based scraping system
- GitHub Actions scheduling system
- Data update frequencies
- File naming conventions

**[External Sources]**
- ↓
**[Automation Layer (GitHub Actions)] ←→ [Scheduling System]**
- ↓
**[Scraping Layer]**
- Lesson Scraper
- Course Scraper
- Course Plan Scraper
- Misc Scraper
- ↓
**[Driver Manager]**
- ↓
**[Data Storage]**
- ↓
**[Data Consumers]**

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Styles and classes
    classDef external fill:#3498db,stroke:#2980b9,color:white
    classDef scraper fill:#2ecc71,stroke:#27ae60,color:white
    classDef automation fill:#f1c40f,stroke:#f39c12,color:black
    classDef storage fill:#9b59b6,stroke:#8e44ad,color:white
    classDef consumer fill:#e67e22,stroke:#d35400,color:white
    classDef manager fill:#1abc9c,stroke:#16a085,color:white

    %% External Data Sources
    ITU[ITU Websites]:::external

    %% Automation Layer
    subgraph Automation
        GHA[GitHub Actions]
        Schedules[Scheduling System]
        GHA <--> Schedules
    end

    %% Workflows
    subgraph Workflows
        W1["15min Lesson Updates"]
        W2["Weekly Course Updates"]
        W3["Weekly Course Plan Updates"]
        W4["Daily Misc Updates"]
        W5["System Keep-Alive"]
    end

    %% Scraping Layer
    subgraph Scrapers
        direction TB
        BS["Base Scraper"]
        LS["Lesson Scraper"]
        CS["Course Scraper"]
        CPS["Course Plan Scraper"]
        MS["Misc Scraper"]
        BS --> LS
        BS --> CS
        BS --> CPS
        BS --> MS
    end

    %% Infrastructure Components
    DM["Driver Manager"]:::manager
    Config["Configuration System"]
    Logger["Logging System"]
    Runner["Main Execution Entry"]

    %% Storage and Consumers
    DataRepo["GitHub Repository\n(itu-helper/data)"]:::storage
    SDK["itu-helper/sdk"]:::consumer

    %% Relationships
    ITU --> Automation
    Automation --> Runner
    Runner --> Scrapers
    Scrapers --> DM
    DM --> DataRepo
    DataRepo --> SDK

    %% Component Mappings
    click LS "https://github.com/itu-helper/data-updater/blob/main/src/lesson_scraper.py"
    click CS "https://github.com/itu-helper/data-updater/blob/main/src/course_scraper.py"
    click CPS "https://github.com/itu-helper/data-updater/blob/main/src/course_plan_scraper.py"
    click MS "https://github.com/itu-helper/data-updater/blob/main/src/misc_scraper.py"
    click DM "https://github.com/itu-helper/data-updater/blob/main/src/driver_manager.py"
    click BS "https://github.com/itu-helper/data-updater/blob/main/src/scraper.py"
    click Config "https://github.com/itu-helper/data-updater/blob/main/src/constants.py"
    click Logger "https://github.com/itu-helper/data-updater/blob/main/src/logger.py"
    click W1 "https://github.com/itu-helper/data-updater/blob/main/.github/workflows/refresh_lessons.yml"
    click W2 "https://github.com/itu-helper/data-updater/blob/main/.github/workflows/refresh_courses.yml"
    click W3 "https://github.com/itu-helper/data-updater/blob/main/.github/workflows/refresh_course_plans.yml"
    click W4 "https://github.com/itu-helper/data-updater/blob/main/.github/workflows/refresh_misc.yml"
    click W5 "https://github.com/itu-helper/data-updater/blob/main/.github/workflows/keep_alive.yaml"
    click Runner "https://github.com/itu-helper/data-updater/blob/main/src/run.py"
```
