This repository houses the central dbt (Data Build Tool) transformation pipeline for Oppia. It ingests raw logging inputs from both the Web server and Android client applications and converts them into structured, performance-optimized analytical datasets inside Google Cloud BigQuery.
The project uses three dbt model layers. Folder names are part of the dbt
configuration in dbt_project.yml, so new models should be added to the
corresponding layer.
├── models/
│ ├── staging/
│ │ ├── web/ # Raw web sources and web event cleaning
│ │ ├── android/ # Raw Android sources and Android event cleaning
│ │ └── cuj_reference/ # CUJ workbook inventory and step definitions
│ ├── intermediate/ # Reusable transformations shared by marts
│ │ └── cuj_health/ # CUJ mappings, readiness, progression, metrics
│ └── marts/ # Business-facing models by product domain
│ ├── users/
│ ├── curriculum/
│ ├── growth_outreach/
│ └── cuj_health/ # Semantic Layer CUJ-health outputs
├── seeds/cuj_health/ # Governed CUJ mappings, thresholds, and step pairs
├── tests/cuj_health/ # Custom CUJ-health assertions
├── macros/ # Reusable dbt macros across all domains
│ ├── ga4/ # Reusable GA4 event-parameter extraction
│ ├── cuj_health/ # Shared CUJ-health calculations
│ └── generate_surrogate_key.sql
├── utils/
│ └── udf/ # Warehouse user-defined functions
├── dbt_project.yml # Model routing and project scope
└── profiles.yml.example # Credential configuration blueprint
Use a double underscore between the entity and the business subject, for
example stg_web_analytics__events or int_web_cuj__event_matches. Keep
source definitions in src_<platform>.yml files and keep model descriptions
and tests beside the models they document.
Before compiling data structures locally, developers must establish active credentials to access the development sandboxes inside oppia-analytics-test.
Ensure you have Python 3.11+ installed, create a virtual environment, and install the project dependencies:
python3 -m venv .venv
source .venv/bin/activate
# Install dbt-bigquery and local dev tools (ruff, coverage, sqlfluff, yamllint)
pip install -r requirements-dev.txt
# Pull down open-source external packages (if any)
dbt depsLocal credentials are kept strictly out of git version control.
-
Copy the tracking template: cp profiles.yml.example profiles.yml
-
Open your newly created
profiles.ymlfile and replace "dev_yourname" with your specific developer schema signature (e.g., dev_johndoe). -
Authenticate with Google Cloud using your local user credentials: gcloud auth application-default login
Run a diagnostic framework check to ensure dbt can establish a secure handshake with BigQuery:
dbt debug
-
Compile the structural SQL lineage tree: dbt compile
-
Build and test models inside your personal schema sandbox: dbt build --target dev
-
Run offline linting, tests, and coverage checks (same checks run in PR CI): yamllint --strict . ruff check . ruff format --check . coverage run -m unittest discover -s scripts -v && coverage report sqlfluff lint models/ tests/ dbt parse python3 scripts/check_dbt_coverage.py
For modeling conventions and architecture details, see models/README.md. For making and reviewing Pull Requests, see CONTRIBUTING.md.