A production-ready starter template demonstrating the Medallion Architecture pattern (Bronze β Silver β Gold) using Bruin CLI.
This pipeline implements a three-layer data architecture pattern:
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β BRONZE LAYER (Raw) β
β ββββββββββββββββ ββββββββββββββββ ββββββββββββββββ β
β βraw_customers β β raw_orders β β raw_products β β
β ββββββββ¬ββββββββ ββββββββ¬ββββββββ ββββββββ¬ββββββββ β
βββββββββββΌβββββββββββββββββββΌβββββββββββββββββββΌββββββββββββββ
β β β
βΌ βΌ βΌ
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β SILVER LAYER (Cleaned) β
β ββββββββββββββββ ββββββββββββββββ ββββββββββββββββ β
β β customers_ β β orders_ β β products_ β β
β β cleaned β β processed β β enriched β β
β ββββββββ¬ββββββββ ββββββββ¬ββββββββ ββββββββ¬ββββββββ β
βββββββββββΌβββββββββββββββββββΌβββββββββββββββββββΌββββββββββββββ
β β β
ββββββββββ¬ββββββββββ΄ββββββββββ¬βββββββββ
βΌ βΌ
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β GOLD LAYER (Business Ready) β
β ββββββββββββββββ ββββββββββββββββ ββββββββββββββββ β
β β customer_ β β daily_ β β product_ β β
β β lifetime_ β β revenue_ β β performance β β
β β value β β summary β β β β
β ββββββββββββββββ ββββββββββββββββ ββββββββββββββββ β
β ββββββββββββββββ β
β β customer_ β β
β β cohort_ β β
β β analysis β β
β ββββββββββββββββ β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
.
βββ pipeline.yml # Pipeline configuration
βββ assets/
β βββ bronze/ # Raw data ingestion layer
β β βββ raw_customers.sql # Raw customer data
β β βββ raw_orders.sql # Raw order transactions
β β βββ raw_products.sql # Raw product catalog
β βββ silver/ # Cleaned & validated layer
β β βββ customers_cleaned.sql # Deduplicated, validated customers
β β βββ orders_processed.sql # Processed orders with currency normalization
β β βββ products_enriched.sql # Enriched product data
β βββ gold/ # Business-ready analytics layer
β βββ customer_lifetime_value.sql # CLV metrics & segmentation
β βββ daily_revenue_summary.sql # Daily KPIs & growth metrics
β βββ product_performance.sql # Product analytics
β βββ customer_cohort_analysis.sql # Cohort retention analysis
βββ README.md
Purpose: Landing zone for raw, unprocessed data from source systems
Characteristics:
- Minimal transformations
- Preserves source data structure
- Includes all records (duplicates, invalid data)
- Timestamped ingestion metadata
- Immutable historical record
Assets:
raw_customers- Customer records from CRMraw_orders- Order transactions from e-commerce platformraw_products- Product catalog from inventory system
Purpose: Clean, conformed, and validated data ready for analytics
Characteristics:
- Deduplication applied
- Data quality rules enforced
- Standardized formats and naming
- Business logic applied
- Invalid records filtered
Transformations:
- Email validation and normalization
- Currency conversion to USD
- Status standardization
- Name formatting (proper case)
- Foreign key validation
Assets:
customers_cleaned- Validated customer recordsorders_processed- Processed orders with currency normalizationproducts_enriched- Enriched product data with derived attributes
Purpose: Aggregated, business-ready analytics tables for reporting and BI
Characteristics:
- Pre-aggregated metrics
- Business KPIs calculated
- Optimized for query performance
- Domain-specific models
- Ready for dashboards and reports
Assets:
customer_lifetime_value- CLV metrics, segmentation, and customer healthdaily_revenue_summary- Daily revenue KPIs with growth ratesproduct_performance- Product sales and performance metricscustomer_cohort_analysis- Retention and cohort behavior analysis
- Bruin CLI installed
- Database connection configured (BigQuery, Snowflake, etc.)
- Clone this repository:
git clone https://github.com/bruin-data/bruin-cloud-starter.git
cd bruin-cloud-starter- Configure your connections:
bruin connections add- Update
pipeline.ymlwith your connection names:
default_connections:
google_cloud_platform: your-bigquery-connection
snowflake: your-snowflake-connection- Update asset queries to point to your actual data sources:
- Replace placeholder table references in bronze layer assets
- Update source table names in SQL queries
Validate the pipeline:
bruin validate .Run the entire pipeline:
bruin run .Run a specific layer:
bruin run assets/bronze/
bruin run assets/silver/
bruin run assets/gold/Run a single asset:
bruin run assets/gold/customer_lifetime_value.sqlRun with downstream dependencies:
bruin run assets/silver/customers_cleaned.sql --downstream- Bronze Layer: Add new source data ingestion
# Create new bronze asset
touch assets/bronze/raw_your_table.sql- Silver Layer: Add transformations
# Create new silver asset with dependencies
touch assets/silver/your_table_cleaned.sql- Gold Layer: Add business metrics
# Create new gold asset
touch assets/gold/your_business_metric.sqlEach asset includes detailed comments explaining:
- Business logic applied
- Data quality rules
- Transformation steps
- Column descriptions
Edit the SQL files to customize transformations for your use case.
Update the FROM clauses in bronze layer assets:
-- Replace this placeholder:
FROM `project.source_dataset.customers_raw`
-- With your actual source:
FROM `your-project.your-dataset.your-table`The pipeline includes built-in data quality checks:
- NOT NULL checks on primary keys
- UNIQUE checks on identifiers
- Positive value checks on amounts
- Email validation with regex
- Foreign key validation between layers
Add custom checks in asset definitions:
columns:
- name: customer_id
checks:
- name: not_null
- name: uniqueView the data lineage:
bruin lineage .This shows the dependency graph between all assets across layers.
The pipeline is configured to run daily. Modify in pipeline.yml:
schedule: daily # Options: hourly, daily, weekly, monthly, or cron expression
start_date: "2024-01-01"Configure Slack notifications in pipeline.yml:
notifications:
slack:
- channel: data-pipelines
success: false # Only notify on failuresThis starter template is ideal for:
- E-commerce analytics - Customer, order, and product analysis
- SaaS metrics - User behavior and revenue tracking
- Retail analytics - Sales performance and inventory
- Customer analytics - CLV, retention, and segmentation
Contributions welcome! Please open an issue or PR.
MIT License - feel free to use this template for your projects.
Built with β€οΈ using Bruin