Skip to content

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

5 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 

Repository files navigation

MLB Data Platform Project

1. Architecture & Security Choices

  • Infrastructure (infra/):

    • Terraform provisions AWS S3 landing & curated buckets with:
      • KMS server-side encryption
      • TLS enforcement
      • Versioning
      • Lifecycle policies for cost control
    • Minimal-privilege IAM roles for CI/CD Terraform plan/apply
    • AWS Budgets monitor monthly spend with email alerts
  • Databricks Administration & ETL (pipelines/databricks/):

    • Cluster policies enforce:
      • Autotermination ≤ 15 minutes
      • Job clusters only (no all-purpose)
      • Cost-effective node types
      • LTS runtime (or ML runtime if justified)
    • Unity Catalog structure (mlb_catalog) separates schemas and enforces access
    • Secrets stored in Databricks Secret Scopes; S3 access via instance profiles
  • ETL & Aggregation:

    • PySpark script ingest_csv_to_delta.py ingests 5 CSVs: Batting, CollegePlaying, People, Salaries, Schools
    • Partitioning by yearID for performance and incremental rebuilds
    • Idempotent job design ensures reruns produce identical results
    • Data quality checks:
      • Nulls handled appropriately
      • Required numeric columns validated
      • Basic sanity checks (e.g., valid year ranges, not null keys)

2. Cost Control Measures & Estimated Savings (finops/)

  • EC2 / Databricks: Spot instances, restricted high-cost node types, auto-termination → ~25% DBU reduction
  • S3 Storage: Lifecycle rules move raw CSVs to Infrequent Access after 30 days, delete older data → ~10–15% savings
  • AWS Savings Plans / Reserved Instances: Estimated 20–30% savings on predictable EC2 workloads
  • Tagging & Budget enforcement: Ensures team accountability and overspend alerts

3. Deployment & Execution

3.1 Infrastructure (infra/)

terraform init
terraform validate
terraform plan -out=tfplan
Run terraform fmt and terraform validate in CI/CD

Apply restricted to protected branches or requires manual approval

Terraform provisions S3, IAM policies, KMS keys, and AWS Budgets

3.2 Databricks ETL Job (pipelines/databricks/)

Upload CSVs to S3 landing bucket

Run ingest_csv_to_delta.py to populate curated Delta tables

Tables partitioned by yearID for faster reads

Data quality checks:

Nulls filtered or replaced

Numeric columns validated

Not-null primary keys enforced

Idempotency:

Reruns produce identical results

Stable ordering maintained

3.3 Team-Year Efficiency Aggregate (sql/)
Execute team_efficiency.sql using Batting & Salaries tables

Metrics computed:

total_payroll (sum of salaries per team-year)

AB and HR (team-year totals)

BA (batting average = H/AB)

SLG (slugging = (H + 2B + 3B + HR)/AB or simplified)

HR_per_Million = HR / (total_payroll / 1,000,000)

Aggregation ensures:

No double counting across players/stints

Deterministic and idempotent results

Sample output (first 10 rows):

sample_output.show(10)

3.4 FinOps Analysis (finops/)
Run analysis.py on aws_costs.csv to:

Identify top cost drivers

Check tag coverage

Propose actionable savings

Implemented controls:

Tighter Databricks cluster policy

S3 lifecycle rules

Optional AWS Budget per tag

4. Observability & Monitoring

Databricks job includes:

Retries (max 2)

Timeout

Email alerts on failure

Terraform resources tagged for visibility

Logs and metrics monitored via Databricks and CloudWatch

Failure notifications and retry policy improve reliability

5. Known Gaps & Next Steps

Gaps:

Full Unity Catalog setup not applied in sandbox

Advanced Delta Lake optimizations (Z-ordering, compaction) not implemented

Real-time dashboards for costs could be improved

Next Steps:

Automate CI/CD for Databricks job deployment

Integrate cost dashboards for proactive FinOps

Add unit tests for ETL scripts and DBT-style transformations

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages