Skip to content

AKhoney/data-engineering-project

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

2 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Weather Data Engineering Project

A professional, enterprise-grade data engineering project for collecting, processing, and analyzing weather data across USA and India. This project demonstrates modern data engineering practices using Azure Cloud services, Databricks, and Apache Spark.

πŸ“‹ Project Overview

This project implements a complete data pipeline that:

  • Ingests weather data from live APIs and static files
  • Processes data for countries, states, and major cities
  • Tracks multiple metrics: temperature, humidity, wind, air quality, and more
  • Implements Medallion Architecture (Bronze β†’ Silver β†’ Gold layers)
  • Manages original and archive tables with monthly/weekly archival
  • Uses Azure Data Factory for orchestration
  • Processes data with Apache Spark & PySpark
  • Implements enterprise-grade logging, monitoring, error handling, and data quality

πŸ—οΈ Architecture

Data Flow

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                    DATA SOURCES                              β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚  Weather APIs        β”‚  CSV/JSON Files                      β”‚
β”‚  (USA & India)       β”‚  (Historical Data)                   β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                         β”‚
                         β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚         AZURE DATA FACTORY (Orchestration)                   β”‚
β”‚  - Copy Activities (API β†’ Staging)                           β”‚
β”‚  - Lookup Activities (Aggregations)                          β”‚
β”‚  - Error Handling & Retry Logic                             β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                         β”‚
                         β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚            AZURE DATA LAKE STORAGE (ADLS)                    β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚   Staging    β”‚   Bronze       β”‚   Silver    β”‚    Gold        β”‚
β”‚   (Raw)      β”‚   (Raw Data)   β”‚  (Cleaned)  β”‚   (Insights)   β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
       β”‚              β”‚              β”‚              β”‚
       β”‚              β–Ό              β–Ό              β–Ό
       β”‚         β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
       β”‚         β”‚ Original β”‚  β”‚ Original β”‚  β”‚ Original β”‚
       β”‚         β”‚ Table    β”‚  β”‚ Table    β”‚  β”‚ Table    β”‚
       β”‚         β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
       β”‚              β”‚              β”‚              β”‚
       β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                      β”‚
                      β–Ό
       β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
       β”‚   Archive Tables (Append Mode)       β”‚
       β”‚  - Historical Data                   β”‚
       β”‚  - Monthly/Weekly Archival           β”‚
       β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                      β”‚
                      β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚       DATABRICKS (Processing & Analytics)                    β”‚
β”‚  - PySpark Transformations                                   β”‚
β”‚  - Data Quality Validation                                   β”‚
β”‚  - State/City-level Aggregations                             β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Medallion Architecture

BRONZE LAYER (Raw Data)
β”œβ”€β”€ Original Table: Current week/month raw data
└── Archive Table: All historical raw data

SILVER LAYER (Cleaned & Validated)
β”œβ”€β”€ Original Table: Current cleaned data
└── Archive Table: Historical cleaned data

GOLD LAYER (Business Ready Insights)
β”œβ”€β”€ Original Table: Current insights & aggregations
β”œβ”€β”€ Archive Table: Historical trends & patterns
β”œβ”€β”€ Country-level aggregations
β”œβ”€β”€ State-level aggregations
└── City-level aggregations

πŸ“ Project Structure

