trellis-datamodel 0.1.2__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (51) hide show
  1. trellis_datamodel-0.1.2/PKG-INFO +298 -0
  2. trellis_datamodel-0.1.2/README.md +262 -0
  3. trellis_datamodel-0.1.2/pyproject.toml +71 -0
  4. trellis_datamodel-0.1.2/setup.cfg +4 -0
  5. trellis_datamodel-0.1.2/trellis_datamodel/__init__.py +3 -0
  6. trellis_datamodel-0.1.2/trellis_datamodel/adapters/__init__.py +47 -0
  7. trellis_datamodel-0.1.2/trellis_datamodel/adapters/base.py +137 -0
  8. trellis_datamodel-0.1.2/trellis_datamodel/adapters/dbt_core.py +565 -0
  9. trellis_datamodel-0.1.2/trellis_datamodel/cli.py +130 -0
  10. trellis_datamodel-0.1.2/trellis_datamodel/config.py +193 -0
  11. trellis_datamodel-0.1.2/trellis_datamodel/models/__init__.py +13 -0
  12. trellis_datamodel-0.1.2/trellis_datamodel/models/schemas.py +27 -0
  13. trellis_datamodel-0.1.2/trellis_datamodel/routes/__init__.py +11 -0
  14. trellis_datamodel-0.1.2/trellis_datamodel/routes/data_model.py +222 -0
  15. trellis_datamodel-0.1.2/trellis_datamodel/routes/manifest.py +70 -0
  16. trellis_datamodel-0.1.2/trellis_datamodel/routes/schema.py +181 -0
  17. trellis_datamodel-0.1.2/trellis_datamodel/server.py +67 -0
  18. trellis_datamodel-0.1.2/trellis_datamodel/static/_app/env.js +1 -0
  19. trellis_datamodel-0.1.2/trellis_datamodel/static/_app/immutable/assets/0.x7WqvLKf.css +1 -0
  20. trellis_datamodel-0.1.2/trellis_datamodel/static/_app/immutable/assets/2.DLAp_5AW.css +1 -0
  21. trellis_datamodel-0.1.2/trellis_datamodel/static/_app/immutable/chunks/Bpg6QCuO.js +1 -0
  22. trellis_datamodel-0.1.2/trellis_datamodel/static/_app/immutable/chunks/ByPwy4Kv.js +1 -0
  23. trellis_datamodel-0.1.2/trellis_datamodel/static/_app/immutable/chunks/C-EkzuW7.js +1 -0
  24. trellis_datamodel-0.1.2/trellis_datamodel/static/_app/immutable/chunks/C5F_HkED.js +1 -0
  25. trellis_datamodel-0.1.2/trellis_datamodel/static/_app/immutable/chunks/Cp6tXdVM.js +2 -0
  26. trellis_datamodel-0.1.2/trellis_datamodel/static/_app/immutable/chunks/D-DEYC7o.js +1 -0
  27. trellis_datamodel-0.1.2/trellis_datamodel/static/_app/immutable/chunks/DfmIHBKM.js +1 -0
  28. trellis_datamodel-0.1.2/trellis_datamodel/static/_app/immutable/chunks/G7wgDTPn.js +2 -0
  29. trellis_datamodel-0.1.2/trellis_datamodel/static/_app/immutable/chunks/NHoXZvRd.js +1 -0
  30. trellis_datamodel-0.1.2/trellis_datamodel/static/_app/immutable/entry/app.DZCvOQjA.js +2 -0
  31. trellis_datamodel-0.1.2/trellis_datamodel/static/_app/immutable/entry/start.C4HmrbHj.js +1 -0
  32. trellis_datamodel-0.1.2/trellis_datamodel/static/_app/immutable/nodes/0.TGY9TRSm.js +1 -0
  33. trellis_datamodel-0.1.2/trellis_datamodel/static/_app/immutable/nodes/1.DWQeb39n.js +1 -0
  34. trellis_datamodel-0.1.2/trellis_datamodel/static/_app/immutable/nodes/2.C8sG4yZB.js +27 -0
  35. trellis_datamodel-0.1.2/trellis_datamodel/static/_app/version.json +1 -0
  36. trellis_datamodel-0.1.2/trellis_datamodel/static/index.html +40 -0
  37. trellis_datamodel-0.1.2/trellis_datamodel/static/robots.txt +3 -0
  38. trellis_datamodel-0.1.2/trellis_datamodel/tests/__init__.py +2 -0
  39. trellis_datamodel-0.1.2/trellis_datamodel/tests/conftest.py +131 -0
  40. trellis_datamodel-0.1.2/trellis_datamodel/tests/test_data_model.py +151 -0
  41. trellis_datamodel-0.1.2/trellis_datamodel/tests/test_dbt_schema.py +234 -0
  42. trellis_datamodel-0.1.2/trellis_datamodel/tests/test_manifest.py +72 -0
  43. trellis_datamodel-0.1.2/trellis_datamodel/tests/test_yaml_handler.py +228 -0
  44. trellis_datamodel-0.1.2/trellis_datamodel/utils/__init__.py +2 -0
  45. trellis_datamodel-0.1.2/trellis_datamodel/utils/yaml_handler.py +309 -0
  46. trellis_datamodel-0.1.2/trellis_datamodel.egg-info/PKG-INFO +298 -0
  47. trellis_datamodel-0.1.2/trellis_datamodel.egg-info/SOURCES.txt +49 -0
  48. trellis_datamodel-0.1.2/trellis_datamodel.egg-info/dependency_links.txt +1 -0
  49. trellis_datamodel-0.1.2/trellis_datamodel.egg-info/entry_points.txt +2 -0
  50. trellis_datamodel-0.1.2/trellis_datamodel.egg-info/requires.txt +19 -0
  51. trellis_datamodel-0.1.2/trellis_datamodel.egg-info/top_level.txt +1 -0
