How ahmedaliali811/covid19_data_engineering_project works
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: covid_pipline.py COVID pipeline DAG · load_data/main.py Raw loader · 01_create_schemas.sql Warehouse bootstrap · extract_files/main.py CSV extractor
Components 18
External source
- Johns Hopkins daily reports
Ingestion
- CSV extractor · Discovers and downloads daily report CSVs.
extract_files/main.py - GitHub client
extract_files/github_client.py - File downloader
extract_files/download_file.py - Raw CSV snapshots · Decouples source availability from warehouse loading.
Data/raw_data - Raw loader · Standardizes CSV columns and writes source-shaped records.
load_data/main.py - Load logic
load_data/loader.py
Orchestration & runtime
- COVID pipeline DAG · Orders extraction, raw loading, and dbt seed/run/test.
docker/airflow/dags/covid_pipline.py - Docker Compose runtime · Runs PostgreSQL, Airflow, and dbt.
docker-compose.yaml
PostgreSQL warehouse
- Warehouse bootstrap · Creates schemas, raw tables, and pipeline metadata.
docker/postgres/init/01_create_schemas.sql - Raw schema · Source-shaped ingested records.
docker/postgres/init/02_create_raw_tables.sql - Pipeline metadata
docker/postgres/init/03_create_metdata_tables.sql
dbt transformations
- Staging contract · Centralizes typing, naming, null handling, and initial validation.
dbt/models/staging/stg_covid_cases.sql - Raw source declarations
dbt/models/staging/sources.yml - Country mapping
dbt/seeds/country_mapping.csv - Clean COVID cases · Applies business cleaning and country enrichment.
dbt/models/intermediate/int_covid_cases_clean.sql - Analytics marts · Dimensions, daily fact, country summary, and monthly aggregates.
dbt/models/marts/fct_covid_daily.sql
Reporting
- COVID-19 dashboard
Dashboard/covid19-dashboard.pbix
Connections 20
- 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