data-engineering-weather/
β”œβ”€β”€ src/
β”‚   β”œβ”€β”€ api/
β”‚   β”‚   β”œβ”€β”€ __init__.py
β”‚   β”‚   β”œβ”€β”€ weather_client.py          # Weather API client
β”‚   β”‚   └── api_config.py              # API configuration
β”‚   β”œβ”€β”€ ingestion/
β”‚   β”‚   β”œβ”€β”€ __init__.py
β”‚   β”‚   β”œβ”€β”€ file_ingestion.py          # Read CSV/JSON files
β”‚   β”‚   └── api_ingestion.py           # Fetch from APIs
β”‚   β”œβ”€β”€ transformations/
β”‚   β”‚   β”œβ”€β”€ __init__.py
β”‚   β”‚   β”œβ”€β”€ bronze_transformations.py  # Raw β†’ Bronze
β”‚   β”‚   β”œβ”€β”€ silver_transformations.py  # Bronze β†’ Silver
β”‚   β”‚   └── gold_transformations.py    # Silver β†’ Gold
β”‚   β”œβ”€β”€ validation/
β”‚   β”‚   β”œβ”€β”€ __init__.py
β”‚   β”‚   β”œβ”€β”€ data_quality.py            # Quality checks
β”‚   β”‚   β”œβ”€β”€ schema_validator.py        # Schema validation
β”‚   β”‚   └── anomaly_detection.py       # Data anomalies
β”‚   β”œβ”€β”€ logging/
β”‚   β”‚   β”œβ”€β”€ __init__.py
β”‚   β”‚   └── logger.py                  # Structured logging
β”‚   β”œβ”€β”€ config/
β”‚   β”‚   β”œβ”€β”€ __init__.py
β”‚   β”‚   β”œβ”€β”€ config.py                  # Configuration management
β”‚   β”‚   └── constants.py               # Constants
β”‚   β”œβ”€β”€ utils/
β”‚   β”‚   β”œβ”€β”€ __init__.py
β”‚   β”‚   β”œβ”€β”€ spark_utils.py             # Spark helpers
β”‚   β”‚   β”œβ”€β”€ adls_utils.py              # ADLS operations
β”‚   β”‚   └── retry_logic.py             # Retry & backoff
β”‚   └── archive/
β”‚       β”œβ”€β”€ __init__.py
β”‚       └── archive_manager.py         # Archive operations
β”œβ”€β”€ terraform/
β”‚   β”œβ”€β”€ main.tf                        # Main resources
β”‚   β”œβ”€β”€ variables.tf                   # Variables & placeholders
β”‚   β”œβ”€β”€ outputs.tf                     # Output values
β”‚   β”œβ”€β”€ storage.tf                     # ADLS configuration
β”‚   β”œβ”€β”€ databricks.tf                  # Databricks setup
β”‚   β”œβ”€β”€ data_factory.tf                # ADF setup
β”‚   β”œβ”€β”€ keyvault.tf                    # Key Vault
β”‚   └── terraform.tfvars.example       # Example variables
β”œβ”€β”€ adf-pipelines/
β”‚   β”œβ”€β”€ pipeline-ingest-api.json       # ADF pipeline for API ingestion
β”‚   β”œβ”€β”€ pipeline-ingest-files.json     # ADF pipeline for file ingestion
β”‚   β”œβ”€β”€ pipeline-archive.json          # ADF pipeline for archival
β”‚   β”œβ”€β”€ pipeline-master.json           # Master orchestration pipeline
β”‚   └── linked-services-template.json  # Linked service templates
β”œβ”€β”€ docs/
β”‚   β”œβ”€β”€ ARCHITECTURE.md                # Detailed architecture
β”‚   β”œβ”€β”€ SETUP_GUIDE.md                 # Setup instructions
β”‚   β”œβ”€β”€ RUNBOOK.md                     # Operations runbook
β”‚   β”œβ”€β”€ DATA_DICTIONARY.md             # Data schema documentation
β”‚   β”œβ”€β”€ API_DOCUMENTATION.md           # API details
β”‚   └── TROUBLESHOOTING.md             # Troubleshooting guide
β”œβ”€β”€ config/
β”‚   β”œβ”€β”€ dev-config.yaml                # Development environment
β”‚   β”œβ”€β”€ staging-config.yaml            # Staging environment
β”‚   └── prod-config.yaml               # Production environment
β”œβ”€β”€ tests/
β”‚   β”œβ”€β”€ __init__.py
β”‚   β”œβ”€β”€ test_api_client.py             # API client tests
β”‚   β”œβ”€β”€ test_transformations.py        # Transformation tests
β”‚   └── test_validation.py             # Validation tests
β”œβ”€β”€ .env.example                       # Environment template
β”œβ”€β”€ .gitignore                         # Git ignore rules
β”œβ”€β”€ requirements.txt                   # Python dependencies
β”œβ”€β”€ setup.py                           # Package setup
└── README.md                          # This file

πŸš€ Quick Start

Prerequisites

  • Python 3.8+
  • Azure subscription (optional for local development)
  • Databricks workspace (optional for local development)
  • Git
  • pip package manager

