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:
- Load the test project (if no cached project exists)
- Open the model search screen
- 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 Codevimorvi- Vimnano- Nanosubl- 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:
- Model-level (highest):
{{ config(...) }}in SQL files - Schema-level:
config:blocks in schema.yml - 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
- Backend changes: Extend DbtProject or DbtModel in
src/backend/ - Frontend changes: Create new screens/widgets in
src/frontend/ - Add tests: Write tests in
tests/following existing patterns - 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:
- Fork the repository
- Create a feature branch
- Add tests for new functionality
- Ensure all tests pass (
pytest) - Submit a pull request
License
[Add your license here]
Acknowledgments
Built with:
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file dbt_tui-0.2.0.tar.gz.
File metadata
- Download URL: dbt_tui-0.2.0.tar.gz
- Upload date:
- Size: 32.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1517d05135cddc7d8618bd4bfe07e31167cfa9207278e2e77f1fa285f412de98
|
|
| MD5 |
653bd0532074c98bdc0805ed543a813e
|
|
| BLAKE2b-256 |
5d9343ba44e63dfabb786ea7fcb873a997f070ae4a17e2f95973d732d1f24338
|
File details
Details for the file dbt_tui-0.2.0-py3-none-any.whl.
File metadata
- Download URL: dbt_tui-0.2.0-py3-none-any.whl
- Upload date:
- Size: 44.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9e449155a7c30402e29444033634a71e682aefd3b30a7bec16d69779a653dfe8
|
|
| MD5 |
a6837644aa209458079a414d8baf1d83
|
|
| BLAKE2b-256 |
a1a06303cd1b5b4ee87f58655eda80de824358322959e736e2d29c28826ac3de
|