sql-dag-flow 0.7.0__tar.gz → 0.8.0__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 (25) hide show
  1. {sql_dag_flow-0.7.0/src/sql_dag_flow.egg-info → sql_dag_flow-0.8.0}/PKG-INFO +9 -2
  2. {sql_dag_flow-0.7.0 → sql_dag_flow-0.8.0}/README.md +186 -181
  3. {sql_dag_flow-0.7.0 → sql_dag_flow-0.8.0}/pyproject.toml +48 -41
  4. {sql_dag_flow-0.7.0 → sql_dag_flow-0.8.0}/src/sql_dag_flow/main.py +75 -68
  5. {sql_dag_flow-0.7.0 → sql_dag_flow-0.8.0}/src/sql_dag_flow/parser.py +268 -163
  6. sql_dag_flow-0.7.0/src/sql_dag_flow/static/assets/index-BqmvUL2G.js → sql_dag_flow-0.8.0/src/sql_dag_flow/static/assets/index-BHIrhtIc.js +48 -48
  7. {sql_dag_flow-0.7.0 → sql_dag_flow-0.8.0}/src/sql_dag_flow/static/index.html +1 -1
  8. {sql_dag_flow-0.7.0 → sql_dag_flow-0.8.0/src/sql_dag_flow.egg-info}/PKG-INFO +9 -2
  9. {sql_dag_flow-0.7.0 → sql_dag_flow-0.8.0}/src/sql_dag_flow.egg-info/SOURCES.txt +5 -5
  10. {sql_dag_flow-0.7.0 → sql_dag_flow-0.8.0}/src/sql_dag_flow.egg-info/requires.txt +3 -0
  11. sql_dag_flow-0.8.0/tests/test_consistency.py +59 -0
  12. sql_dag_flow-0.8.0/tests/test_graph.py +151 -0
  13. sql_dag_flow-0.8.0/tests/test_identity.py +171 -0
  14. sql_dag_flow-0.7.0/src/sql_dag_flow/test_api_endpoints.py +0 -44
  15. sql_dag_flow-0.7.0/src/sql_dag_flow/test_parser.py +0 -29
  16. sql_dag_flow-0.7.0/src/sql_dag_flow/verify_counts.py +0 -21
  17. {sql_dag_flow-0.7.0 → sql_dag_flow-0.8.0}/LICENSE +0 -0
  18. {sql_dag_flow-0.7.0 → sql_dag_flow-0.8.0}/MANIFEST.in +0 -0
  19. {sql_dag_flow-0.7.0 → sql_dag_flow-0.8.0}/setup.cfg +0 -0
  20. {sql_dag_flow-0.7.0 → sql_dag_flow-0.8.0}/src/sql_dag_flow/__init__.py +0 -0
  21. {sql_dag_flow-0.7.0 → sql_dag_flow-0.8.0}/src/sql_dag_flow/static/assets/index-HIS38g9M.css +0 -0
  22. {sql_dag_flow-0.7.0 → sql_dag_flow-0.8.0}/src/sql_dag_flow/static/vite.svg +0 -0
  23. {sql_dag_flow-0.7.0 → sql_dag_flow-0.8.0}/src/sql_dag_flow.egg-info/dependency_links.txt +0 -0
  24. {sql_dag_flow-0.7.0 → sql_dag_flow-0.8.0}/src/sql_dag_flow.egg-info/entry_points.txt +0 -0
  25. {sql_dag_flow-0.7.0 → sql_dag_flow-0.8.0}/src/sql_dag_flow.egg-info/top_level.txt +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: sql-dag-flow
3
- Version: 0.7.0
3
+ Version: 0.8.0
4
4
  Summary: A sophisticated SQL lineage visualization tool for Medallion Architectures.
5
5
  Author-email: Flavio Sandoval <dsandovalflavio@gmail.com>
6
6
  License: MIT
@@ -21,6 +21,8 @@ Requires-Dist: uvicorn
21
21
  Requires-Dist: sqlglot
22
22
  Requires-Dist: networkx
23
23
  Requires-Dist: pydantic
24
+ Provides-Extra: dev
25
+ Requires-Dist: pytest>=7; extra == "dev"
24
26
  Dynamic: license-file
25
27
 
26
28
  # SQL DAG Flow
@@ -58,8 +60,11 @@ Specially optimized for the **Medallion Architecture** (Bronze, Silver, Gold) an
58
60
 
59
61
  ### 🔍 Visualization & Analysis
60
62
  * **Automatic Parsing**: Recursively scans `.sql` files to detect dependencies (`FROM`, `JOIN`, `CTE`s) using `sqlglot`.