Local Setup

  1. Clone the repository

    git clone https://github.com/yourusername/data-engineering-weather.git
    cd data-engineering-weather
  2. Create virtual environment

    python -m venv venv
    source venv/bin/activate  # On Windows: venv\Scripts\activate
  3. Install dependencies

    pip install -r requirements.txt
  4. Configure environment

    cp .env.example .env
    # Edit .env with your actual values (API keys, Azure credentials, etc.)
  5. Run tests

    pytest tests/ -v

πŸ”§ Configuration

All configuration is managed via:

  • .env file - Secrets and credentials (DO NOT commit)
  • config/ folder - Environment-specific configs
  • Terraform variables - Infrastructure parameters

Environment Variables

See .env.example for all available configuration options.

Key variables:

  • AZURE_SUBSCRIPTION_ID - Azure subscription
  • ADLS_ACCOUNT_NAME - ADLS account name
  • DATABRICKS_TOKEN - Databricks API token
  • WEATHER_API_KEY - Weather service API key
  • ENVIRONMENT - Current environment (development/staging/production)

πŸ“Š Data Pipeline

Weekly/Monthly Processing

  1. Ingestion Phase

    • ADF Copy Activity: Fetch API data β†’ Staging
    • ADF Copy Activity: Read file data β†’ Staging
  2. Bronze Layer

    • Raw data from staging
    • Minimal transformations
    • Schema validation
  3. Silver Layer

    • Data cleaning & deduplication
    • Null handling
    • Type conversions
    • Quality checks
  4. Gold Layer

    • Business-ready aggregations
    • Country-level metrics
    • State-level insights
    • City-level analysis
    • Trend calculations

Archive Process (Month-End/Weekend)

  1. Copy to Archive

    • Original table β†’ Archive table (APPEND)
    • Maintains full history
  2. Clear Original

    • DELETE old data from Original table
    • INSERT new processed data
    • Fresh snapshot each period

πŸ” Data Quality

Implemented quality checks:

  • βœ… Schema validation (Avro/JSON)
  • βœ… Row count monitoring
  • βœ… Duplicate detection
  • βœ… Null value checks
  • βœ… Data freshness monitoring
  • βœ… Anomaly detection
  • βœ… Incremental load validation

πŸ“ˆ Monitoring & Logging

  • Structured Logging: JSON format for easy parsing
  • Azure Application Insights: Real-time monitoring
  • SLA Tracking: Data freshness and latency metrics
  • Error Alerting: Automatic notifications on failures
  • Audit Logs: Track all data modifications

πŸ” Security

  • βœ… No credentials in code (uses .env & Key Vault)
  • βœ… Encryption at rest (ADLS, databases)
  • βœ… Encryption in transit (TLS)
  • βœ… Access control (RBAC)
  • βœ… Audit logging

πŸ’° Cost Optimization

  • Incremental loading (only process new data)
  • Auto-scaling Databricks clusters
  • Archive to cheaper storage tiers
  • Optimized query patterns
  • Partitioned data for faster access

🀝 Contributing

  1. Create a feature branch
  2. Make changes and add tests
  3. Run pytest tests/ to verify
  4. Submit a pull request

πŸ“ Documentation

πŸ› οΈ Tech Stack

  • Cloud: Azure (ADLS, Databricks, Data Factory, Key Vault, SQL Database)
  • Processing: Apache Spark, PySpark, Python 3.8+
  • Orchestration: Azure Data Factory
  • IaC: Terraform
  • Monitoring: Application Insights
  • Testing: pytest
  • Version Control: Git, GitHub

πŸ“Š Metrics & KPIs

  • Data freshness: Time from ingestion to availability
  • Pipeline latency: End-to-end processing time
  • Data quality score: % of records passing validation
  • Archive success rate: % of archives completing successfully
  • API uptime: % of successful API calls

πŸ“ž Support

For issues and questions:

πŸ“„ License

This project is licensed under the MIT License - see LICENSE file for details.

πŸ‘€ Author

Created as a professional data engineering portfolio project.


Last Updated: 2026-05-13

About

A professional data engineering project for building ETL pipelines and data infrastructure

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors