# edilsonathayde/covid19-data-engineering architecture

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

- Interactive diagram: https://gitdiagram.com/edilsonathayde/covid19-data-engineering
- Repository: https://github.com/edilsonathayde/covid19-data-engineering

## Overview

##### Project Type and Purpose
- This is a data engineering project implementing an ETL pipeline in Python + Spark, deployed on Databricks.
- Purpose: extract public COVID-19 data, process it through Medallion layers (RAW → Bronze → Silver → Gold), and make it available for analysis/visualization.

##### High-Level Components
a. Data Sources
- COVID-19 Open Data CSV (external URL)
b. Compute & Orchestration
- Databricks Workspace & Spark Cluster
- Python modules + Notebooks (src/utils/functions.py, src/etl/extract.py, notebooks/*.ipynb)
c. Storage Layers (Delta Lake on DBFS or Cloud Storage)
- RAW (original CSV)
- Bronze (Delta format, minimal structuring)
- Silver (cleansed & normalized)
- Gold (aggregated metrics)
d. Configuration & Environment
- config/configs.py (paths, environment variables)
- config/spark_session.py (Spark session builder)
e. Consumers & Visualization
- Notebook analyses (EDA graphs in images/)
- Downstream dashboards or BI tools (implicit)

##### Relationships & Data Flow
1. External CSV URL → Extraction function (`download_file_from_url`)
2. Extraction → RAW storage
3. RAW → Transformation step (Bronze conversion)
4. Bronze → Transformation step (Silver cleaning)
5. Silver → Transformation step (Gold aggregation)
6. Gold → Notebook analyses & dashboards
- Configuration injecting into extraction/transformation modules (config blocks feeding paths and Spark settings).

##### Architectural Patterns & Design Principles
- Medallion Architecture: clearly separate layers and annotate each with its purpose (backup, structuring, cleaning, aggregation).
- Modular code: `src/utils/functions.py` holds generic file & transform helpers, `src/etl/extract.py` holds extraction logic.
- Infrastructure as code: configs separate from business logic; Spark session builder decouples environment setup.

##### Technologies, Frameworks & Libraries
- Python 3.x
- Apache Spark on Databricks
- Delta Lake format for ACID transactions
- PyPI libraries from requirements.txt (e.g., pandas, requests)
- Databricks File System (DBFS) or cloud storage under the hood

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% External Source
    CSV["COVID-19 Open Data CSV"]:::external

    %% Configuration & Dependencies
    Configs["Pipeline Configuration\n(config/configs.py)"]:::config
    SparkSession["Spark Session Builder\n(config/spark_session.py)"]:::config
    Dependencies["Project Dependencies\n(requirements.txt)"]:::config
    Readme["Project README\n(README.md)"]:::config

    %% Compute & Orchestration
    subgraph "Databricks/Spark Cluster"
        direction TB
        ExtractModule["Extraction Module"]:::compute
        Functions["Utility Functions"]:::compute
        FileOps["File Helpers"]:::compute
        Notebook1["01_Data Extraction Notebook"]:::notebook
        Notebook2["02_Bronze Transformation Notebook"]:::notebook
        Notebook3["02_Silver Transformation Notebook"]:::notebook
        Notebook4["03_Gold Transformation Notebook"]:::notebook
    end

    %% Storage Layers
    RawStorage(("RAW Layer\nDelta Table")):::raw
    BronzeStorage(("Bronze Layer\nDelta Table")):::bronze
    SilverStorage(("Silver Layer\nDelta Table")):::silver
    GoldStorage(("Gold Layer\nDelta Table")):::gold

    %% Analysis & Visualization
    Notebook5["04_Additional Analysis Notebook"]:::notebook
    Notebook6["05_Additional Analysis Notebook"]:::notebook
    Images["EDA & Visualization Assets"]:::assets

    %% Data Flow & Dependencies
    CSV -->|"download_file_from_url"| Notebook1
    Notebook1 -->|"write raw"| RawStorage
    RawStorage -->|"convert to Delta"| Notebook2
    Notebook2 -->|"write bronze"| BronzeStorage
    BronzeStorage -->|"clean & normalize"| Notebook3
    Notebook3 -->|"write silver"| SilverStorage
    SilverStorage -->|"aggregate metrics"| Notebook4
    Notebook4 -->|"write gold"| GoldStorage
    GoldStorage -->|"analysis input"| Notebook5
    GoldStorage -->|"analysis input"| Notebook6
    Notebook5 -->|"output visuals"| Images
    Notebook6 -->|"output visuals"| Images

    %% Config & Session Injection
    Configs --> ExtractModule
    Configs --> Notebook1
    Configs --> Notebook2
    Configs --> Notebook3
    Configs --> Notebook4
    SparkSession --> ExtractModule
    SparkSession --> Notebook1
    SparkSession --> Notebook2
    SparkSession --> Notebook3
    SparkSession --> Notebook4

    %% Util Functions Usage
    Functions --> ExtractModule
    FileOps --> ExtractModule

    %% Click Events
    click ExtractModule "https://github.com/edilsonathayde/covid19-data-engineering/blob/main/src/etl/extract.py"
    click Functions "https://github.com/edilsonathayde/covid19-data-engineering/blob/main/src/utils/functions.py"
    click FileOps "https://github.com/edilsonathayde/covid19-data-engineering/blob/main/src/utils/file_operations.py"
    click SparkSession "https://github.com/edilsonathayde/covid19-data-engineering/blob/main/config/spark_session.py"
    click Configs "https://github.com/edilsonathayde/covid19-data-engineering/blob/main/config/configs.py"
    click Notebook1 "https://github.com/edilsonathayde/covid19-data-engineering/blob/main/notebooks/01_data_extraction.ipynb"
    click Notebook2 "https://github.com/edilsonathayde/covid19-data-engineering/blob/main/notebooks/02_data_transformation_to_bronze.ipynb"
    click Notebook3 "https://github.com/edilsonathayde/covid19-data-engineering/blob/main/notebooks/02_data_transformation_to_silver.ipynb"
    click Notebook4 "https://github.com/edilsonathayde/covid19-data-engineering/blob/main/notebooks/03_data_transformation_to_gold.ipynb"
    click Notebook5 "https://github.com/edilsonathayde/covid19-data-engineering/blob/main/notebooks/04_Data.ipynb"
    click Notebook6 "https://github.com/edilsonathayde/covid19-data-engineering/blob/main/notebooks/05_DE.ipynb"
    click Images "https://github.com/edilsonathayde/covid19-data-engineering/tree/main/images/"
    click Dependencies "https://github.com/edilsonathayde/covid19-data-engineering/blob/main/requirements.txt"
    click Readme "https://github.com/edilsonathayde/covid19-data-engineering/blob/main/README.md"

    %% Styles
    classDef external fill:#BBDEFB,stroke:#1E88E5,color:#000
    classDef compute fill:#C8E6C9,stroke:#388E3C,color:#000
    classDef config fill:#FFE0B2,stroke:#FB8C00,color:#000
    classDef raw fill:#FFF9C4,stroke:#F9A825,color:#000
    classDef bronze fill:#FFE082,stroke:#F57C00,color:#000
    classDef silver fill:#E0F7FA,stroke:#0097A7,color:#000
    classDef gold fill:#FFF3E0,stroke:#FFB300,color:#000
    classDef notebook fill:#E1BEE7,stroke:#8E24AA,color:#000
    classDef assets fill:#D1C4E9,stroke:#7E57C2,color:#000
```
