learntodriveai.dev/Data Engineering/dbt Framework: From Scripts to Models
Data EngineeringProject 036 unitsVerified on 16 October 2026

dbt Framework: From Scripts to Models

Mihai PopescuOwner and Head Cheesemaker · Artisan cheese producer · Sibiu, Romania
Slack · from Mihai
I have data everywhere. Production batches in one spreadsheet, sales in another, milk purchases in a third. Different people maintain each one.
Chat with Mihai

What you hand back

  • A dbt project over three data sources
  • Staging models for production, sales and purchases
  • A profitability mart by cheese variety
  • Yield per variety from milk to cheese
  • A quarterly revenue summary for the accountant
  • Automated tests on the profitability numbers

6 units

  1. Unit 1: Meet Mihai and understand the cheese business

    Read Mihai's Slack message, ask about his six cheeses, and review the pipeline spec and its verification targets.

    Open unit 1
  2. Unit 2: Set up the project and profile all three sources

    Set up the project folder from the materials and profile the production, sales and milk purchase files.

    Open unit 2
  3. Unit 3: Initialize the dbt project and configure sources

    Review the dbt template, learn what the framework adds to plain SQL, and configure the three sources.

    Open unit 3
  4. Unit 4: Build staging models

    Build the staging models that clean, rename and type-cast each source, then check the row counts.

    Open unit 4
  5. Unit 5: Build the mart, add dbt tests, and find the gap

    Build the profitability mart with ref(), add automated tests, and find where passing tests still miss wrong numbers.

    Open unit 5
  6. Unit 6: Show Mihai and close the project

    Query the mart and a quarterly summary, then present the profitability results to Mihai and close the project.

    Open unit 6
Read the full brief

You're building a dbt project for an artisan cheese producer in Sibiu, Romania — connecting milk purchases, production batches, and sales records into a profitability model by cheese variety, with automated quality tests.

A dbt project is a set of SQL files — called models — connected by reference declarations that the framework uses to track dependencies and run tests. Unit 3 introduces the framework before you build anything.

The discipline skills: writing dbt models with declared dependencies and ref(), applying staging-to-mart layer architecture inside a framework, and writing automated tests — unique, not_null, accepted_values, relationships — that verify data properties after every run.

The AI-direction lesson: AI generates dbt models that run. The question is whether you understand what the framework is doing or are just trusting AI's explanation. AI will describe how models relate, how tests protect the data, how the DAG resolves dependencies — and those descriptions may not match the actual SQL. Reading the code AI produces, not the explanation it offers, is the verification habit that starts here. A dbt project where all tests pass can still produce wrong profitability numbers. The tests verify structure. You verify meaning.

Your Role

You're building a dbt project that connects Mihai's three data sources into a profitability model. The SQL is the same kind you wrote in P1 and P2. What's new is the framework — models, dependencies, automated tests. How you break the work into tasks is your call.

What's New

Last time you extracted API data, designed a schema from source profiles, and built staging and mart layers in raw SQL scripts. You handled idempotency manually — making sure re-running the pipeline didn't create duplicates.

This time, dbt handles idempotency for you. Models use CREATE OR REPLACE by default, so running the pipeline twice produces the same result without manual checks. The framework encodes a property you had to build yourself before.

The genuinely new piece is automated testing. dbt's built-in tests — unique, not_null, accepted_values, relationships — check structural properties of your data after every run. But structural correctness is not the same as business correctness. All tests can pass while the profitability numbers are wrong. Deciding which tests actually protect Mihai's numbers — and which just confirm things the database already guarantees — is the real decision in this project.

Tools

  • Python — via your Miniconda de environment
  • DuckDB — analytical database for all three sources
  • SQL — transformation logic inside dbt models
  • dbt Core + dbt-duckdb adapter — transformation framework (new this project). The unit that introduces dbt walks through setup.
  • Claude Code — your AI agent, doing the implementation work
  • Git / GitHub — version control

Materials

You'll receive:

  • Pipeline specification — what to build, Mihai's requirements, verification targets
  • Three data source files — production log, sales records, milk purchases
  • dbt project template — project structure, dbt_project.yml, and profiles.yml configured for DuckDB
  • Verification checklist — row counts, staging counts, profitability spot-checks
  • Project governance file — CLAUDE.md with the full ticket breakdown
  • Ticket backlog — work broken into sequenced tickets
Materials · 11 files
Start Project 3

You work at a computer with a terminal. Signed in, your place is saved.