# arturovaine/airflow-web-scraper-etl architecture

> Architecture diagram of the GitHub repository arturovaine/airflow-web-scraper-etl, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-04-08). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/arturovaine/airflow-web-scraper-etl
- Repository: https://github.com/arturovaine/airflow-web-scraper-etl

## Overview

##### Main Components
- Docker Compose Container Environment: Emphasize that Docker Compose orchestrates several containers.
- Apache Airflow Container: This includes the Airflow Scheduler, Web Server (UI), and Worker(s) as necessary. This container runs the DAGs from the dags/ directory.
- PostgreSQL Container: Dedicated to storing the scraped data (quotes) and accessed by Airflow during the load step.
- (Optional) Additional Auxiliary Containers: If the project were to expand, you might have separate containers (for logging or custom plugins) but here note that directories like logs/ and plugins/ provide support to the Airflow setup rather than separate services.
- Host/Local Machine: Although many components run in containers, note that the bootstrapping is initiated by a shell script (create_airflow_scraper_project.sh) that sets up the environment.

##### Relationships and Data Flow
- A feedback loop where the Airflow UI provides monitoring and trigger capabilities for the ETL process.

##### Architectural Patterns and Design Principles
- Decoupled services: Airflow and PostgreSQL communicate through network links defined in Docker Compose, which encourages modularity and separation of concerns.
- ETL Flow: Illustrate the “Extract-Transform-Load” process by labeling the DAG’s stages (extracting data with BeautifulSoup, transforming it as needed, and loading it into PostgreSQL).

##### Relevant Technologies and Their Roles
- Apache Airflow: Manages scheduling, execution, and monitoring of the ETL DAG.
- Docker & Docker Compose: Used to containerize all components, ensuring environment consistency.
- PostgreSQL: Serves as the data storage back end.
- BeautifulSoup: The Python library used for scraping data from web pages.
- Shell Script (create_airflow_scraper_project.sh): Bootstraps the environment setup and container deployment.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Host Setup
    subgraph "Host Setup"
        HS_Shell["Bootstrapping Script"]:::host
        HS_Readme["Project Documentation"]:::host
    end

    %% Docker Compose Environment
    subgraph "Docker Compose Environment"
        subgraph "Airflow Container"
            A_Scheduler["Airflow Scheduler"]:::airflow
            A_WebUI["Airflow Web UI"]:::airflow
            A_Worker["Airflow Worker"]:::airflow
            ETL_DAG["ETL DAG - etl_web_scraper"]:::dag
        end
        subgraph "PostgreSQL Container"
            PostgreSQL["PostgreSQL Database"]:::database
        end
    end

    %% External Process for Web Scraping
    WebScraper["Web Scraper (BeautifulSoup)"]:::dag

    %% Connections
    HS_Shell -->|"deploys"| A_Scheduler
    A_Scheduler -->|"schedules"| ETL_DAG
    A_WebUI -->|"monitors"| ETL_DAG
    ETL_DAG -->|"extracts"| WebScraper
    WebScraper ---|"returnsData"| ETL_DAG
    ETL_DAG -->|"loads"| PostgreSQL

    %% Click Events
    click HS_Shell "https://github.com/arturovaine/airflow-web-scraper-etl/blob/main/create_airflow_scraper_project.sh"
    click HS_Readme "https://github.com/arturovaine/airflow-web-scraper-etl/blob/main/README.md"

    %% Styles
    classDef host fill:#f2f2f2,stroke:#333,stroke-width:2px;
    classDef airflow fill:#a3e4d7,stroke:#27ae60,stroke-width:2px;
    classDef dag fill:#f9e79f,stroke:#f1c40f,stroke-width:2px;
    classDef database fill:#aed6f1,stroke:#2980b9,stroke-width:2px;
```
