# timolsoft/countries_information_ingestion architecture

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

- Interactive diagram: https://gitdiagram.com/timolsoft/countries_information_ingestion
- Repository: https://github.com/timolsoft/countries_information_ingestion

## Overview

This repository is a country-data ELT pipeline for travel-destination analytics. Its main workflow extracts country attributes from REST Countries, validates row counts, loads a BigQuery staging table, and builds a dimensional warehouse; Airflow owns that scheduled flow. The README also documents a dbt modeling path, a local PostgreSQL alternative, and ad-hoc analytics queries. The Airflow, extraction, and BigQuery load implementations were sampled; dbt internals and individual SQL queries were not, so those links reflect README statements only.

Main entry points: [`airflow/dags/country_pipeline_dag.py`](https://github.com/timolsoft/countries_information_ingestion/blob/main/airflow/dags/country_pipeline_dag.py) (Airflow DAG), [`api/extract.py`](https://github.com/timolsoft/countries_information_ingestion/blob/main/api/extract.py) (Country extraction), [`api/load.py`](https://github.com/timolsoft/countries_information_ingestion/blob/main/api/load.py) (BigQuery loader), [`country_data/models/staging/stg_country_data.sql`](https://github.com/timolsoft/countries_information_ingestion/blob/main/country_data/models/staging/stg_country_data.sql) (dbt staging view)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_ingest["Ingestion"]
  node_extract["Country extraction<br/>[extract.py]"]
  node_load_helpers["BigQuery loader<br/>[load.py]"]
  node_gcs[("Cloud Storage bucket")]
  node_postgres_loader["Postgres alternative<br/>[load2db.py]"]
  node_postgres[("Local PostgreSQL")]
end

subgraph group_orchestration["Orchestration"]
  node_airflow_dag["Airflow DAG"]
  node_validate["Row-count gate"]
  node_warehouse_build["Warehouse build"]
end

subgraph group_warehouse["Warehouse"]
  node_staging[("BigQuery staging<br/>[load.py]")]
  node_warehouse_tables[("Star schema")]
  node_dbt_staging["dbt staging view"]
  node_dbt_dimensions["dbt dimensions"]
  node_dbt_fact["dbt country fact<br/>[fact_country.sql]"]
end

subgraph group_analytics["Analytics"]
  node_analytics_sql["Analytics queries"]
end

node_api(("REST Countries API"))

node_airflow_dag -->|"calls extraction"| node_extract
node_airflow_dag -->|"runs validation"| node_validate
node_airflow_dag -->|"calls loader"| node_load_helpers
node_airflow_dag -->|"runs build task"| node_warehouse_build
node_extract -->|"fetches country data"| node_api
node_airflow_dag -->|"re-extracts for load"| node_extract
node_airflow_dag -->|"passes row counts"| node_validate
node_load_helpers -->|"ensures bucket"| node_gcs
node_load_helpers -->|"truncates and loads"| node_staging
node_warehouse_build -->|"reads staging data"| node_staging
node_warehouse_build -->|"creates tables"| node_warehouse_tables
node_staging -.->|"feeds staging model"| node_dbt_staging
node_dbt_staging -.->|"feeds dimensions"| node_dbt_dimensions
node_dbt_staging -.->|"feeds fact model"| node_dbt_fact
node_postgres_loader -->|"calls extraction"| node_extract
node_postgres_loader -.->|"loads locally"| node_postgres
node_analytics_sql -.->|"queries warehouse"| node_warehouse_tables

click node_airflow_dag "https://github.com/timolsoft/countries_information_ingestion/blob/main/airflow/dags/country_pipeline_dag.py"
click node_extract "https://github.com/timolsoft/countries_information_ingestion/blob/main/api/extract.py"
click node_validate "https://github.com/timolsoft/countries_information_ingestion/blob/main/airflow/dags/country_pipeline_dag.py"
click node_load_helpers "https://github.com/timolsoft/countries_information_ingestion/blob/main/api/load.py"
click node_staging "https://github.com/timolsoft/countries_information_ingestion/blob/main/api/load.py"
click node_warehouse_build "https://github.com/timolsoft/countries_information_ingestion/blob/main/airflow/dags/country_pipeline_dag.py"
click node_warehouse_tables "https://github.com/timolsoft/countries_information_ingestion/blob/main/airflow/dags/country_pipeline_dag.py"
click node_dbt_staging "https://github.com/timolsoft/countries_information_ingestion/blob/main/country_data/models/staging/stg_country_data.sql"
click node_dbt_dimensions "https://github.com/timolsoft/countries_information_ingestion/tree/main/country_data/models/warehouse"
click node_dbt_fact "https://github.com/timolsoft/countries_information_ingestion/blob/main/country_data/models/warehouse/fact_country.sql"
click node_postgres_loader "https://github.com/timolsoft/countries_information_ingestion/blob/main/api/load2db.py"
click node_analytics_sql "https://github.com/timolsoft/countries_information_ingestion/blob/main/Top%202%20countries%20with%20the%20largest%20Area%20for%20each%20continent.sql"

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_extract,node_load_helpers,node_gcs,node_postgres_loader,node_postgres toneBlue
class node_airflow_dag,node_validate,node_warehouse_build toneAmber
class node_staging,node_warehouse_tables,node_dbt_staging,node_dbt_dimensions,node_dbt_fact,node_api toneMint
class node_analytics_sql toneRose
```

## Components

### Ingestion

- [Country extraction](https://github.com/timolsoft/countries_information_ingestion/blob/main/api/extract.py): `api/extract.py`
- [BigQuery loader](https://github.com/timolsoft/countries_information_ingestion/blob/main/api/load.py): `api/load.py`
- **Cloud Storage bucket**
- [Postgres alternative](https://github.com/timolsoft/countries_information_ingestion/blob/main/api/load2db.py): `api/load2db.py`
- **Local PostgreSQL**

### Orchestration

- [Airflow DAG](https://github.com/timolsoft/countries_information_ingestion/blob/main/airflow/dags/country_pipeline_dag.py): `airflow/dags/country_pipeline_dag.py`
- [Row-count gate](https://github.com/timolsoft/countries_information_ingestion/blob/main/airflow/dags/country_pipeline_dag.py): `airflow/dags/country_pipeline_dag.py`
- [Warehouse build](https://github.com/timolsoft/countries_information_ingestion/blob/main/airflow/dags/country_pipeline_dag.py): `airflow/dags/country_pipeline_dag.py`

### Warehouse

- [BigQuery staging](https://github.com/timolsoft/countries_information_ingestion/blob/main/api/load.py): `api/load.py`
- [Star schema](https://github.com/timolsoft/countries_information_ingestion/blob/main/airflow/dags/country_pipeline_dag.py): `airflow/dags/country_pipeline_dag.py`
- [dbt staging view](https://github.com/timolsoft/countries_information_ingestion/blob/main/country_data/models/staging/stg_country_data.sql): `country_data/models/staging/stg_country_data.sql`
- [dbt dimensions](https://github.com/timolsoft/countries_information_ingestion/tree/main/country_data/models/warehouse): `country_data/models/warehouse`
- [dbt country fact](https://github.com/timolsoft/countries_information_ingestion/blob/main/country_data/models/warehouse/fact_country.sql): `country_data/models/warehouse/fact_country.sql`

### Analytics

- [Analytics queries](https://github.com/timolsoft/countries_information_ingestion/blob/main/Top%202%20countries%20with%20the%20largest%20Area%20for%20each%20continent.sql): `Top 2 countries with the largest Area for each continent.sql`

### Other components

- **REST Countries API**

## Connections

- Airflow DAG → Country extraction: calls extraction (evidence: `airflow/dags/country_pipeline_dag.py`)
- Airflow DAG → Row-count gate: runs validation (evidence: `airflow/dags/country_pipeline_dag.py`)
- Airflow DAG → BigQuery loader: calls loader (evidence: `airflow/dags/country_pipeline_dag.py`)
- Airflow DAG → Warehouse build: runs build task (evidence: `airflow/dags/country_pipeline_dag.py`)
- Country extraction → REST Countries API: fetches country data (evidence: `api/extract.py`)
- Airflow DAG → Country extraction: re-extracts for load (evidence: `airflow/dags/country_pipeline_dag.py`)
- Airflow DAG → Row-count gate: passes row counts (evidence: `airflow/dags/country_pipeline_dag.py`)
- BigQuery loader → Cloud Storage bucket: ensures bucket (evidence: `api/load.py`)
- BigQuery loader → BigQuery staging: truncates and loads (evidence: `api/load.py`)
- Warehouse build → BigQuery staging: reads staging data (evidence: `airflow/dags/country_pipeline_dag.py`)
- Warehouse build → Star schema: creates tables (evidence: `airflow/dags/country_pipeline_dag.py`)
- BigQuery staging → dbt staging view: feeds staging model (evidence: `README.md`)
- dbt staging view → dbt dimensions: feeds dimensions (evidence: `README.md`)
- dbt staging view → dbt country fact: feeds fact model (evidence: `README.md`)
- Postgres alternative → Country extraction: calls extraction (evidence: `api/load2db.py`)
- Postgres alternative → Local PostgreSQL: loads locally (evidence: `README.md`)
- Analytics queries → Star schema: queries warehouse (evidence: `README.md`)
