Domain Models & Typings
Relevant source files
The following files were used as context for generating this wiki page:
Introduction
The flext-dbt-ldif project provides a structured framework for transforming LDAP Data Interchange Format (LDIF) data into dbt (data build tool) models. The Domain Models and Typings serve as the foundational schema and contract for this transformation process, ensuring that LDIF metadata, dbt model definitions, and workflow results are handled with strict typing and validation.
These models are built upon the flext-core and flext-meltano foundations, utilizing Pydantic-based ArbitraryTypesModel to define the structure of dbt models, validation results, and end-to-end pipeline statuses. This architecture allows for a seamless flow from raw LDIF parsing to validated, staged, and materialized analytics insights.
Sources: src/flext_dbt_ldif/models.py:1-15, pyproject.toml:25-30, README.md:1-10
Core Data Models
The primary model namespace is encapsulated within FlextDbtLdifModels, which inherits from FlextLdifModels and Meltano-based models. This namespace contains the specialized DbtLdif group of models used for metadata orchestration.
DbtModel Definition
The DbtModel class is the central data structure representing a single dbt model generated from LDIF data. It includes metadata regarding the model's type (e.g., staging, analytics), its SQL content, and its position in the dependency graph.
| Field | Type | Description |
|---|---|---|
name | str | Unique name of the dbt model. |
dbt_model_type | str | Category (e.g., staging, intermediate, marts). |
ldif_source | str | Identifier for the source LDIF data. |
materialization | str | Strategy (default: view). |
sql_content | str | The actual rendered SQL for dbt execution. |
dependencies | t.StrSequence | List of upstream model names. |
Sources: src/flext_dbt_ldif/models.py:18-43, tests/unit/test_dbt_models.py:100-112
Model Validation Rules
The DbtModel implements a validate_business_rules method to ensure data integrity before persistence or execution. This method enforces that names, sources, and SQL content are not empty.
def validate_business_rules(self) -> p.Result[bool]:
"""Validate minimal model constraints."""
if not self.name.strip():
return e.fail_validation("name", error="cannot be empty")
if not self.ldif_source.strip():
return e.fail_validation("ldif_source", error="cannot be empty")
if not self.sql_content.strip():
return e.fail_validation("sql_content", error="cannot be empty")
return r[bool].ok(value=True)
Sources: src/flext_dbt_ldif/models.py:51-59, tests/unit/test_dbt_models.py:126-155
Transformation and Workflow Results
The system utilizes specific models to capture the state and output of various lifecycle stages, from initial parsing to final transformation.
Result Lifecycle Model Flow
The following diagram illustrates how data flows through different result models during a standard LDIF-to-dbt workflow.
This diagram shows the transition from raw validation metrics to final pipeline status reports.
Sources: src/flext_dbt_ldif/models.py:61-125, tests/unit/test_services.py:40-80
Result Model Specifications
| Model | Key Fields | Purpose |
|---|---|---|
LdifValidationResult | total_entries, quality_score | Captures quality metrics of raw LDIF. |
DbtTransformationResult | records, models, status | Summarizes dbt execution output. |
ModelGenerationResult | models_generated, model_names | Tracks the creation of SQL files. |
WorkflowResult | ldif_file, workflow_status | Comprehensive end-to-end report. |
Sources: src/flext_dbt_ldif/models.py:61-115
Project Configuration and Typings
The project relies on a centralized dbt_project.yml for materialization defaults and typings.py for ensuring type safety across the package.
dbt Schema Materialization
The project defines a tiered schema structure for LDIF data transformation, as configured in the project metadata.
models:
flext_dbt_ldif:
+materialized: table
+schema: ldif
staging:
+materialized: view
+schema: ldif_staging
intermediate:
+materialized: view
+schema: ldif_intermediate
marts:
+materialized: table
+schema: ldif_marts
Sources: dbt_project.yml:32-52
Dependency and Typing Architecture
The project utilizes flext-core for lazy loading and result handling (p.Result). Typing aliases are managed in src/flext_dbt_ldif/typings.py to provide a consistent interface for JSON mappings and string sequences.
The class hierarchy demonstrates the encapsulation of model definitions within the FlextDbtLdifModels namespace.
Sources: src/flext_dbt_ldif/models.py:12-20, src/flext_dbt_ldif/typings.py
Conclusion
The Domain Models and Typings in flext-dbt-ldif provide a robust, validated contract for the lifecycle of LDIF data within a dbt-managed environment. By strictly defining the DbtModel and various Result payloads, the architecture ensures that every step—from parsing quality checks to model generation—is traceable and type-safe. This structure facilitates the reliable creation of complex LDIF analytics pipelines by enforcing business rules at the data model level.
Sources: src/flext_dbt_ldif/models.py:18-125, AGENTS.md:10-25