@@ -0,0 +1,298 @@
1
+ Metadata-Version: 2.4
2
+ Name: trellis-datamodel
3
+ Version: 0.1.2
4
+ Summary: Visual data model editor for dbt projects
5
+ Author: Tim Hiebenthal
6
+ Project-URL: Homepage, https://github.com/timhiebenthal/trellis-datamodel
7
+ Project-URL: Repository, https://github.com/timhiebenthal/trellis-datamodel
8
+ Project-URL: Issues, https://github.com/timhiebenthal/trellis-datamodel/issues
9
+ Keywords: dbt,data-modeling,erd,data-engineering,analytics-engineering,visualization,schema
10
+ Classifier: Development Status :: 4 - Beta
11
+ Classifier: Intended Audience :: Developers
12
+ Classifier: Programming Language :: Python :: 3
13
+ Classifier: Programming Language :: Python :: 3.11
14
+ Classifier: Programming Language :: Python :: 3.12
15
+ Classifier: Topic :: Database
16
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
17
+ Requires-Python: >=3.11
18
+ Description-Content-Type: text/markdown
19
+ Requires-Dist: dbt-core<2.0,>=1.6
20
+ Requires-Dist: fastapi>=0.121.3
21
+ Requires-Dist: python-dotenv>=1.2.1
22
+ Requires-Dist: pyyaml>=6.0.3
23
+ Requires-Dist: ruamel.yaml>=0.18.0
24
+ Requires-Dist: typer>=0.9.0
25
+ Requires-Dist: uvicorn>=0.38.0
26
+ Provides-Extra: dev
27
+ Requires-Dist: pytest>=8.0.0; extra == "dev"
28
+ Requires-Dist: httpx>=0.27.0; extra == "dev"
29
+ Provides-Extra: examples
30
+ Requires-Dist: dbt-duckdb==1.10; extra == "examples"
31
+ Requires-Dist: duckdb>=1.4.2; extra == "examples"
32
+ Requires-Dist: marimo>=0.18.0; extra == "examples"
33
+ Requires-Dist: nba-api>=1.11.3; extra == "examples"
34
+ Requires-Dist: pandas>=2.3.3; extra == "examples"
35
+ Requires-Dist: tqdm>=4.67.1; extra == "examples"
36
+
37
+ # Trellis Data
38
+
39
+ A local-first tool to bridge Conceptual Data Modeling, Logical Data Modeling and the physical Implementation (currently with dbt-core).
40
+
41
+ ## Motivation
42
+
43
+ **Current workflow pains:**
44
+ - ERD diagrams live in separate tools (Lucidchart, draw.io) and quickly become stale or unreadable for large projects
45
+ - Data transformations are done isolated from the conceptual data model.
46
+ - No single view connecting business concepts to logical schema
47
+ - Stakeholders can't easily understand model structure without technical context
48
+
49
+ **How Trellis helps:**
50
+ - Visual data model that stays in sync — reads directly from `manifest.json` / `catalog.json`
51
+ - Sketch entities and with their fields and auto-generate schema.yml's for dbt
52
+ - Draw relationships on canvas → auto-generates dbt `relationships` tests
53
+ - Two views: **Conceptual** (entity names, descriptions) and **Logical** (columns, types, materializations) to jump between high-level architect and execution-view.
54
+
55
+ **Two Ways of getting started**
56
+ - Greenfield: draft entities and fields before writing SQL, then sync to dbt YAML
57
+ - Brownfield: document your existing data model by loading existing dbt models and utilize relationship tests to infer links
58
+
59
+ ## Prerequisites
60
+ - **Node.js 22+ (or 20.19+) & npm**
61
+ - Recommended: Use [nvm](https://github.com/nvm-sh/nvm) to install a compatible version (e.g., `nvm install 22`).
62
+ - Note: System packages (`apt-get`) may be too old for the frontend dependencies.
63
+ - A `.nvmrc` file is included; run `nvm use` to switch to the correct version automatically.
64
+ - **Python 3.12+ & [uv](https://github.com/astral-sh/uv)**
65
+ - Install uv via `curl -LsSf https://astral.sh/uv/install.sh | sh` and ensure it’s on your `$PATH`.
66
+ - **Make** (optional) for convenience targets defined in the `Makefile`.
67
+
68
+ ## Installation
69
+
70
+ ### Install from PyPI
71
+
72
+ ```bash
73
+ pip install trellis-datamodel
74
+ # or with uv
75
+ uv pip install trellis-datamodel
76
+ ```
77
+
78
+ ### Install from Source (Development)
79
+
80
+ ```bash
81
+ # Clone the repository
82
+ git clone https://github.com/yourorg/trellis-datamodel.git
83
+ cd trellis-datamodel
84
+
85
+ # Install in editable mode
86
+ pip install -e .
87
+ # or with uv
88
+ uv pip install -e .
89
+ ```
90
+
91
+ ## Quick Start
92
+
93
+ 1. **Navigate to your dbt project directory**
94
+ ```bash
95
+ cd /path/to/your/dbt-project
96
+ ```
97
+
98
+ 2. **Initialize configuration**
99
+ ```bash
100
+ trellis init
101
+ ```
102
+ This creates a `trellis.yml` file. Edit it to point to your dbt manifest and catalog locations.
103
+
104
+ 3. **Start the server**
105
+ ```bash
106
+ trellis run
107
+ ```
108
+
109
+ The server will start on **http://localhost:8089** and automatically open your browser.
110
+
111
+ ## Development Setup
112
+
113
+ For local development with hot reload:
114
+
115
+ ### Install Dependencies
116
+ Run these once per machine (or when dependencies change).
117
+
118
+ 1. **Backend**
119
+ ```bash
120
+ uv sync
121
+ ```
122
+ 2. **Frontend**
123
+ ```bash
124
+ cd frontend
125
+ npm install
126
+ ```
127
+
128
+ **Terminal 1 – Backend**
129
+ ```bash
130
+ make backend
131
+ # or
132
+ uv run trellis run
133
+ ```
134
+ Backend serves the API at http://localhost:8089.
135
+
136
+ **Terminal 2 – Frontend**
137
+ ```bash
138
+ make frontend
139
+ # or
140
+ cd frontend && npm run dev
141
+ ```
142
+ Frontend runs at http://localhost:5173 (for development with hot reload).
143
+
144
+ ## Building for Distribution
145
+
146
+ To build the package with bundled frontend:
147
+
148
+ ```bash
149
+ make build-package
150
+ ```
151
+
152
+ This will:
153
+ 1. Build the frontend (`npm run build`)
154
+ 2. Copy static files to `trellis_datamodel/static/`
155
+ 3. Build the Python wheel (`uv build`)
156
+
157
+ The wheel will be in `dist/` and can be installed with `pip install dist/trellis_datamodel-*.whl`.
158
+
159
+ ## CLI Options
160
+
161
+ ```bash
162
+ trellis run [OPTIONS]
163
+
164
+ Options:
165
+ --port, -p INTEGER Port to run the server on [default: 8089]
166
+ --config, -c TEXT Path to config file (trellis.yml or config.yml)
167
+ --no-browser Don't open browser automatically
168
+ --help Show help message
169
+ ```
170
+
171
+ ## dbt Metadata
172
+ - Generate `manifest.json` and `catalog.json` by running `dbt docs generate` in your dbt project.
173
+ - The UI reads these artifacts to power the ERD modeller.
174
+ - Without these artifacts, the UI loads but shows no dbt models.
175
+
176
+ ## Configuration
177
+
178
+ Run `trellis init` to create a starter `trellis.yml` file in your project.
179
+
180
+ Options:
181
+
182
+ - `framework`: Transformation framework to use. Currently supported: `dbt-core`. Future: `dbt-fusion`, `sqlmesh`, `bruin`, `pydantic`. Defaults to `dbt-core`.
183
+ - `dbt_project_path`: Path to your dbt project directory (relative to `config.yml` or absolute). **Required**.
184
+ - `dbt_manifest_path`: Path to `manifest.json` (relative to `dbt_project_path` or absolute). Defaults to `target/manifest.json`.
185
+ - `dbt_catalog_path`: Path to `catalog.json` (relative to `dbt_project_path` or absolute). Defaults to `target/catalog.json`.
186
+ - `data_model_file`: Path where the data model YAML will be saved (relative to `dbt_project_path` or absolute). Defaults to `data_model.yml`.
187
+ - `dbt_model_paths`: List of path patterns to filter which dbt models are shown (e.g., `["3_core"]`). If empty, all models are included.
188
+
189
+ **Example `trellis.yml`:**
190
+ ```yaml
191
+ framework: dbt-core
192
+ dbt_project_path: "./dbt_built"
193
+ dbt_manifest_path: "target/manifest.json"
194
+ dbt_catalog_path: "target/catalog.json"
195
+ data_model_file: "data_model.yml"
196
+ dbt_model_paths:
197
+ - "3_core"
198
+ ```
199
+
200
+
201
+ ## Testing
202
+
203
+ ### Frontend
204
+ **Testing Libraries:**
205
+ The following testing libraries are defined in `package.json` under `devDependencies` and are automatically installed when you run `npm install`:
206
+ - [Vitest](https://vitest.dev/) (Unit testing)
207
+ - [Playwright](https://playwright.dev/) (End-to-End testing)
208
+ - [Testing Library](https://testing-library.com/) (DOM & Svelte testing utilities)
209
+ - [jsdom](https://github.com/jsdom/jsdom) (DOM environment)
210
+
211
+ > **Playwright system dependencies (Ubuntu/WSL2)**
212
+ >
213
+ > The browsers downloaded by Playwright need a handful of native libraries. Install them before running `npm run test:e2e`:
214
+ >
215
+ > ```bash
216
+ > sudo apt-get update && sudo apt-get install -y \
217
+ > libxcursor1 libxdamage1 libgtk-3-0 libpangocairo-1.0-0 libpango-1.0-0 \
218
+ > libatk1.0-0 libcairo-gobject2 libcairo2 libgdk-pixbuf-2.0-0 libasound2 \
219
+ > libnspr4 libnss3 libgbm1 libgles2-mesa libgtk-4-1 libgraphene-1.0-0 \
220
+ > libxslt1.1 libwoff2dec0 libvpx7 libevent-2.1-7 libopus0 \
221
+ > libgstallocators-1.0-0 libgstapp-1.0-0 libgstpbutils-1.0-0 libgstaudio-1.0-0 \
222
+ > libgsttag-1.0-0 libgstvideo-1.0-0 libgstgl-1.0-0 libgstcodecparsers-1.0-0 \
223
+ > libgstfft-1.0-0 libflite1 libflite1-plugins libwebpdemux2 libavif13 \
224
+ > libharfbuzz-icu0 libwebpmux3 libenchant-2-2 libsecret-1-0 libhyphen0 \
225
+ > libwayland-server0 libmanette-0.2-0 libx264-163
226
+ > ```
227
+
228
+ **Running Tests:**
229
+
230
+ The test suite has multiple levels to catch different types of issues:
231
+
232
+ ```bash
233
+ cd frontend
234
+
235
+ # Quick smoke test (catches 500 errors, runtime crashes, ESM issues)
236
+ # Fastest way to verify the app loads without errors
237
+ npm run test:smoke
238
+
239
+ # TypeScript/compilation check
240
+ npm run check
241
+
242
+ # Unit tests
243
+ npm run test:unit
244
+
245
+ # E2E tests (includes smoke test + full test suite)
246
+ # Note: Requires backend running with test data (see Test Data Isolation below)
247
+ npm run test:e2e
248
+
249
+ # Run all tests (check + smoke + unit + e2e)
250
+ npm run test
251
+ ```
252
+
253
+ **Test Levels:**
254
+ 1. **`npm run check`** - TypeScript compilation errors
255
+ 2. **`npm run test:smoke`** - Runtime errors (500s, console errors, ESM issues) - **catches app crashes**
256
+ 3. **`npm run test:unit`** - Unit tests with Vitest
257
+ 4. **`npm run test:e2e`** - Full E2E tests with Playwright
258
+
259
+ **Using Makefile:**
260
+ ```bash
261
+ # From project root
262
+ make test-smoke # Quick smoke test
263
+ make test-check # TypeScript check
264
+ make test-unit # Unit tests
265
+ make test-e2e # E2E tests (auto-starts backend with test data)
266
+ make test-all # All tests
267
+ ```
268
+
269
+ **Test Data Isolation:**
270
+ E2E tests use a separate test data file (`frontend/tests/test_data_model.yml`) to avoid polluting your production data model. **Playwright automatically starts the backend** with the correct environment variable, so you don't need to manage it manually.
271
+
272
+ ```bash
273
+ # Just run E2E tests - backend starts automatically with test data
274
+ make test-e2e
275
+ # OR:
276
+ # cd frontend && npm run test:e2e
277
+ ```
278
+
279
+ The test data file is automatically cleaned before and after test runs via Playwright's `globalSetup` and `globalTeardown`. Your production `data_model.yml` remains untouched.
280
+
281
+ ### Backend
282
+ **Testing Libraries:**
283
+ The following testing libraries are defined in `pyproject.toml` under `[project.optional-dependencies]` in the `dev` group:
284
+ - [pytest](https://docs.pytest.org/) (Testing framework)
285
+ - [httpx](https://www.python-httpx.org/) (Async HTTP client for API testing)
286
+
287
+ **Installation:**
288
+ Unlike `npm`, `uv sync` does not install optional dependencies by default. To include the testing libraries, run:
289
+ ```bash
290
+ cd backend
291
+ uv sync --extra dev
292
+ ```
293
+
294
+ **Running Tests:**
295
+ ```bash
296
+ cd backend
297
+ uv run pytest
298
+ ```
@@ -0,0 +1,262 @@
1
+ # Trellis Data
2
+
3
+ A local-first tool to bridge Conceptual Data Modeling, Logical Data Modeling and the physical Implementation (currently with dbt-core).
4
+
5
+ ## Motivation
6
+
7
+ **Current workflow pains:**
8
+ - ERD diagrams live in separate tools (Lucidchart, draw.io) and quickly become stale or unreadable for large projects
9
+ - Data transformations are done isolated from the conceptual data model.
10
+ - No single view connecting business concepts to logical schema
11
+ - Stakeholders can't easily understand model structure without technical context
12
+
13
+ **How Trellis helps:**
14
+ - Visual data model that stays in sync — reads directly from `manifest.json` / `catalog.json`
15
+ - Sketch entities and with their fields and auto-generate schema.yml's for dbt
16
+ - Draw relationships on canvas → auto-generates dbt `relationships` tests
17
+ - Two views: **Conceptual** (entity names, descriptions) and **Logical** (columns, types, materializations) to jump between high-level architect and execution-view.
18
+
19
+ **Two Ways of getting started**
20
+ - Greenfield: draft entities and fields before writing SQL, then sync to dbt YAML
21
+ - Brownfield: document your existing data model by loading existing dbt models and utilize relationship tests to infer links
22
+
23
+ ## Prerequisites
24
+ - **Node.js 22+ (or 20.19+) & npm**
25
+ - Recommended: Use [nvm](https://github.com/nvm-sh/nvm) to install a compatible version (e.g., `nvm install 22`).
26
+ - Note: System packages (`apt-get`) may be too old for the frontend dependencies.
27
+ - A `.nvmrc` file is included; run `nvm use` to switch to the correct version automatically.
28
+ - **Python 3.12+ & [uv](https://github.com/astral-sh/uv)**
29
+ - Install uv via `curl -LsSf https://astral.sh/uv/install.sh | sh` and ensure it’s on your `$PATH`.
30
+ - **Make** (optional) for convenience targets defined in the `Makefile`.
31
+
32
+ ## Installation
33
+
34
+ ### Install from PyPI
35
+
36
+ ```bash
37
+ pip install trellis-datamodel
38
+ # or with uv
39
+ uv pip install trellis-datamodel
40
+ ```
41
+
42
+ ### Install from Source (Development)
43
+
44
+ ```bash
45
+ # Clone the repository
46
+ git clone https://github.com/yourorg/trellis-datamodel.git
47
+ cd trellis-datamodel
48
+
49
+ # Install in editable mode
50
+ pip install -e .
51
+ # or with uv
52
+ uv pip install -e .
53
+ ```
54
+
55
+ ## Quick Start
56
+
57
+ 1. **Navigate to your dbt project directory**
58
+ ```bash
59
+ cd /path/to/your/dbt-project
60
+ ```
61
+
62
+ 2. **Initialize configuration**
63
+ ```bash
64
+ trellis init
65
+ ```
66
+ This creates a `trellis.yml` file. Edit it to point to your dbt manifest and catalog locations.
67
+
68
+ 3. **Start the server**
69
+ ```bash
70
+ trellis run
71
+ ```
72
+
73
+ The server will start on **http://localhost:8089** and automatically open your browser.
74
+
75
+ ## Development Setup
76
+
77
+ For local development with hot reload:
78
+
79
+ ### Install Dependencies
80
+ Run these once per machine (or when dependencies change).
81
+
82
+ 1. **Backend**
83
+ ```bash
84
+ uv sync
85
+ ```
86
+ 2. **Frontend**
87
+ ```bash
88
+ cd frontend
89
+ npm install
90
+ ```
91
+
92
+ **Terminal 1 – Backend**
93
+ ```bash
94
+ make backend
95
+ # or
96
+ uv run trellis run
97
+ ```
98
+ Backend serves the API at http://localhost:8089.
99
+
100
+ **Terminal 2 – Frontend**
101
+ ```bash
102
+ make frontend
103
+ # or
104
+ cd frontend && npm run dev
105
+ ```
106
+ Frontend runs at http://localhost:5173 (for development with hot reload).
107
+
108
+ ## Building for Distribution
109
+
110
+ To build the package with bundled frontend:
111
+
112
+ ```bash
113
+ make build-package
114
+ ```
115
+
116
+ This will:
117
+ 1. Build the frontend (`npm run build`)
118
+ 2. Copy static files to `trellis_datamodel/static/`
119
+ 3. Build the Python wheel (`uv build`)
120
+
121
+ The wheel will be in `dist/` and can be installed with `pip install dist/trellis_datamodel-*.whl`.
122
+
123
+ ## CLI Options
124
+
125
+ ```bash
126
+ trellis run [OPTIONS]
127
+
128
+ Options:
129
+ --port, -p INTEGER Port to run the server on [default: 8089]
130
+ --config, -c TEXT Path to config file (trellis.yml or config.yml)
131
+ --no-browser Don't open browser automatically
132
+ --help Show help message
133
+ ```
134
+
135
+ ## dbt Metadata
136
+ - Generate `manifest.json` and `catalog.json` by running `dbt docs generate` in your dbt project.
137
+ - The UI reads these artifacts to power the ERD modeller.
138
+ - Without these artifacts, the UI loads but shows no dbt models.
139
+
140
+ ## Configuration
141
+
142
+ Run `trellis init` to create a starter `trellis.yml` file in your project.
143
+
144
+ Options:
145
+
146
+ - `framework`: Transformation framework to use. Currently supported: `dbt-core`. Future: `dbt-fusion`, `sqlmesh`, `bruin`, `pydantic`. Defaults to `dbt-core`.
147
+ - `dbt_project_path`: Path to your dbt project directory (relative to `config.yml` or absolute). **Required**.
148
+ - `dbt_manifest_path`: Path to `manifest.json` (relative to `dbt_project_path` or absolute). Defaults to `target/manifest.json`.
149
+ - `dbt_catalog_path`: Path to `catalog.json` (relative to `dbt_project_path` or absolute). Defaults to `target/catalog.json`.
150
+ - `data_model_file`: Path where the data model YAML will be saved (relative to `dbt_project_path` or absolute). Defaults to `data_model.yml`.
151
+ - `dbt_model_paths`: List of path patterns to filter which dbt models are shown (e.g., `["3_core"]`). If empty, all models are included.
152
+
153
+ **Example `trellis.yml`:**
154
+ ```yaml
155
+ framework: dbt-core
156
+ dbt_project_path: "./dbt_built"
157
+ dbt_manifest_path: "target/manifest.json"
158
+ dbt_catalog_path: "target/catalog.json"
159
+ data_model_file: "data_model.yml"
160
+ dbt_model_paths:
161
+ - "3_core"
162
+ ```
163
+
164
+
165
+ ## Testing
166
+
167
+ ### Frontend
168
+ **Testing Libraries:**
169
+ The following testing libraries are defined in `package.json` under `devDependencies` and are automatically installed when you run `npm install`:
170
+ - [Vitest](https://vitest.dev/) (Unit testing)
171
+ - [Playwright](https://playwright.dev/) (End-to-End testing)
172
+ - [Testing Library](https://testing-library.com/) (DOM & Svelte testing utilities)
173
+ - [jsdom](https://github.com/jsdom/jsdom) (DOM environment)
174
+
175
+ > **Playwright system dependencies (Ubuntu/WSL2)**
176
+ >
177
+ > The browsers downloaded by Playwright need a handful of native libraries. Install them before running `npm run test:e2e`:
178
+ >
179
+ > ```bash
180
+ > sudo apt-get update && sudo apt-get install -y \
181
+ > libxcursor1 libxdamage1 libgtk-3-0 libpangocairo-1.0-0 libpango-1.0-0 \
182
+ > libatk1.0-0 libcairo-gobject2 libcairo2 libgdk-pixbuf-2.0-0 libasound2 \
183
+ > libnspr4 libnss3 libgbm1 libgles2-mesa libgtk-4-1 libgraphene-1.0-0 \
184
+ > libxslt1.1 libwoff2dec0 libvpx7 libevent-2.1-7 libopus0 \
185
+ > libgstallocators-1.0-0 libgstapp-1.0-0 libgstpbutils-1.0-0 libgstaudio-1.0-0 \
186
+ > libgsttag-1.0-0 libgstvideo-1.0-0 libgstgl-1.0-0 libgstcodecparsers-1.0-0 \
187
+ > libgstfft-1.0-0 libflite1 libflite1-plugins libwebpdemux2 libavif13 \
188
+ > libharfbuzz-icu0 libwebpmux3 libenchant-2-2 libsecret-1-0 libhyphen0 \
189
+ > libwayland-server0 libmanette-0.2-0 libx264-163
190
+ > ```
191
+
192
+ **Running Tests:**
193
+
194
+ The test suite has multiple levels to catch different types of issues:
195
+
196
+ ```bash
197
+ cd frontend
198
+
199
+ # Quick smoke test (catches 500 errors, runtime crashes, ESM issues)
200
+ # Fastest way to verify the app loads without errors
201
+ npm run test:smoke
202
+
203
+ # TypeScript/compilation check
204
+ npm run check
205
+
206
+ # Unit tests
207
+ npm run test:unit
208
+
209
+ # E2E tests (includes smoke test + full test suite)
210
+ # Note: Requires backend running with test data (see Test Data Isolation below)
211
+ npm run test:e2e
212
+
213
+ # Run all tests (check + smoke + unit + e2e)
214
+ npm run test
215
+ ```
216
+
217
+ **Test Levels:**
218
+ 1. **`npm run check`** - TypeScript compilation errors
219
+ 2. **`npm run test:smoke`** - Runtime errors (500s, console errors, ESM issues) - **catches app crashes**
220
+ 3. **`npm run test:unit`** - Unit tests with Vitest
221
+ 4. **`npm run test:e2e`** - Full E2E tests with Playwright
222
+
223
+ **Using Makefile:**
224
+ ```bash
225
+ # From project root
226
+ make test-smoke # Quick smoke test
227
+ make test-check # TypeScript check
228
+ make test-unit # Unit tests
229
+ make test-e2e # E2E tests (auto-starts backend with test data)
230
+ make test-all # All tests
231
+ ```
232
+
233
+ **Test Data Isolation:**
234
+ E2E tests use a separate test data file (`frontend/tests/test_data_model.yml`) to avoid polluting your production data model. **Playwright automatically starts the backend** with the correct environment variable, so you don't need to manage it manually.
235
+
236
+ ```bash
237
+ # Just run E2E tests - backend starts automatically with test data
238
+ make test-e2e
239
+ # OR:
240
+ # cd frontend && npm run test:e2e
241
+ ```
242
+
243
+ The test data file is automatically cleaned before and after test runs via Playwright's `globalSetup` and `globalTeardown`. Your production `data_model.yml` remains untouched.
244
+
245
+ ### Backend
246
+ **Testing Libraries:**
247
+ The following testing libraries are defined in `pyproject.toml` under `[project.optional-dependencies]` in the `dev` group:
248
+ - [pytest](https://docs.pytest.org/) (Testing framework)
249
+ - [httpx](https://www.python-httpx.org/) (Async HTTP client for API testing)
250
+
251
+ **Installation:**
252
+ Unlike `npm`, `uv sync` does not install optional dependencies by default. To include the testing libraries, run:
253
+ ```bash
254
+ cd backend
255
+ uv sync --extra dev
256
+ ```
257
+
258
+ **Running Tests:**
259
+ ```bash
260
+ cd backend
261
+ uv run pytest
262
+ ```
@@ -0,0 +1,71 @@
1
+ [build-system]
2
+ requires = ["setuptools>=61.0", "wheel"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "trellis-datamodel"
7
+ version = "0.1.2"
8
+ description = "Visual data model editor for dbt projects"
9
+ readme = "README.md"
10
+ requires-python = ">=3.11"
11
+ authors = [
12
+ {name = "Tim Hiebenthal"},
13
+ ]
14
+ keywords = ["dbt", "data-modeling", "erd", "data-engineering", "analytics-engineering", "visualization", "schema"]
15
+ classifiers = [
16
+ "Development Status :: 4 - Beta",
17
+ "Intended Audience :: Developers",
18
+ "Programming Language :: Python :: 3",
19
+ "Programming Language :: Python :: 3.11",
20
+ "Programming Language :: Python :: 3.12",
21
+ "Topic :: Database",
22
+ "Topic :: Software Development :: Libraries :: Python Modules",
23
+ ]
24
+ dependencies = [
25
+ "dbt-core>=1.6,<2.0",
26
+ "fastapi>=0.121.3",
27
+ "python-dotenv>=1.2.1",
28
+ "pyyaml>=6.0.3",
29
+ "ruamel.yaml>=0.18.0",
30
+ "typer>=0.9.0",
31
+ "uvicorn>=0.38.0",
32
+ ]
33
+
34
+ [project.urls]
35
+ Homepage = "https://github.com/timhiebenthal/trellis-datamodel"
36
+ Repository = "https://github.com/timhiebenthal/trellis-datamodel"
37
+ Issues = "https://github.com/timhiebenthal/trellis-datamodel/issues"
38
+
39
+ [project.scripts]
40
+ trellis = "trellis_datamodel.cli:app"
41
+
42
+ [project.optional-dependencies]
43
+ dev = [
44
+ "pytest>=8.0.0",
45
+ "httpx>=0.27.0",
46
+ ]
47
+ examples = [
48
+ "dbt-duckdb==1.10",
49
+ "duckdb>=1.4.2",
50
+ "marimo>=0.18.0",
51
+ "nba-api>=1.11.3",
52
+ "pandas>=2.3.3",
53
+ "tqdm>=4.67.1",
54
+ ]
55
+
56
+ [tool.setuptools.packages.find]
57
+ where = ["."]
58
+ include = ["trellis_datamodel*"]
59
+
60
+ [tool.setuptools.package-data]
61
+ trellis_datamodel = ["static/**/*"]
62
+
63
+ [tool.pytest.ini_options]
64
+ testpaths = ["trellis_datamodel/tests"]
65
+ pythonpath = ["."]
66
+
67
+ [dependency-groups]
68
+ dev = [
69
+ "httpx>=0.28.1",
70
+ "pytest>=9.0.1",
71
+ ]
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,3 @@
1
+ """Trellis Data - Visual data model editor for dbt projects."""
2
+
3
+ __version__ = "0.1.2"
@@ -0,0 +1,47 @@
1
+ """
2
+ Adapter factory for transformation framework integrations.
3
+
4
+ Provides get_adapter() to instantiate the appropriate adapter based on config.
5
+ """
6
+
7
+ from typing import Union
8
+
9
+ from trellis_datamodel.config import (
10
+ FRAMEWORK,
11
+ MANIFEST_PATH,
12
+ CATALOG_PATH,
13
+ DBT_PROJECT_PATH,
14
+ DATA_MODEL_PATH,
15
+ DBT_MODEL_PATHS,
16
+ )
17
+ from .base import TransformationAdapter
18
+ from .dbt_core import DbtCoreAdapter
19
+
20
+
21
+ def get_adapter() -> Union[DbtCoreAdapter, TransformationAdapter]:
22
+ """
23
+ Get the appropriate adapter based on the configured framework.
24
+
25
+ Returns:
26
+ An adapter instance implementing TransformationAdapter.
27
+
28
+ Raises:
29
+ ValueError: If the configured framework is not supported.
30
+ """
31
+ if FRAMEWORK == "dbt-core":
32
+ return DbtCoreAdapter(
33
+ manifest_path=MANIFEST_PATH,
34
+ catalog_path=CATALOG_PATH,
35
+ project_path=DBT_PROJECT_PATH,
36
+ data_model_path=DATA_MODEL_PATH,
37
+ model_paths=DBT_MODEL_PATHS,
38
+ )
39
+
40
+ raise ValueError(
41
+ f"Unknown framework: {FRAMEWORK}. "
42
+ f"Supported frameworks: dbt-core"
43
+ )
44
+
45
+
46
+ __all__ = ["get_adapter", "TransformationAdapter", "DbtCoreAdapter"]
47
+