This is an example dbt project prepared by Pipeline To Insights for tutorial purposes. Check out full blog post for more details.
This dbt project transforms raw e-commerce data into clean, analytics-ready tables by following a layered approach:
- Staging Layer → Standardises raw data
- Intermediate Layer → Aggregates and processes data
- Marts Layer → Provides final business-ready tables
ecommerce_project/
│-- models/
│ ├── staging/
│ │ ├── stg_orders.sql
│ │ ├── stg_customers.sql
│ │ ├── stg_payments.sql
│ │ ├── sources.yml
│ │ └── schema.yml
│ ├── intermediate/
│ │ ├── int_order_summary.sql
│ │ ├── int_payment_summary.sql
│ │ └── schema.yml
│ ├── marts/
│ │ ├── mart_customer_lifetime_value.sql
│ │ ├── mart_orders_payments.sql
│ │ └── schema.yml
│ ├── data/
│ │ ├── orders.csv
│ │ ├── customers.csv
│ │ ├── payments.csv
│ ├── analyses/
│ ├── macros/
│ ├── seeds/
│ ├── snapshots/
│ ├── tests/
│-- .gitignore
│-- dbt_project.yml
│-- profiles.yml
│-- README.md- Install dbt:
pip install dbt-core dbt-postgres- Configure profiles.yml(update database credentials):
ecommerce_project:
target: dev
outputs:
dev:
type: postgres
host: localhost
user: my_user
password: my_password
port: 5432
dbname: my_db
schema: public- Test the connection:
dbt debug- Run the models:
dbt run- Run the tests:
dbt test- Generate and serve documentation:
dbt docs generate
dbt docs serve