Modular ETL pipeline: extracts African country data from a REST API, transforms and validates it, loads into SQLite and runs analytical SQL queries
# π African Countries ETL Pipeline
A modular **Extract β Transform β Load (ETL)** pipeline that ingests live African country data from a public REST API, applies data quality transformations, loads the result into a **SQLite** database, and runs analytical **SQL** queries β all in a single command.
## ποΈ Pipeline Architecture
```
REST Countries API
β
βΌ
[1] EXTRACT fetch_countries() β HTTP GET, error handling
β
βΌ
[2] TRANSFORM transform() β flatten JSON, compute density, cast types
β
βΌ
[3] VALIDATE validate() β data quality checks (nulls, types, ranges)
β
βΌ
[4] LOAD load_to_sqlite() β full-refresh into SQLite
β
βΌ
[5] QUERY run_queries() β 5 analytical SQL queries
β
βΌ
[6] EXPORT export_csv() β CSV for downstream use
```
## π οΈ Tech Stack
| Tool | Purpose |
|------|---------|
| Python 3.10+ | Core language |
| `requests` | API extraction |
| `pandas` | Data transformation & quality checks |
| `sqlite3` | Embedded database (stdlib) |
| SQL | Analytical querying |
## π Getting Started
```bash
# Clone the repo
git clone
github.com
cd etl-data-pipeline
# Install dependencies
pip install -r requirements.txt
# Run the pipeline
python main.py
```
## π Project Structure
```
etl-data-pipeline/
βββ main.py # Orchestrator β runs all 5 stages
βββ config.py # Centralised configuration
βββ requirements.txt
βββ pipeline/
β βββ extract.py # Stage 1: API extraction
β βββ transform.py # Stage 2 & 3: transformation + validation
β βββ load.py # Stage 4β6: loading, querying, export
βββ data/ # SQLite database (auto-created)
βββ outputs/ # CSV export + pipeline log (auto-created)
```
## π Analytical SQL Queries
| Query | Description |
|-------|-------------|
| `top_10_by_population` | Most populous African countries |
| `top_10_by_area` | Largest countries by land area |
| `hig β¦