# ahmedaliali811/covid19_data_engineering_project architecture

> Architecture diagram of the GitHub repository ahmedaliali811/covid19_data_engineering_project, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-07-22). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/ahmedaliali811/covid19_data_engineering_project
- Repository: https://github.com/ahmedaliali811/covid19_data_engineering_project

## Overview

#### Purpose and Entry Points
This repository implements a Dockerized COVID-19 ELT warehouse: retrieve Johns Hopkins daily CSV reports, ingest them into PostgreSQL, transform them with dbt, and expose marts to Power BI. The operational entry point is the Airflow DAG at `docker/airflow/dags/covid_pipline.py`; local service topology is defined in `docker-compose.yaml`. The reporting consumer is `Dashboard/covid19-dashboard.pbix`.

#### 1. Extraction Boundary
Python extraction code discovers and downloads daily-report CSVs from the external Johns Hopkins GitHub dataset. The main extraction boundary is `extract_files/main.py`, with GitHub/API access isolated in `extract_files/github_client.py` and download behavior in `extract_files/download_file.py`. Downloaded files are persisted as local raw snapshots under `Data/raw_data/`, separating external-source availability from warehouse loading.

#### 2. Raw Ingestion and Metadata
The loader reads downloaded CSVs, standardizes input columns, and writes source-shaped records to PostgreSQL’s `raw` schema. Its executable flow is rooted at `load_data/main.py`, with database access in `load_data/db.py` and load logic in `load_data/loader.py`. Database bootstrap creates warehouse schemas, raw tables, and pipeline metadata structures through `docker/postgres/init/01_create_schemas.sql`, `02_create_raw_tables.sql`, and `03_create_metdata_tables.sql`.

#### 3. Airflow Orchestration
`docker/airflow/dags/covid_pipline.py` coordinates the pipeline in ordered task groups: extraction, raw loading, then dbt seed/run/test. Airflow is the control-plane boundary: it invokes Python ingestion components and dbt commands rather than embedding transformation SQL in orchestration code. Pipeline execution and monitoring occur through the Airflow container/UI.

#### 4. dbt Staging Layer
dbt declares PostgreSQL raw inputs in `dbt/models/staging/sources.yml` and converts raw records into a stable staging contract in `dbt/models/staging/stg_covid_cases.sql`. This is the principal boundary between ingestion variability and warehouse transformations: types, names, null handling, and initial validation are centralized before downstream business models consume the data.

#### 5. Intermediate Standardization
`dbt/models/intermediate/int_covid_cases_clean.sql` applies business-oriented cleaning and enrichment. It uses the country mapping seed at `dbt/seeds/country_mapping.csv` to normalize country identities, preventing source naming variations from propagating into dimensions, facts, and reporting aggregates.

#### 6. Mart and Reporting Models
The mart layer forms a star-schema-oriented analytics contract: `dbt/models/marts/dim_date.sql` and `dim_country.sql` provide shared dimensions, while `fct_covid_daily.sql` stores daily COVID measures. Reporting-ready aggregates are supplied by `dbt/models/marts/country_summary.sql` and `monthly_results.sql`. Model and source tests are declared alongside layers in `dbt/models/marts/schema.yml` and `dbt/models/intermediate/schema.yml`.

#### 7. Runtime, Infrastructure, and Consumers
Docker Compose provides the material runtime for PostgreSQL 16, Airflow 3.2, and dbt 1.9 via `docker-compose.yaml`; dbt project behavior and connection profile are in `dbt/dbt_project.yml` and `dbt/profiles.yml`. PostgreSQL is the durable warehouse boundary, while Power BI consumes the final mart/reporting tables through `Dashboard/covid19-dashboard.pbix`. The only identified external data service is the Johns Hopkins GitHub repository accessed by the extractor.

