Skip to main content

Terminal UI for exploring and managing dbt projects

Project description

dbtui

A Terminal User Interface (TUI) for navigating and managing dbt (data build tool) projects.

dbtui provides an interactive command-line interface for exploring dbt models, their relationships, and configurations without leaving your terminal.

Features

  • Model Explorer: Browse all models in your dbt project with search capabilities
  • Dependency Visualization: View parent and child relationships for any model
  • Model Preview: Read model SQL and configuration inline
  • Quick Navigation: Jump between related models with keyboard shortcuts
  • New Model Creation: Create new models with automatic ref() generation
  • Property Discovery: View effective configurations from all sources (dbt_project.yml, schema.yml, model config)
  • Session Persistence: Automatically saves and restores your last viewed project and model
  • External Editor Integration: Open models in your preferred editor

Installation

Requirements

  • Python 3.12 or higher
  • A dbt project to explore

Install from source

# Clone the repository
git clone <repository-url>
cd dbtui

# Install dependencies using pip
pip install -e .

# Or using poetry
poetry install

Usage

Basic Usage

Navigate to a dbt project directory and run:

python -m dbtui

Or if installed via poetry:

poetry run python -m dbtui

First Launch

On first launch, dbtui will:

  1. Load the test project (if no cached project exists)
  2. Open the model search screen
  3. Allow you to search for and select a model

Keyboard Shortcuts

Global Bindings

Key Action Description
o Options Open options/settings screen
f Find Model Open model search screen
p Project Search Select a different dbt project
q Quit Exit the application

Model View Screen

Key Action Description
E External Edit Open current model in external editor
n New Model Create a new model that refs the current one
Tab Switch Focus Cycle between parents list, model content, and children list
↑↓ Navigate Lists Move up/down in parent/child lists
Enter Select Model Navigate to the selected parent/child model

Model Search Screen

Key Action Description
Type to search Live Search Filter models by name as you type
↑↓ Navigate Results Move through search results
Enter Select Model Open the selected model

New Model Screen

Key Action Description
Type path Enter Path Specify relative path for new model (e.g., models/staging/stg_users.sql)
Enter Create Model Create the model and open it
Esc Cancel Close modal without creating

Configuration

Cache and Settings

dbtui stores its configuration in your system's cache directory:

  • Linux: ~/.cache/dbtui/cache.json
  • macOS: ~/Library/Caches/dbtui/cache.json
  • Windows: %LOCALAPPDATA%\dbtui\cache.json

The cache stores:

  • Last opened project path
  • Last viewed model
  • External editor command (default: vi)

External Editor

To configure your preferred external editor, open the options screen (o key) and set the editor command. Examples:

  • code - Visual Studio Code
  • vim or vi - Vim
  • nano - Nano
  • subl - Sublime Text

Project Structure

dbtui/
├── src/
│   ├── backend/          # Core dbt project logic
│   │   ├── project.py    # DbtProject class
│   │   ├── model.py      # DbtModel class
│   │   ├── fetch.py      # Property fetching utilities
│   │   ├── property_claim.py      # Property precedence logic
│   │   └── property_discovery.py  # Property discovery from configs
│   ├── frontend/         # TUI screens and widgets
│   │   ├── main.py       # Main application
│   │   ├── model_search/ # Model search interface
│   │   ├── model_tree/   # Model dependency tree view
│   │   ├── new_model/    # New model creation
│   │   └── options/      # Settings screen
│   └── common/           # Shared abstractions and utilities
│       ├── model.py      # Abstract model interface
│       ├── project.py    # Abstract project interface
│       └── cache.py      # Configuration persistence
├── tests/                # Test suite
│   └── testing/          # Test dbt project
└── pyproject.toml        # Project dependencies

Architecture

Backend

The backend implements the core dbt project parsing logic:

  • DbtProject: Represents a dbt project, loads models from configured model-paths
  • DbtModel: Represents a single model, parses Jinja2 templates to extract refs and configs
  • PropertyClaim: Represents a property claim from any configuration source
  • Property Discovery: Collects properties from dbt_project.yml, schema.yml, and model SQL

Frontend

Built with Textual, the frontend provides:

  • Screen-based navigation: Each feature is a separate screen
  • Reactive state management: Changes to project/model automatically update UI
  • Keyboard-driven workflow: All actions accessible via keyboard

Property Precedence

dbtui correctly implements dbt's configuration precedence rules:

  1. Model-level (highest): {{ config(...) }} in SQL files
  2. Schema-level: config: blocks in schema.yml
  3. Project-level (lowest): models: section in dbt_project.yml
    • More specific paths override general ones
    • Example: models.project.staging.stg_users > models.project.staging > models.project

Development

Running Tests

# Run all tests
pytest

# Run specific test file
pytest tests/test_property_claims.py

# Run with coverage
pytest --cov=src

# Run with verbose output
pytest -v

Test Project

The tests/testing/ directory contains a sample dbt project used for testing:

  • Multiple model directories (vanilla, complex_config, invalid)
  • Models with various configurations
  • Schema.yml files with properties and configs
  • Project-level configurations in dbt_project.yml

Adding New Features

  1. Backend changes: Extend DbtProject or DbtModel in src/backend/
  2. Frontend changes: Create new screens/widgets in src/frontend/
  3. Add tests: Write tests in tests/ following existing patterns
  4. Update abstractions: Modify src/common/ interfaces if needed

Roadmap

  • Enhanced model search (fuzzy matching, filters)
  • Property viewer showing all effective configs with sources
  • DAG visualization (ASCII graph)
  • Model execution (dbt run, dbt test)
  • Column-level lineage
  • Documentation viewer
  • Git integration
  • Multiple project workspace

Contributing

Contributions are welcome! Please:

  1. Fork the repository
  2. Create a feature branch
  3. Add tests for new functionality
  4. Ensure all tests pass (pytest)
  5. Submit a pull request

License

[Add your license here]

Acknowledgments

Built with:

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

dbt_tui-0.1.0.tar.gz (28.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

dbt_tui-0.1.0-py3-none-any.whl (40.7 kB view details)

Uploaded Python 3

File details

Details for the file dbt_tui-0.1.0.tar.gz.

File metadata

  • Download URL: dbt_tui-0.1.0.tar.gz
  • Upload date:
  • Size: 28.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.11

File hashes

Hashes for dbt_tui-0.1.0.tar.gz
Algorithm Hash digest
SHA256 e766c28ec976d6558c097f64b0316ba12386185ecbf5c2c9aa4825949d1b9027
MD5 fd3128f7dbf0a74a1456ec8b060f2801
BLAKE2b-256 3f4318a650659969c24441f4c2df7d888f3ada9abb2048292e5613dc9c395a87

See more details on using hashes here.

File details

Details for the file dbt_tui-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: dbt_tui-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 40.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.11

File hashes

Hashes for dbt_tui-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 c310fa18f2ff33a9fdd8b54bfa3cf5f844c5eaefa1f08243caa15a85b8f8250d
MD5 2b1942aeca3435ae2f7603bfd2738415
BLAKE2b-256 11fdeff9d055d753bfe89bcaf510d924216ab9119c6176c3862fd3d0b557d4dc

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page