63
+ * **Trustworthy Lineage (New in v0.8.0 🎯)**: Every `.sql` file appears exactly once, even when two folders hold the same filename (`staging/customers.sql` and `marts/customers.sql` no longer overwrite each other — they're addressed by path). Dependency resolution is strict: a reference naming a dataset will never be matched to a model in a *different* dataset, and an ambiguous name draws no edge at all. Anything unresolved, ambiguous or duplicated is reported in a warnings banner instead of failing silently — a missing edge you can see beats a wrong edge you can't.
61
64
  * **Persistent File Cache (New in v0.6.0 ⚡)**: Avoids re-parsing unchanged SQL files across application restarts. Instantly loads your DAG on consecutive days.
62
65
  * **Selective Processing (New in v0.6.0 🚀)**: Dramatically improves performance on large projects (10x-20x) by only analyzing visible nodes for complex features like Qualify Columns and Column-Level Lineage.
66
+ * **Scoped Views (New in v0.7.0 🎯)**: A saved diagram is now a *scope*. Reopening or refreshing it only re-parses the models actually on your canvas, so parsing stays proportional to your view instead of your whole project — and newly added `.sql` files never flood a curated architecture.
67
+ * **Scan New Models (New in v0.7.0 🔎)**: A pure filesystem diff (zero SQL parsing, instant on huge projects) that surfaces `.sql` files not yet on your canvas, so you pull them in on demand instead of re-indexing everything.
63
68
  * **Medallion Architecture Support**: Automatically categorizes and colors nodes based on folder structure (Bronze, Silver, Gold).
64
69
  * **Advanced Discovery Mode (Improved in v0.6.0 👻)**: Visualize "Ghost Nodes" (missing files or external tables). Includes specific filters to show **Both**, **Only External**, or **Only CTEs**.
65
70
  * **CTE Visualization**: Detects internal Common Table Expressions and displays them as distinct Pink nodes.
@@ -91,6 +96,7 @@ Specially optimized for the **Medallion Architecture** (Bronze, Silver, Gold) an
91
96
 
92
97
  ### 📊 Discovery & Analysis Tools
93
98
  * **Impact Analysis**: Visualize blast radius before making changes. Highlights downstream models, column usage, and risk levels.
99
+ * **Git Blast Radius (New in v0.7.0 🌿)**: Highlights the models changed in your git working tree — or versus a base branch — together with every downstream model they affect. The "what does this PR break?" view, rendered directly on the canvas.
94
100
  * **Diff View on Refresh**: Automatically summarizes added, removed, and modified nodes/edges after code changes.
95
101
  * **Column Usage Tracking (Improved in v0.4.9 🔧)**: Schema Preview shows which specific columns are used by downstream consumers. Uses `sqlglot.optimizer.qualify_columns` for precise resolution of unqualified column references.
96
102
  * **Staleness Detection**: Automatically flags inactive models (`Last Modified > 90d` = Stale) to help clean up legacy pipelines.
@@ -103,6 +109,7 @@ Specially optimized for the **Medallion Architecture** (Bronze, Silver, Gold) an
103
109
  * **SQL Syntax Validation (New in v0.4.9 🆕)**: Detects SQL parse errors and displays structured warnings with line/column references. Shows ⚠️ badge on nodes with syntax issues.
104
110
  * **Large DAG Support & Safe Cycle Detection (New in v0.5.1 🚀)**: Optimized cycle detection algorithm prevents backend hanging and "Failed to fetch" browser errors when analyzing massive projects (50+ nodes). Employs quick DAG verifications and bounded iterator loops.
105
111
  * **Performance Optimizations (v0.6.0 ⚡)**: Combines a new `.sqldagflow` persistent disk cache with visibility-based selective processing to make large DAG refreshes virtually instantaneous.
112
+ * **Performance Overhaul (New in v0.7.0 ⚡)**: Scoped parsing keeps the heavy `sqlglot` work proportional to your view; the Data Dictionary export no longer parses the entire project just to export a handful of models; upstream/downstream counts are computed in a single topological pass instead of one graph traversal per node; and the canvas virtualizes off-screen nodes and stops re-rendering every node on each refresh.
106
113
  * **Batch Hide from Toolbar**: Select multiple nodes → click "Hide" in the selection toolbar to hide them all at once.
107
114
  * **Discovery Mode Fix**: Ghost nodes from Discovery Mode are now hidden when their connected source nodes are hidden, preventing orphan ghost nodes.
108
115
 
@@ -149,7 +156,7 @@ Install easily via `pip`:
149
156
  pip install sql-dag-flow
150
157
  ```
151
158
 
152
- To update to the latest version (**v0.7.0**):
159
+ To update to the latest version (**v0.8.0**):
153
160
 
154
161
  ```bash
155
162
  pip install --upgrade sql-dag-flow
@@ -1,181 +1,186 @@
1
- # SQL DAG Flow
2
-
3
- > **"Static Data Lineage for Modern Data Engineers. No databases, just code."**
4
-
5
- **SQL DAG Flow** is a lightweight, open-source Python library designed to transform your SQL code into visual architecture.
6
-
7
- Unlike traditional lineage tools that require active database connections or query log access, **SQL DAG Flow** performs **static analysis (parsing)** of your local `.sql` files. This allows for instant, secure dependency visualization, bottleneck identification, and Data Lineage documentation without leaving your development environment.
8
-
9
- Specially optimized for the **Medallion Architecture** (Bronze, Silver, Gold) and modern stacks (DuckDB, BigQuery, Snowflake), it bridges the gap between the code you write and the architecture you design.
10
-
11
- ## 💡 Philosophy: Why this exists
12
-
13
- * **Local-First & Zero-Config**: You don't need to configure servers, cloud credentials, or Docker containers. If you have SQL files, you have a diagram.
14
- * **Security by Design**: By relying on static analysis, your code never leaves your machine and no access to sensitive production data is required.
15
- * **Living Documentation**: The diagram is generated *from* the code. If the code changes, the documentation updates, eliminating obsolete manually-drawn diagrams.
16
-
17
- ---
18
-
19
- ## 🎯 Objectives & Use Cases
20
-
21
- * **1. Legacy Code Audit & Refactoring**:
22
- * *The Problem*: You join a new project with 200+ undocumented SQL scripts. Nobody knows what breaks what.
23
- * *The Solution*: Run `sql-dag-flow` to instantly map the "spaghetti" dependencies. Identify orphan tables, circular dependencies, and the impact of changing a Silver layer table.
24
- * *The Solution*: Generate interactive pipeline visualizations (ETL/ELT) to include in your Pull Requests, Wikis, or client deliverables.
25
- * **3. Medallion Architecture Validation**:
26
- * *The Problem*: It's hard to verify if the logical separation of layers (Bronze → Silver → Gold) is being respected.
27
- * *The Solution*: The tool visually groups your scripts by folder structure, allowing you to validate that data flows correctly between quality layers without improper "jumps".
28
- * **4. Accelerated Onboarding**:
29
- * *The Problem*: Explaining data flow to new engineers takes hours of whiteboard drawing.
30
- * *The Solution*: Deliver an interactive map where new team members can explore where data comes from, view associated SQL code, and understand business logic without reading thousands of lines of code.
31
-
32
- ## 🚀 Key Features
33
-
34
- ### 🔍 Visualization & Analysis
35
- * **Automatic Parsing**: Recursively scans `.sql` files to detect dependencies (`FROM`, `JOIN`, `CTE`s) using `sqlglot`.
36
- * **Persistent File Cache (New in v0.6.0 ⚡)**: Avoids re-parsing unchanged SQL files across application restarts. Instantly loads your DAG on consecutive days.
37
- * **Selective Processing (New in v0.6.0 🚀)**: Dramatically improves performance on large projects (10x-20x) by only analyzing visible nodes for complex features like Qualify Columns and Column-Level Lineage.
38
- * **Medallion Architecture Support**: Automatically categorizes and colors nodes based on folder structure (Bronze, Silver, Gold).
39
- * **Advanced Discovery Mode (Improved in v0.6.0 👻)**: Visualize "Ghost Nodes" (missing files or external tables). Includes specific filters to show **Both**, **Only External**, or **Only CTEs**.
40
- * **CTE Visualization**: Detects internal Common Table Expressions and displays them as distinct Pink nodes.
41
- * **Smart Layout (New 🧠)**:
42
- * Powered by **ELK (Eclipse Layout Kernel)**.
43
- * Minimizes edge crossings and optimizes flow direction.
44
- * Intelligent "Port" handling for cleaner connections.
45
- * **Startup Configuration Selector**: Instantly resume previous sessions by selecting any `.json` configuration file found in your project directory upon launching the app.
46
-
47
- ### 🎮 Interactive Graph
48
- * **Smart Context Menu**:
49
- * **Focus Tree**: Isolate a node and its lineage (ancestors + descendants) to declutter the view.
50
- * **Select Tree**: One-click selection of an entire dependency chain for easy movement.
51
- * **Hide/Show**: Toggle visibility of individual nodes or full branches.
52
- * **Advanced Navigation**:
53
- * **Sidebar**: Grouped list of nodes with toggle between **By Layer** and **By Project/Dataset** views.
54
- * **Command Palette (Cmd+P)**: Instantly search and navigate to nodes across large projects.
55
- * **Keyboard Arrow Navigation**: Rapidly explore lineage by moving ← (upstream) and → (downstream) between connected nodes.
56
- * **Breadcrumb Trail**: Maintain context while drilling down with a visual history of visited nodes.
57
- * **SQL Content Search**: Search inside SQL file content across all nodes — find WHERE clauses, JOINs, or any keyword.
58
- * **Details Panel**: View formatted SQL code, schema preview (DDL, CTAS, Views), node configuration, and add **custom descriptions** to document models.
59
-
60
- ### 📝 Notes & Annotations
61
- * **Center Placement**: New notes spawn exactly in the center of your view.
62
- * **Rich Styling**:
63
- * **Markdown Support**: Write rich text notes.
64
- * **Transparent & Borderless**:Create clean, floating text labels without boxes.
65
- * **Groups**: Create visual containers to group related nodes.
66
-
67
- ### 📊 Discovery & Analysis Tools
68
- * **Impact Analysis**: Visualize blast radius before making changes. Highlights downstream models, column usage, and risk levels.
69
- * **Diff View on Refresh**: Automatically summarizes added, removed, and modified nodes/edges after code changes.
70
- * **Column Usage Tracking (Improved in v0.4.9 🔧)**: Schema Preview shows which specific columns are used by downstream consumers. Uses `sqlglot.optimizer.qualify_columns` for precise resolution of unqualified column references.
71
- * **Staleness Detection**: Automatically flags inactive models (`Last Modified > 90d` = Stale) to help clean up legacy pipelines.
72
- * **Business Rule Extraction**: Automatically detects and displays WHERE filters, CASE logic, HAVING clauses, and aggregations from each SQL model.
73
- * **Complexity Scoring**: Weighted metric per node (JOINs×3, CTEs×2, Subqueries×3, Filters×1, CASE×2, Aggregations×1, UNIONs×2) with color-coded badges (🟢 Low, 🟡 Medium, 🟠 High, 🔴 Very High). Toggleable via ⚡ button.
74
- * **Node Comparison**: Select exactly 2 nodes and compare them side-by-side. Highlights differences across metadata, schema columns (shared vs unique), dependencies (Venn-style), complexity scores (with delta indicators), business rules, and SQL content (synced scroll).
75
- * **Statistics Panel**: Centered popup with layer distribution bars, edge/source/sink/orphan counts, project/dataset tree, and architecture health validation (now detects **circular dependencies**).
76
- * **Schema Extraction**: Backend AST-based extraction via `sqlglot` handles DDL, CTAS, `CREATE VIEW AS`, CTEs, window functions, CASE expressions, and `SELECT *`.
77
- * **Column-Level Lineage (New in v0.4.9 🆕)**: Traces how each output column derives from source columns. Shows transformation chain (e.g., `order_timestamp ← orders_raw.order_date via CAST(... AS DATETIME)`).
78
- * **SQL Syntax Validation (New in v0.4.9 🆕)**: Detects SQL parse errors and displays structured warnings with line/column references. Shows ⚠️ badge on nodes with syntax issues.
79
- * **Large DAG Support & Safe Cycle Detection (New in v0.5.1 🚀)**: Optimized cycle detection algorithm prevents backend hanging and "Failed to fetch" browser errors when analyzing massive projects (50+ nodes). Employs quick DAG verifications and bounded iterator loops.
80
- * **Performance Optimizations (v0.6.0 ⚡)**: Combines a new `.sqldagflow` persistent disk cache with visibility-based selective processing to make large DAG refreshes virtually instantaneous.
81
- * **Batch Hide from Toolbar**: Select multiple nodes → click "Hide" in the selection toolbar to hide them all at once.
82
- * **Discovery Mode Fix**: Ghost nodes from Discovery Mode are now hidden when their connected source nodes are hidden, preventing orphan ghost nodes.
83
-
84
- ### 🎨 Linear-Inspired UI (New in v0.4.6 ✨)
85
- * **Design Token System**: ~80 CSS custom properties for consistent theming across all components.
86
- * **Premium Dark Theme**: Deep `#0d0d0d` canvas with warm white text (`#e8e8e6`), never pure white.
87
- * **Refined Light Theme**: Warm off-white `#f7f6f3` backgrounds — never harsh pure white.
88
- * **Glassmorphism Toolbars**: `backdrop-filter: blur(16px)` on all floating panels.
89
- * **Violet-Indigo Accent**: Premium `#7c6aef` accent color replacing generic blues/greens.
90
- * **Smooth Animations**: `fadeIn` and `slideUp` micro-animations on popovers and modals.
91
- * **Custom Scrollbars**: Subtle, styled scrollbars matching the theme.
92
- * **Focus Rings**: Accessible focus indicators using the accent color.
93
-
94
- ### ⚙️ Customization & Export
95
- * **Premium UI**:
96
- * **Themes**: Toggle between Light and Dark modes.
97
- * **Palettes**: Choose from **Standard**, **Vivid**, **Pastel**, or **Linear** (LCH-inspired tones) color schemes.
98
- * **Styles**: Switch between "Full" (colored body) and "Minimal" (colored border) node styles.
99
- * **Export Dictionary**: Generate and download a comprehensive Markdown Data Dictionary report of your entire DAG.
100
- * **Export Graph**: Save high-resolution **PNG** or vector **SVG** diagrams for documentation.
101
-
102
- ---
103
-
104
- ## 🎨 Visual Legend & Color Palettes
105
-
106
- SQL DAG Flow uses distinct colors to identify node types. You can switch between these palettes in the Settings.
107
-
108
- | Node Type | Layer / Meaning | Standard | Vivid | Pastel | Linear |
109
- | :--- | :--- | :--- | :--- | :--- | :--- |
110
- | **Bronze** | Raw Ingestion | 🟤 Brown (`#8B4513`) | 🟠 Warm (`#E8734A`) | 🟤 Sand (`#DCC1B0`) | 🟤 Muted (`#B08968`) |
111
- | **Silver** | Cleaned / Conformed | ⚪ Gray (`#708090`) | 🔵 Ocean (`#5CA8D3`) | ⚪ Fog (`#B8C5D0`) | ⚪ Slate (`#8E99A4`) |
112
- | **Gold** | Business Aggregates | 🟡 Gold (`#DAA520`) | 🟡 Amber (`#F0C75E`) | 🟡 Cream (`#F0E4B8`) | 🟡 Warm (`#D4A843`) |
113
- | **External** | Missing / Ghost Node | 🟠 Rust (`#C06430`) | 🟠 Spice (`#E8943A`) | 🟠 Peach (`#E8D0A8`) | 🟠 Sand (`#CC8B5E`) |
114
- | **CTE** | Internal Common Table Expression | 💖 Pink (`#E91E63`) | 💜 Rose (`#D45B8C`) | 🌸 Blush (`#DAAFC0`) | 💜 Mauve (`#C77092`) |
115
- | **Other** | Uncategorized | 🔵 Teal (`#4CA1AF`) | 💠 Aqua (`#4AABB8`) | 🧊 Mist (`#A8D0D8`) | 🔵 Ocean (`#6B9DAD`) |
116
-
117
- ---
118
-
119
- ## 📦 Installation
120
-
121
- Install easily via `pip`:
122
-
123
- ```bash
124
- pip install sql-dag-flow
125
- ```
126
-
127
- To update to the latest version (**v0.7.0**):
128
-
129
- ```bash
130
- pip install --upgrade sql-dag-flow
131
- ```
132
-
133
- ---
134
-
135
- ## ▶️ Usage
136
-
137
- ### 1. Command Line Interface (CLI)
138
-
139
- Run directly from your terminal:
140
-
141
- ```bash
142
- # Analyze the current directory
143
- sql-dag-flow
144
-
145
- # Analyze a specific SQL project
146
- sql-dag-flow /path/to/my/dbt_project
147
- ```
148
-
149
- ### 2. Python API
150
-
151
- Integrate into your workflows:
152
-
153
- ```python
154
- from sql_dag_flow import start
155
-
156
- # Start the server and open the browser
157
- start(directory="./my_sql_project")
158
- ```
159
-
160
- ---
161
-
162
- ## 📂 Project Structure Expectations
163
-
164
- SQL DAG Flow looks for standard Medallion Architecture naming conventions:
165
-
166
- * **Bronze Layer**: Folders named `bronze`, `raw`, `landing`, or `staging`.
167
- * **Silver Layer**: Folders named `silver`, `intermediate`, or `conformed`.
168
- * **Gold Layer**: Folders named `gold`, `mart`, `serving`, or `presentation`.
169
- * **Other**: Any other folder is categorized as "Other" (Teal).
170
-
171
- ---
172
-
173
- ## 🤝 Contributing
174
-
175
- Contributions are welcome!
176
- 1. Fork the repository.
177
- 2. Create a feature branch.
178
- 3. Submit a Pull Request.
179
-
180
- ---
181
- *Created by [Flavio Sandoval](https://github.com/dsandovalflavio)*
1
+ # SQL DAG Flow
2
+
3
+ > **"Static Data Lineage for Modern Data Engineers. No databases, just code."**
4
+
5
+ **SQL DAG Flow** is a lightweight, open-source Python library designed to transform your SQL code into visual architecture.
6
+
7
+ Unlike traditional lineage tools that require active database connections or query log access, **SQL DAG Flow** performs **static analysis (parsing)** of your local `.sql` files. This allows for instant, secure dependency visualization, bottleneck identification, and Data Lineage documentation without leaving your development environment.
8
+
9
+ Specially optimized for the **Medallion Architecture** (Bronze, Silver, Gold) and modern stacks (DuckDB, BigQuery, Snowflake), it bridges the gap between the code you write and the architecture you design.
10
+
11
+ ## 💡 Philosophy: Why this exists
12
+
13
+ * **Local-First & Zero-Config**: You don't need to configure servers, cloud credentials, or Docker containers. If you have SQL files, you have a diagram.
14
+ * **Security by Design**: By relying on static analysis, your code never leaves your machine and no access to sensitive production data is required.
15
+ * **Living Documentation**: The diagram is generated *from* the code. If the code changes, the documentation updates, eliminating obsolete manually-drawn diagrams.
16
+
17
+ ---
18
+
19
+ ## 🎯 Objectives & Use Cases
20
+
21
+ * **1. Legacy Code Audit & Refactoring**:
22
+ * *The Problem*: You join a new project with 200+ undocumented SQL scripts. Nobody knows what breaks what.
23
+ * *The Solution*: Run `sql-dag-flow` to instantly map the "spaghetti" dependencies. Identify orphan tables, circular dependencies, and the impact of changing a Silver layer table.
24
+ * *The Solution*: Generate interactive pipeline visualizations (ETL/ELT) to include in your Pull Requests, Wikis, or client deliverables.
25
+ * **3. Medallion Architecture Validation**:
26
+ * *The Problem*: It's hard to verify if the logical separation of layers (Bronze → Silver → Gold) is being respected.
27
+ * *The Solution*: The tool visually groups your scripts by folder structure, allowing you to validate that data flows correctly between quality layers without improper "jumps".
28
+ * **4. Accelerated Onboarding**:
29
+ * *The Problem*: Explaining data flow to new engineers takes hours of whiteboard drawing.
30
+ * *The Solution*: Deliver an interactive map where new team members can explore where data comes from, view associated SQL code, and understand business logic without reading thousands of lines of code.
31
+
32
+ ## 🚀 Key Features
33
+
34
+ ### 🔍 Visualization & Analysis
35
+ * **Automatic Parsing**: Recursively scans `.sql` files to detect dependencies (`FROM`, `JOIN`, `CTE`s) using `sqlglot`.
36
+ * **Trustworthy Lineage (New in v0.8.0 🎯)**: Every `.sql` file appears exactly once, even when two folders hold the same filename (`staging/customers.sql` and `marts/customers.sql` no longer overwrite each other — they're addressed by path). Dependency resolution is strict: a reference naming a dataset will never be matched to a model in a *different* dataset, and an ambiguous name draws no edge at all. Anything unresolved, ambiguous or duplicated is reported in a warnings banner instead of failing silently — a missing edge you can see beats a wrong edge you can't.
37
+ * **Persistent File Cache (New in v0.6.0 ⚡)**: Avoids re-parsing unchanged SQL files across application restarts. Instantly loads your DAG on consecutive days.
38
+ * **Selective Processing (New in v0.6.0 🚀)**: Dramatically improves performance on large projects (10x-20x) by only analyzing visible nodes for complex features like Qualify Columns and Column-Level Lineage.
39
+ * **Scoped Views (New in v0.7.0 🎯)**: A saved diagram is now a *scope*. Reopening or refreshing it only re-parses the models actually on your canvas, so parsing stays proportional to your view instead of your whole project — and newly added `.sql` files never flood a curated architecture.
40
+ * **Scan New Models (New in v0.7.0 🔎)**: A pure filesystem diff (zero SQL parsing, instant on huge projects) that surfaces `.sql` files not yet on your canvas, so you pull them in on demand instead of re-indexing everything.
41
+ * **Medallion Architecture Support**: Automatically categorizes and colors nodes based on folder structure (Bronze, Silver, Gold).
42
+ * **Advanced Discovery Mode (Improved in v0.6.0 👻)**: Visualize "Ghost Nodes" (missing files or external tables). Includes specific filters to show **Both**, **Only External**, or **Only CTEs**.
43
+ * **CTE Visualization**: Detects internal Common Table Expressions and displays them as distinct Pink nodes.
44
+ * **Smart Layout (New 🧠)**:
45
+ * Powered by **ELK (Eclipse Layout Kernel)**.
46
+ * Minimizes edge crossings and optimizes flow direction.
47
+ * Intelligent "Port" handling for cleaner connections.
48
+ * **Startup Configuration Selector**: Instantly resume previous sessions by selecting any `.json` configuration file found in your project directory upon launching the app.
49
+
50
+ ### 🎮 Interactive Graph
51
+ * **Smart Context Menu**:
52
+ * **Focus Tree**: Isolate a node and its lineage (ancestors + descendants) to declutter the view.
53
+ * **Select Tree**: One-click selection of an entire dependency chain for easy movement.
54
+ * **Hide/Show**: Toggle visibility of individual nodes or full branches.
55
+ * **Advanced Navigation**:
56
+ * **Sidebar**: Grouped list of nodes with toggle between **By Layer** and **By Project/Dataset** views.
57
+ * **Command Palette (Cmd+P)**: Instantly search and navigate to nodes across large projects.
58
+ * **Keyboard Arrow Navigation**: Rapidly explore lineage by moving ← (upstream) and → (downstream) between connected nodes.
59
+ * **Breadcrumb Trail**: Maintain context while drilling down with a visual history of visited nodes.
60
+ * **SQL Content Search**: Search inside SQL file content across all nodes — find WHERE clauses, JOINs, or any keyword.
61
+ * **Details Panel**: View formatted SQL code, schema preview (DDL, CTAS, Views), node configuration, and add **custom descriptions** to document models.
62
+
63
+ ### 📝 Notes & Annotations
64
+ * **Center Placement**: New notes spawn exactly in the center of your view.
65
+ * **Rich Styling**:
66
+ * **Markdown Support**: Write rich text notes.
67
+ * **Transparent & Borderless**:Create clean, floating text labels without boxes.
68
+ * **Groups**: Create visual containers to group related nodes.
69
+
70
+ ### 📊 Discovery & Analysis Tools
71
+ * **Impact Analysis**: Visualize blast radius before making changes. Highlights downstream models, column usage, and risk levels.
72
+ * **Git Blast Radius (New in v0.7.0 🌿)**: Highlights the models changed in your git working tree — or versus a base branch — together with every downstream model they affect. The "what does this PR break?" view, rendered directly on the canvas.
73
+ * **Diff View on Refresh**: Automatically summarizes added, removed, and modified nodes/edges after code changes.
74
+ * **Column Usage Tracking (Improved in v0.4.9 🔧)**: Schema Preview shows which specific columns are used by downstream consumers. Uses `sqlglot.optimizer.qualify_columns` for precise resolution of unqualified column references.
75
+ * **Staleness Detection**: Automatically flags inactive models (`Last Modified > 90d` = Stale) to help clean up legacy pipelines.
76
+ * **Business Rule Extraction**: Automatically detects and displays WHERE filters, CASE logic, HAVING clauses, and aggregations from each SQL model.
77
+ * **Complexity Scoring**: Weighted metric per node (JOINs×3, CTEs×2, Subqueries×3, Filters×1, CASE×2, Aggregations×1, UNIONs×2) with color-coded badges (🟢 Low, 🟡 Medium, 🟠 High, 🔴 Very High). Toggleable via ⚡ button.
78
+ * **Node Comparison**: Select exactly 2 nodes and compare them side-by-side. Highlights differences across metadata, schema columns (shared vs unique), dependencies (Venn-style), complexity scores (with delta indicators), business rules, and SQL content (synced scroll).
79
+ * **Statistics Panel**: Centered popup with layer distribution bars, edge/source/sink/orphan counts, project/dataset tree, and architecture health validation (now detects **circular dependencies**).
80
+ * **Schema Extraction**: Backend AST-based extraction via `sqlglot` handles DDL, CTAS, `CREATE VIEW AS`, CTEs, window functions, CASE expressions, and `SELECT *`.
81
+ * **Column-Level Lineage (New in v0.4.9 🆕)**: Traces how each output column derives from source columns. Shows transformation chain (e.g., `order_timestamp ← orders_raw.order_date via CAST(... AS DATETIME)`).
82
+ * **SQL Syntax Validation (New in v0.4.9 🆕)**: Detects SQL parse errors and displays structured warnings with line/column references. Shows ⚠️ badge on nodes with syntax issues.
83
+ * **Large DAG Support & Safe Cycle Detection (New in v0.5.1 🚀)**: Optimized cycle detection algorithm prevents backend hanging and "Failed to fetch" browser errors when analyzing massive projects (50+ nodes). Employs quick DAG verifications and bounded iterator loops.
84
+ * **Performance Optimizations (v0.6.0 ⚡)**: Combines a new `.sqldagflow` persistent disk cache with visibility-based selective processing to make large DAG refreshes virtually instantaneous.
85
+ * **Performance Overhaul (New in v0.7.0 ⚡)**: Scoped parsing keeps the heavy `sqlglot` work proportional to your view; the Data Dictionary export no longer parses the entire project just to export a handful of models; upstream/downstream counts are computed in a single topological pass instead of one graph traversal per node; and the canvas virtualizes off-screen nodes and stops re-rendering every node on each refresh.
86
+ * **Batch Hide from Toolbar**: Select multiple nodes → click "Hide" in the selection toolbar to hide them all at once.
87
+ * **Discovery Mode Fix**: Ghost nodes from Discovery Mode are now hidden when their connected source nodes are hidden, preventing orphan ghost nodes.
88
+
89
+ ### 🎨 Linear-Inspired UI (New in v0.4.6 ✨)
90
+ * **Design Token System**: ~80 CSS custom properties for consistent theming across all components.
91
+ * **Premium Dark Theme**: Deep `#0d0d0d` canvas with warm white text (`#e8e8e6`), never pure white.
92
+ * **Refined Light Theme**: Warm off-white `#f7f6f3` backgrounds — never harsh pure white.
93
+ * **Glassmorphism Toolbars**: `backdrop-filter: blur(16px)` on all floating panels.
94
+ * **Violet-Indigo Accent**: Premium `#7c6aef` accent color replacing generic blues/greens.
95
+ * **Smooth Animations**: `fadeIn` and `slideUp` micro-animations on popovers and modals.
96
+ * **Custom Scrollbars**: Subtle, styled scrollbars matching the theme.
97
+ * **Focus Rings**: Accessible focus indicators using the accent color.
98
+
99
+ ### ⚙️ Customization & Export
100
+ * **Premium UI**:
101
+ * **Themes**: Toggle between Light and Dark modes.
102
+ * **Palettes**: Choose from **Standard**, **Vivid**, **Pastel**, or **Linear** (LCH-inspired tones) color schemes.
103
+ * **Styles**: Switch between "Full" (colored body) and "Minimal" (colored border) node styles.
104
+ * **Export Dictionary**: Generate and download a comprehensive Markdown Data Dictionary report of your entire DAG.
105
+ * **Export Graph**: Save high-resolution **PNG** or vector **SVG** diagrams for documentation.
106
+
107
+ ---
108
+
109
+ ## 🎨 Visual Legend & Color Palettes
110
+
111
+ SQL DAG Flow uses distinct colors to identify node types. You can switch between these palettes in the Settings.
112
+
113
+ | Node Type | Layer / Meaning | Standard | Vivid | Pastel | Linear |
114
+ | :--- | :--- | :--- | :--- | :--- | :--- |
115
+ | **Bronze** | Raw Ingestion | 🟤 Brown (`#8B4513`) | 🟠 Warm (`#E8734A`) | 🟤 Sand (`#DCC1B0`) | 🟤 Muted (`#B08968`) |
116
+ | **Silver** | Cleaned / Conformed | ⚪ Gray (`#708090`) | 🔵 Ocean (`#5CA8D3`) | ⚪ Fog (`#B8C5D0`) | ⚪ Slate (`#8E99A4`) |
117
+ | **Gold** | Business Aggregates | 🟡 Gold (`#DAA520`) | 🟡 Amber (`#F0C75E`) | 🟡 Cream (`#F0E4B8`) | 🟡 Warm (`#D4A843`) |
118
+ | **External** | Missing / Ghost Node | 🟠 Rust (`#C06430`) | 🟠 Spice (`#E8943A`) | 🟠 Peach (`#E8D0A8`) | 🟠 Sand (`#CC8B5E`) |
119
+ | **CTE** | Internal Common Table Expression | 💖 Pink (`#E91E63`) | 💜 Rose (`#D45B8C`) | 🌸 Blush (`#DAAFC0`) | 💜 Mauve (`#C77092`) |
120
+ | **Other** | Uncategorized | 🔵 Teal (`#4CA1AF`) | 💠 Aqua (`#4AABB8`) | 🧊 Mist (`#A8D0D8`) | 🔵 Ocean (`#6B9DAD`) |
121
+
122
+ ---
123
+
124
+ ## 📦 Installation
125
+
126
+ Install easily via `pip`:
127
+
128
+ ```bash
129
+ pip install sql-dag-flow
130
+ ```
131
+
132
+ To update to the latest version (**v0.8.0**):
133
+
134
+ ```bash
135
+ pip install --upgrade sql-dag-flow
136
+ ```
137
+
138
+ ---
139
+
140
+ ## ▶️ Usage
141
+
142
+ ### 1. Command Line Interface (CLI)
143
+
144
+ Run directly from your terminal:
145
+
146
+ ```bash
147
+ # Analyze the current directory
148
+ sql-dag-flow
149
+
150
+ # Analyze a specific SQL project
151
+ sql-dag-flow /path/to/my/dbt_project
152
+ ```
153
+
154
+ ### 2. Python API
155
+
156
+ Integrate into your workflows:
157
+
158
+ ```python
159
+ from sql_dag_flow import start
160
+
161
+ # Start the server and open the browser
162
+ start(directory="./my_sql_project")
163
+ ```
164
+
165
+ ---
166
+
167
+ ## 📂 Project Structure Expectations
168
+
169
+ SQL DAG Flow looks for standard Medallion Architecture naming conventions:
170
+
171
+ * **Bronze Layer**: Folders named `bronze`, `raw`, `landing`, or `staging`.
172
+ * **Silver Layer**: Folders named `silver`, `intermediate`, or `conformed`.
173
+ * **Gold Layer**: Folders named `gold`, `mart`, `serving`, or `presentation`.
174
+ * **Other**: Any other folder is categorized as "Other" (Teal).
175
+
176
+ ---
177
+
178
+ ## 🤝 Contributing
179
+
180
+ Contributions are welcome!
181
+ 1. Fork the repository.
182
+ 2. Create a feature branch.
183
+ 3. Submit a Pull Request.
184
+
185
+ ---
186
+ *Created by [Flavio Sandoval](https://github.com/dsandovalflavio)*
@@ -1,42 +1,49 @@
1
- [build-system]
2
- requires = ["setuptools>=42", "wheel"]
3
- build-backend = "setuptools.build_meta"
4
-
5
- [project]
6
- name = "sql-dag-flow"
7
- version = "0.7.0"
8
- description = "A sophisticated SQL lineage visualization tool for Medallion Architectures."
9
- readme = "README.md"
10
- requires-python = ">=3.8"
11
- license = {text = "MIT"}
12
- authors = [
13
- {name = "Flavio Sandoval", email = "dsandovalflavio@gmail.com"}
14
- ]
15
- keywords = ["sql", "lineage", "dag", "visualization", "medallion-architecture", "data-engineering"]
16
- classifiers = [
17
- "Development Status :: 4 - Beta",
18
- "Intended Audience :: Developers",
19
- "License :: OSI Approved :: MIT License",
20
- "Programming Language :: Python :: 3",
21
- "Programming Language :: Python :: 3.8",
22
- "Programming Language :: Python :: 3.9",
23
- "Programming Language :: Python :: 3.10",
24
- "Programming Language :: Python :: 3.11",
25
- ]
26
- dependencies = [
27
- "fastapi",
28
- "uvicorn",
29
- "sqlglot",
30
- "networkx",
31
- "pydantic"
32
- ]
33
-
34
- [project.scripts]
35
- sql-dag-flow = "sql_dag_flow.main:start"
36
-
37
- [tool.setuptools.packages.find]
38
- where = ["src"]
39
- include = ["sql_dag_flow*"]
40
-
41
- [tool.setuptools.package-data]
1
+ [build-system]
2
+ requires = ["setuptools>=42", "wheel"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "sql-dag-flow"
7
+ version = "0.8.0"
8
+ description = "A sophisticated SQL lineage visualization tool for Medallion Architectures."
9
+ readme = "README.md"
10
+ requires-python = ">=3.8"
11
+ license = {text = "MIT"}
12
+ authors = [
13
+ {name = "Flavio Sandoval", email = "dsandovalflavio@gmail.com"}
14
+ ]
15
+ keywords = ["sql", "lineage", "dag", "visualization", "medallion-architecture", "data-engineering"]
16
+ classifiers = [
17
+ "Development Status :: 4 - Beta",
18
+ "Intended Audience :: Developers",
19
+ "License :: OSI Approved :: MIT License",
20
+ "Programming Language :: Python :: 3",
21
+ "Programming Language :: Python :: 3.8",
22
+ "Programming Language :: Python :: 3.9",
23
+ "Programming Language :: Python :: 3.10",
24
+ "Programming Language :: Python :: 3.11",
25
+ ]
26
+ dependencies = [
27
+ "fastapi",
28
+ "uvicorn",
29
+ "sqlglot",
30
+ "networkx",
31
+ "pydantic"
32
+ ]
33
+
34
+ [project.scripts]
35
+ sql-dag-flow = "sql_dag_flow.main:start"
36
+
37
+ [project.optional-dependencies]
38
+ dev = ["pytest>=7"]
39
+
40
+ [tool.pytest.ini_options]
41
+ testpaths = ["tests"]
42
+ pythonpath = ["src", "tests"]
43
+
44
+ [tool.setuptools.packages.find]
45
+ where = ["src"]
46
+ include = ["sql_dag_flow*"]
47
+
48
+ [tool.setuptools.package-data]
42
49
  sql_dag_flow = ["static/**/*"]