Main entry points: [`docker/airflow/dags/covid_pipline.py`](https://github.com/ahmedaliali811/covid19_data_engineering_project/blob/main/docker/airflow/dags/covid_pipline.py) (COVID pipeline DAG), [`load_data/main.py`](https://github.com/ahmedaliali811/covid19_data_engineering_project/blob/main/load_data/main.py) (Raw loader), [`docker/postgres/init/01_create_schemas.sql`](https://github.com/ahmedaliali811/covid19_data_engineering_project/blob/main/docker/postgres/init/01_create_schemas.sql) (Warehouse bootstrap), [`extract_files/main.py`](https://github.com/ahmedaliali811/covid19_data_engineering_project/blob/main/extract_files/main.py) (CSV extractor)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_source["External source"]
  node_johns_hopkins[("Johns Hopkins daily reports<br/>external dataset")]
end

subgraph group_ingestion["Ingestion"]
  node_extractor["CSV extractor<br/>Python job<br/>[main.py]"]
  node_github_client["GitHub client<br/>source adapter<br/>[github_client.py]"]
  node_downloader["File downloader<br/>download adapter<br/>[download_file.py]"]
  node_raw_snapshots["Raw CSV snapshots<br/>local storage"]
  node_loader["Raw loader<br/>Python job<br/>[main.py]"]
  node_load_logic["Load logic<br/>loader module<br/>[loader.py]"]
end

subgraph group_orchestration["Orchestration &amp; runtime"]
  node_airflow_dag{{"COVID pipeline DAG<br/>Airflow DAG<br/>[covid_pipline.py]"}}
  node_compose["Docker Compose runtime<br/>container topology"]
end

subgraph group_warehouse["PostgreSQL warehouse"]
  node_bootstrap["Warehouse bootstrap<br/>SQL initialization"]
  node_raw_schema[("Raw schema<br/>PostgreSQL schema")]
  node_pipeline_metadata["Pipeline metadata<br/>PostgreSQL schema"]
end

subgraph group_dbt["dbt transformations"]
  node_staging["Staging contract<br/>dbt staging model"]
  node_raw_sources["Raw source declarations<br/>dbt sources<br/>[sources.yml]"]
  node_country_mapping["Country mapping<br/>dbt seed"]
  node_clean_cases["Clean COVID cases<br/>dbt intermediate model"]
  node_mart_schema[("Analytics marts<br/>dbt mart models")]
end

subgraph group_reporting["Reporting"]
  node_power_bi["COVID-19 dashboard<br/>Power BI report"]
end

node_johns_hopkins -->|"accessed by"| node_github_client
node_github_client -->|"discovers reports"| node_extractor
node_extractor -->|"requests downloads"| node_downloader
node_downloader -->|"persists CSVs"| node_raw_snapshots
node_raw_snapshots -->|"read by"| node_loader
node_load_logic -->|"used by"| node_loader
node_loader -->|"loads records"| node_raw_schema
node_bootstrap -->|"creates"| node_raw_schema
node_bootstrap -->|"creates"| node_pipeline_metadata
node_compose -->|"runs"| node_airflow_dag
node_compose -->|"initializes"| node_bootstrap
node_airflow_dag -->|"orchestrates"| node_extractor
node_airflow_dag -->|"orchestrates"| node_loader
node_airflow_dag -->|"runs dbt"| node_staging
node_raw_schema -->|"declared as"| node_raw_sources
node_raw_sources -->|"feeds"| node_staging
node_staging -->|"standardizes into"| node_clean_cases
node_country_mapping -->|"normalizes countries"| node_clean_cases
node_clean_cases -->|"builds"| node_mart_schema
node_mart_schema -->|"consumed by"| node_power_bi

click node_extractor "https://github.com/ahmedaliali811/covid19_data_engineering_project/blob/main/extract_files/main.py"
click node_github_client "https://github.com/ahmedaliali811/covid19_data_engineering_project/blob/main/extract_files/github_client.py"
click node_downloader "https://github.com/ahmedaliali811/covid19_data_engineering_project/blob/main/extract_files/download_file.py"
click node_raw_snapshots "https://github.com/ahmedaliali811/covid19_data_engineering_project/tree/main/Data/raw_data"
click node_loader "https://github.com/ahmedaliali811/covid19_data_engineering_project/blob/main/load_data/main.py"
click node_load_logic "https://github.com/ahmedaliali811/covid19_data_engineering_project/blob/main/load_data/loader.py"
click node_airflow_dag "https://github.com/ahmedaliali811/covid19_data_engineering_project/blob/main/docker/airflow/dags/covid_pipline.py"
click node_compose "https://github.com/ahmedaliali811/covid19_data_engineering_project/blob/main/docker-compose.yaml"
click node_bootstrap "https://github.com/ahmedaliali811/covid19_data_engineering_project/blob/main/docker/postgres/init/01_create_schemas.sql"
click node_raw_schema "https://github.com/ahmedaliali811/covid19_data_engineering_project/blob/main/docker/postgres/init/02_create_raw_tables.sql"
click node_pipeline_metadata "https://github.com/ahmedaliali811/covid19_data_engineering_project/blob/main/docker/postgres/init/03_create_metdata_tables.sql"
click node_staging "https://github.com/ahmedaliali811/covid19_data_engineering_project/blob/main/dbt/models/staging/stg_covid_cases.sql"
click node_raw_sources "https://github.com/ahmedaliali811/covid19_data_engineering_project/blob/main/dbt/models/staging/sources.yml"
click node_country_mapping "https://github.com/ahmedaliali811/covid19_data_engineering_project/blob/main/dbt/seeds/country_mapping.csv"
click node_clean_cases "https://github.com/ahmedaliali811/covid19_data_engineering_project/blob/main/dbt/models/intermediate/int_covid_cases_clean.sql"
click node_mart_schema "https://github.com/ahmedaliali811/covid19_data_engineering_project/blob/main/dbt/models/marts/fct_covid_daily.sql"
click node_power_bi "https://github.com/ahmedaliali811/covid19_data_engineering_project/blob/main/Dashboard/covid19-dashboard.pbix"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_johns_hopkins toneBlue
class node_extractor,node_github_client,node_downloader,node_raw_snapshots,node_loader,node_load_logic toneAmber
class node_airflow_dag,node_compose toneMint
class node_bootstrap,node_raw_schema,node_pipeline_metadata toneRose
class node_staging,node_raw_sources,node_country_mapping,node_clean_cases,node_mart_schema toneIndigo
class node_power_bi toneTeal
```

## Components

### External source

- **Johns Hopkins daily reports**: external dataset

### Ingestion

- [CSV extractor](https://github.com/ahmedaliali811/covid19_data_engineering_project/blob/main/extract_files/main.py): Python job · Discovers and downloads daily report CSVs. · `extract_files/main.py`
- [GitHub client](https://github.com/ahmedaliali811/covid19_data_engineering_project/blob/main/extract_files/github_client.py): source adapter · `extract_files/github_client.py`
- [File downloader](https://github.com/ahmedaliali811/covid19_data_engineering_project/blob/main/extract_files/download_file.py): download adapter · `extract_files/download_file.py`
- [Raw CSV snapshots](https://github.com/ahmedaliali811/covid19_data_engineering_project/tree/main/Data/raw_data): local storage · Decouples source availability from warehouse loading. · `Data/raw_data`
- [Raw loader](https://github.com/ahmedaliali811/covid19_data_engineering_project/blob/main/load_data/main.py): Python job · Standardizes CSV columns and writes source-shaped records. · `load_data/main.py`
- [Load logic](https://github.com/ahmedaliali811/covid19_data_engineering_project/blob/main/load_data/loader.py): loader module · `load_data/loader.py`

### Orchestration & runtime

- [COVID pipeline DAG](https://github.com/ahmedaliali811/covid19_data_engineering_project/blob/main/docker/airflow/dags/covid_pipline.py): Airflow DAG · Orders extraction, raw loading, and dbt seed/run/test. · `docker/airflow/dags/covid_pipline.py`
- [Docker Compose runtime](https://github.com/ahmedaliali811/covid19_data_engineering_project/blob/main/docker-compose.yaml): container topology · Runs PostgreSQL, Airflow, and dbt. · `docker-compose.yaml`

### PostgreSQL warehouse

- [Warehouse bootstrap](https://github.com/ahmedaliali811/covid19_data_engineering_project/blob/main/docker/postgres/init/01_create_schemas.sql): SQL initialization · Creates schemas, raw tables, and pipeline metadata. · `docker/postgres/init/01_create_schemas.sql`
- [Raw schema](https://github.com/ahmedaliali811/covid19_data_engineering_project/blob/main/docker/postgres/init/02_create_raw_tables.sql): PostgreSQL schema · Source-shaped ingested records. · `docker/postgres/init/02_create_raw_tables.sql`
- [Pipeline metadata](https://github.com/ahmedaliali811/covid19_data_engineering_project/blob/main/docker/postgres/init/03_create_metdata_tables.sql): PostgreSQL schema · `docker/postgres/init/03_create_metdata_tables.sql`

### dbt transformations

- [Staging contract](https://github.com/ahmedaliali811/covid19_data_engineering_project/blob/main/dbt/models/staging/stg_covid_cases.sql): dbt staging model · Centralizes typing, naming, null handling, and initial validation. · `dbt/models/staging/stg_covid_cases.sql`
- [Raw source declarations](https://github.com/ahmedaliali811/covid19_data_engineering_project/blob/main/dbt/models/staging/sources.yml): dbt sources · `dbt/models/staging/sources.yml`
- [Country mapping](https://github.com/ahmedaliali811/covid19_data_engineering_project/blob/main/dbt/seeds/country_mapping.csv): dbt seed · `dbt/seeds/country_mapping.csv`
- [Clean COVID cases](https://github.com/ahmedaliali811/covid19_data_engineering_project/blob/main/dbt/models/intermediate/int_covid_cases_clean.sql): dbt intermediate model · Applies business cleaning and country enrichment. · `dbt/models/intermediate/int_covid_cases_clean.sql`
- [Analytics marts](https://github.com/ahmedaliali811/covid19_data_engineering_project/blob/main/dbt/models/marts/fct_covid_daily.sql): dbt mart models · Dimensions, daily fact, country summary, and monthly aggregates. · `dbt/models/marts/fct_covid_daily.sql`

### Reporting

- [COVID-19 dashboard](https://github.com/ahmedaliali811/covid19_data_engineering_project/blob/main/Dashboard/covid19-dashboard.pbix): Power BI report · `Dashboard/covid19-dashboard.pbix`

## Connections

- Johns Hopkins daily reports → GitHub client: accessed by
- GitHub client → CSV extractor: discovers reports
- CSV extractor → File downloader: requests downloads
- File downloader → Raw CSV snapshots: persists CSVs
- Raw CSV snapshots → Raw loader: read by
- Load logic → Raw loader: used by
- Raw loader → Raw schema: loads records
- Warehouse bootstrap → Raw schema: creates
- Warehouse bootstrap → Pipeline metadata: creates
- Docker Compose runtime → COVID pipeline DAG: runs
- Docker Compose runtime → Warehouse bootstrap: initializes
- COVID pipeline DAG → CSV extractor: orchestrates
- COVID pipeline DAG → Raw loader: orchestrates
- COVID pipeline DAG → Staging contract: runs dbt
- Raw schema → Raw source declarations: declared as
- Raw source declarations → Staging contract: feeds
- Staging contract → Clean COVID cases: standardizes into
- Country mapping → Clean COVID cases: normalizes countries
- Clean COVID cases → Analytics marts: builds
- Analytics marts → COVID-19 dashboard: consumed by
