dataguard-drift 0.1.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 (36) hide show
  1. dataguard_drift-0.1.0/LICENSE +21 -0
  2. dataguard_drift-0.1.0/PKG-INFO +359 -0
  3. dataguard_drift-0.1.0/README.md +315 -0
  4. dataguard_drift-0.1.0/dataguard/__init__.py +4 -0
  5. dataguard_drift-0.1.0/dataguard/cli.py +424 -0
  6. dataguard_drift-0.1.0/dataguard/core/__init__.py +18 -0
  7. dataguard_drift-0.1.0/dataguard/core/contracts.py +82 -0
  8. dataguard_drift-0.1.0/dataguard/core/drift.py +77 -0
  9. dataguard_drift-0.1.0/dataguard/core/lineage.py +85 -0
  10. dataguard_drift-0.1.0/dataguard/core/schema.py +63 -0
  11. dataguard_drift-0.1.0/dataguard/core/validator.py +166 -0
  12. dataguard_drift-0.1.0/dataguard/engine/__init__.py +3 -0
  13. dataguard_drift-0.1.0/dataguard/engine/duckdb_engine.py +100 -0
  14. dataguard_drift-0.1.0/dataguard/py.typed +0 -0
  15. dataguard_drift-0.1.0/dataguard/storage/__init__.py +25 -0
  16. dataguard_drift-0.1.0/dataguard/storage/metadata.py +227 -0
  17. dataguard_drift-0.1.0/dataguard/storage/models.py +89 -0
  18. dataguard_drift-0.1.0/dataguard/ui/__init__.py +0 -0
  19. dataguard_drift-0.1.0/dataguard/ui/dashboard.py +232 -0
  20. dataguard_drift-0.1.0/dataguard_drift.egg-info/PKG-INFO +359 -0
  21. dataguard_drift-0.1.0/dataguard_drift.egg-info/SOURCES.txt +34 -0
  22. dataguard_drift-0.1.0/dataguard_drift.egg-info/dependency_links.txt +1 -0
  23. dataguard_drift-0.1.0/dataguard_drift.egg-info/entry_points.txt +2 -0
  24. dataguard_drift-0.1.0/dataguard_drift.egg-info/requires.txt +21 -0
  25. dataguard_drift-0.1.0/dataguard_drift.egg-info/top_level.txt +1 -0
  26. dataguard_drift-0.1.0/pyproject.toml +162 -0
  27. dataguard_drift-0.1.0/setup.cfg +4 -0
  28. dataguard_drift-0.1.0/tests/test_cli.py +155 -0
  29. dataguard_drift-0.1.0/tests/test_contracts.py +39 -0
  30. dataguard_drift-0.1.0/tests/test_drift.py +91 -0
  31. dataguard_drift-0.1.0/tests/test_engine.py +85 -0
  32. dataguard_drift-0.1.0/tests/test_lineage.py +56 -0
  33. dataguard_drift-0.1.0/tests/test_metadata.py +79 -0
  34. dataguard_drift-0.1.0/tests/test_models.py +57 -0
  35. dataguard_drift-0.1.0/tests/test_schema.py +58 -0
  36. dataguard_drift-0.1.0/tests/test_validator.py +161 -0
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Ayush Varma
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,359 @@
1
+ Metadata-Version: 2.4
2
+ Name: dataguard-drift
3
+ Version: 0.1.0
4
+ Summary: Data Quality Framework with Schema Drift Detection, Validation Engine & Lineage Tracking
5
+ Author-email: Ayush Varma <ayushvarma404@gmail.com>
6
+ License-Expression: MIT
7
+ Project-URL: Homepage, https://github.com/ayushvarma7/DataGuard
8
+ Project-URL: Documentation, https://github.com/ayushvarma7/DataGuard#readme
9
+ Project-URL: Repository, https://github.com/ayushvarma7/DataGuard.git
10
+ Project-URL: Issues, https://github.com/ayushvarma7/DataGuard/issues
11
+ Keywords: data-quality,data-engineering,schema-drift,data-validation,lineage,duckdb
12
+ Classifier: Development Status :: 3 - Alpha
13
+ Classifier: Intended Audience :: Developers
14
+ Classifier: Programming Language :: Python :: 3
15
+ Classifier: Programming Language :: Python :: 3.10
16
+ Classifier: Programming Language :: Python :: 3.11
17
+ Classifier: Programming Language :: Python :: 3.12
18
+ Classifier: Programming Language :: Python :: 3.13
19
+ Classifier: Operating System :: OS Independent
20
+ Classifier: Topic :: Database
21
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
22
+ Requires-Python: >=3.10
23
+ Description-Content-Type: text/markdown
24
+ License-File: LICENSE
25
+ Requires-Dist: duckdb>=0.9.0
26
+ Requires-Dist: typer[all]>=0.9.0
27
+ Requires-Dist: rich>=13.0.0
28
+ Requires-Dist: pydantic>=2.0.0
29
+ Requires-Dist: pyyaml>=6.0
30
+ Requires-Dist: pandas>=2.0.0
31
+ Requires-Dist: pyarrow>=14.0.0
32
+ Provides-Extra: dev
33
+ Requires-Dist: pytest>=7.0.0; extra == "dev"
34
+ Requires-Dist: pytest-cov>=4.0.0; extra == "dev"
35
+ Requires-Dist: black>=23.0.0; extra == "dev"
36
+ Requires-Dist: ruff>=0.1.0; extra == "dev"
37
+ Requires-Dist: mypy>=1.0.0; extra == "dev"
38
+ Provides-Extra: ui
39
+ Requires-Dist: streamlit>=1.28.0; extra == "ui"
40
+ Requires-Dist: plotly>=5.18.0; extra == "ui"
41
+ Provides-Extra: all
42
+ Requires-Dist: dataguard-drift[dev,ui]; extra == "all"
43
+ Dynamic: license-file
44
+
45
+ # DataGuard πŸ›‘οΈ
46
+
47
+ > Data Quality Framework with Schema Drift Detection, Validation Engine & Lineage Tracking
48
+
49
+ [![Python](https://img.shields.io/badge/Python-3.10+-blue.svg)](https://python.org)
50
+ [![DuckDB](https://img.shields.io/badge/DuckDB-Latest-yellow.svg)](https://duckdb.org)
51
+ [![License](https://img.shields.io/badge/License-MIT-green.svg)](https://github.com/ayushvarma7/DataGuard/blob/main/LICENSE)
52
+
53
+ DataGuard is a lightweight, open-source data quality framework that helps data engineers catch schema changes, validate data quality, and track column-level lineageβ€”all without expensive enterprise tools.
54
+
55
+ **🌐 [Try the Live Demo (Vercel)](https://getdataguard.vercel.app/)** β€” Multi-Table Engine, SQL Lab, and interactive lineage. Your data never leaves your machine.
56
+
57
+ ---
58
+
59
+ ## ✨ Features
60
+
61
+ - **Schema Inference & Drift Detection** β€” Automatically detect when your data structure changes
62
+ - **Validation Rules Engine** β€” Define rules in YAML, get actionable failure reports
63
+ - **Lineage Tracking** β€” Track column-level data flow from source to output
64
+ - **Data Contracts** β€” Auto-generate contracts for cross-team agreements
65
+ - **Zero Cost** β€” DuckDB + SQLite, no cloud dependencies
66
+ - **Privacy First** β€” Browser demo processes files locally via WebAssembly
67
+
68
+ ---
69
+
70
+ ## πŸ—οΈ Architecture
71
+
72
+ ```
73
+ β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
74
+ β”‚ DataGuard β”‚
75
+ β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
76
+ β”‚ β”‚
77
+ β”‚ β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚
78
+ β”‚ β”‚ SOURCES β”‚ β”‚ PROCESSING β”‚ β”‚ OUTPUTS β”‚ β”‚
79
+ β”‚ β”‚ CSV/Parquet │───▢│ DuckDB │───▢│ Reports β”‚ β”‚
80
+ β”‚ β”‚ Databases β”‚ β”‚ Engine β”‚ β”‚ Alerts β”‚ β”‚
81
+ β”‚ β”‚ Excel β”‚ β”‚ β”‚ β”‚ Contracts β”‚ β”‚
82
+ β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚
83
+ β”‚ β”‚ β”‚ β”‚ β”‚
84
+ β”‚ β–Ό β–Ό β–Ό β”‚
85
+ β”‚ β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚
86
+ β”‚ β”‚ METADATA STORE (SQLite) β”‚ β”‚
87
+ β”‚ β”‚ β€’ Schema snapshots β€’ Validation history β”‚ β”‚
88
+ β”‚ β”‚ β€’ Lineage graph β€’ Data contracts β”‚ β”‚
89
+ β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚
90
+ β”‚ β”‚
91
+ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
92
+ ```
93
+
94
+ ---
95
+
96
+ ## πŸš€ Quick Start
97
+
98
+ ### Installation
99
+
100
+ ```bash
101
+ # Clone the repository
102
+ git clone https://github.com/ayushvarma7/DataGuard.git
103
+ cd DataGuard
104
+
105
+ # Create virtual environment
106
+ python -m venv venv
107
+ source venv/bin/activate # On Windows: venv\Scripts\activate
108
+
109
+ # Install dependencies
110
+ pip install -e .
111
+ ```
112
+
113
+ ### Install from PyPI
114
+
115
+ ```bash
116
+ pip install dataguard-drift # CLI + library
117
+ pip install "dataguard-drift[ui]" # + Streamlit dashboard
118
+ ```
119
+
120
+ The import name and command stay `dataguard`.
121
+
122
+ ### Basic Usage
123
+
124
+ ```bash
125
+ # Infer schema from a file
126
+ dataguard schema infer ./data/matches.csv --name matches
127
+
128
+ # Check for schema drift
129
+ dataguard schema diff matches
130
+
131
+ # Run validations
132
+ dataguard validate matches --rules ./rules/matches.yaml
133
+
134
+ # View lineage
135
+ dataguard lineage show revenue_report --format mermaid
136
+
137
+ # Generate data contract
138
+ dataguard contract generate matches
139
+
140
+ # Launch dashboard
141
+ dataguard ui
142
+ ```
143
+
144
+ ---
145
+
146
+ ## πŸ“ Project Structure
147
+
148
+ ```
149
+ dataguard/
150
+ β”œβ”€β”€ dataguard/
151
+ β”‚ β”œβ”€β”€ __init__.py
152
+ β”‚ β”œβ”€β”€ cli.py # Typer CLI application
153
+ β”‚ β”œβ”€β”€ core/
154
+ β”‚ β”‚ β”œβ”€β”€ __init__.py
155
+ β”‚ β”‚ β”œβ”€β”€ schema.py # Schema inference & drift detection
156
+ β”‚ β”‚ β”œβ”€β”€ validator.py # Validation rules engine
157
+ β”‚ β”‚ β”œβ”€β”€ lineage.py # Lineage tracking & DAG
158
+ β”‚ β”‚ └── contracts.py # Data contract generation
159
+ β”‚ β”œβ”€β”€ storage/
160
+ β”‚ β”‚ β”œβ”€β”€ __init__.py
161
+ β”‚ β”‚ β”œβ”€β”€ metadata.py # SQLite operations
162
+ β”‚ β”‚ └── models.py # Pydantic data models
163
+ β”‚ β”œβ”€β”€ engine/
164
+ β”‚ β”‚ β”œβ”€β”€ __init__.py
165
+ β”‚ β”‚ └── duckdb_engine.py # DuckDB query execution
166
+ β”‚ └── ui/
167
+ β”‚ β”œβ”€β”€ __init__.py
168
+ β”‚ └── dashboard.py # Streamlit dashboard
169
+ β”œβ”€β”€ web/ # Browser demo (React + DuckDB-WASM)
170
+ β”‚ β”œβ”€β”€ src/
171
+ β”‚ β”œβ”€β”€ public/
172
+ β”‚ └── package.json
173
+ β”œβ”€β”€ tests/
174
+ β”‚ β”œβ”€β”€ test_schema.py
175
+ β”‚ β”œβ”€β”€ test_validator.py
176
+ β”‚ └── test_lineage.py
177
+ β”œβ”€β”€ examples/
178
+ β”‚ β”œβ”€β”€ sports_tv/ # Sample SportsTV Germany dataset
179
+ β”‚ β”‚ β”œβ”€β”€ matches.csv
180
+ β”‚ β”‚ β”œβ”€β”€ leagues.csv
181
+ β”‚ β”‚ └── rules.yaml
182
+ β”‚ └── ecommerce/ # Additional example
183
+ β”œβ”€β”€ docs/
184
+ β”‚ β”œβ”€β”€ getting-started.md
185
+ β”‚ β”œβ”€β”€ validation-rules.md
186
+ β”‚ └── lineage-tracking.md
187
+ β”œβ”€β”€ pyproject.toml
188
+ β”œβ”€β”€ README.md
189
+ └── LICENSE
190
+ ```
191
+
192
+ ---
193
+
194
+ ## πŸ› οΈ Tech Stack
195
+
196
+ | Component | Technology | Why |
197
+ |-----------|------------|-----|
198
+ | Query Engine | DuckDB | Fast, in-process, handles CSV/Parquet natively |
199
+ | Metadata Store | SQLite | Simple, file-based, zero configuration |
200
+ | CLI Framework | Typer | Modern CLI with auto-generated help |
201
+ | Data Models | Pydantic | Validation & serialization |
202
+ | Dashboard | Streamlit | Rapid UI development |
203
+ | Web Demo | React + DuckDB-WASM | Browser-based, no server needed |
204
+ | Config Format | YAML | Human-readable rule definitions |
205
+ | Visualization | Mermaid | Lineage diagrams |
206
+
207
+ ---
208
+
209
+ ## πŸ“‹ Development Roadmap
210
+
211
+ ### Phase 1: Schema Inference & Drift Detection βœ…
212
+ - [x] Project setup & dependencies
213
+ - [x] DuckDB engine wrapper
214
+ - [x] Schema inference from CSV/Parquet
215
+ - [x] SQLite metadata store
216
+ - [x] Schema snapshot storage
217
+ - [x] Drift detection algorithm
218
+ - [x] CLI commands: `schema infer`, `schema diff`
219
+ - [x] Unit tests
220
+
221
+ ### Phase 2: Validation Rules Engine βœ…
222
+ - [x] YAML rule parser
223
+ - [x] Validation rule types (not_null, unique, range, etc.)
224
+ - [x] SQL query generator for each rule type
225
+ - [x] Validation executor
226
+ - [x] Report generator (JSON, terminal table)
227
+ - [x] CLI command: `validate`
228
+ - [x] Unit tests
229
+
230
+ ### Phase 3: Lineage Tracking βœ…
231
+ - [x] Lineage data model (DAG)
232
+ - [x] Decorator-based lineage capture (`@track_lineage`)
233
+ - [x] Lineage storage in SQLite
234
+ - [x] Mermaid diagram generator (CLI & Dashboard)
235
+ - [x] CLI commands: `lineage show`
236
+ - [x] Unit tests
237
+
238
+ ### Phase 4: Data Contracts & Polish βœ…
239
+ - [x] Contract schema definition (`DataContract`)
240
+ - [x] Auto-generate contracts from schema + rules (`contract generate`)
241
+ - [x] Contract verification (`contract verify`)
242
+ - [x] Streamlit dashboard (Schema, Drift, Lineage)
243
+ - [x] Documentation Polish
244
+
245
+ ### Phase 5: Browser-Native Dashboard βœ…
246
+ - [x] React + Next.js 16 setup
247
+ - [x] DuckDB-WASM Multi-Table Integration
248
+ - [x] Local-first Privacy Design
249
+ - [x] Visual Data Profiling (Histograms)
250
+ - [x] Full SQL Lab & Workbench
251
+ - [x] Multi-Source Lineage Tracking
252
+ - [x] Vercel Deployment Optimization
253
+
254
+ ---
255
+
256
+ ## πŸ“– Documentation
257
+
258
+ ### Validation Rule Types
259
+
260
+ ```yaml
261
+ # rules/matches.yaml
262
+ dataset: matches
263
+ validations:
264
+ - column: match_id
265
+ rules:
266
+ - type: not_null
267
+ - type: unique
268
+
269
+ - column: viewer_count
270
+ rules:
271
+ - type: not_null
272
+ - type: in_range
273
+ min: 0
274
+ max: 100000000
275
+
276
+ - column: broadcast_date
277
+ rules:
278
+ - type: not_null
279
+ - type: freshness
280
+ max_age_hours: 48
281
+
282
+ - column: league_id
283
+ rules:
284
+ - type: referential_integrity
285
+ parent_table: leagues
286
+ parent_column: id
287
+ ```
288
+
289
+ ### Available Rule Types
290
+
291
+ | Rule | Description | Parameters |
292
+ |------|-------------|------------|
293
+ | `not_null` | Column has no null values | β€” |
294
+ | `unique` | All values are unique | β€” |
295
+ | `in_range` | Numeric values within bounds | `min`, `max` |
296
+ | `in_set` | Values from allowed list | `values: [a, b, c]` |
297
+ | `regex_match` | String matches pattern | `pattern` |
298
+ | `freshness` | Data not older than threshold | `max_age_hours` |
299
+ | `referential_integrity` | FK exists in parent | `parent_table`, `parent_column` |
300
+ | `row_count` | Table has expected rows | `min`, `max` |
301
+
302
+ ## ☁️ Deployment (Vercel)
303
+
304
+ Deploying DataGuard is seamless. Since it's a static Next.js application, it can be hosted on Vercel with zero configuration.
305
+
306
+ 1. **Fork** this repository.
307
+ 2. **Connect** your fork to Vercel.
308
+ 3. Vercel will auto-detect Next.js and build using the optimized Webpack configuration.
309
+ 4. **Enjoy** your private, edge-distributed data quality platform!
310
+
311
+ > [!NOTE]
312
+ > We use the `--webpack` flag for production builds to ensure maximum stability and cross-browser compatibility for the DuckDB-WASM integration.
313
+
314
+ ---
315
+
316
+ ## πŸ§ͺ Running Tests
317
+
318
+ ```bash
319
+ # Run all tests
320
+ pytest
321
+
322
+ # Run with coverage
323
+ pytest --cov=dataguard
324
+
325
+ # Run specific test file
326
+ pytest tests/test_schema.py -v
327
+ ```
328
+
329
+ ---
330
+
331
+ ## 🀝 Contributing
332
+
333
+ Contributions are welcome! Please read our [issues](https://github.com/ayushvarma7/DataGuard/issues) for details.
334
+
335
+ 1. Fork the repository
336
+ 2. Create your feature branch (`git checkout -b feature/amazing-feature`)
337
+ 3. Commit your changes (`git commit -m 'Add amazing feature'`)
338
+ 4. Push to the branch (`git push origin feature/amazing-feature`)
339
+ 5. Open a Pull Request
340
+
341
+ ---
342
+
343
+ ## πŸ“„ License
344
+
345
+ This project is licensed under the MIT License - see the [LICENSE](https://github.com/ayushvarma7/DataGuard/blob/main/LICENSE) file for details.
346
+
347
+ ---
348
+
349
+ ## πŸ™ Acknowledgments
350
+
351
+ - [DuckDB](https://duckdb.org/) β€” The amazing in-process SQL engine
352
+ - [Great Expectations](https://greatexpectations.io/) β€” Inspiration for validation patterns
353
+ - [dbt](https://www.getdbt.com/) β€” Inspiration for lineage concepts
354
+
355
+ ---
356
+
357
+ <p align="center">
358
+ Built with ❀️ by <a href="https://github.com/yourusername">Ayush Varma</a>
359
+ </p>
@@ -0,0 +1,315 @@
1
+ # DataGuard πŸ›‘οΈ
2
+
3
+ > Data Quality Framework with Schema Drift Detection, Validation Engine & Lineage Tracking
4
+
5
+ [![Python](https://img.shields.io/badge/Python-3.10+-blue.svg)](https://python.org)
6
+ [![DuckDB](https://img.shields.io/badge/DuckDB-Latest-yellow.svg)](https://duckdb.org)
7
+ [![License](https://img.shields.io/badge/License-MIT-green.svg)](https://github.com/ayushvarma7/DataGuard/blob/main/LICENSE)
8
+
9
+ DataGuard is a lightweight, open-source data quality framework that helps data engineers catch schema changes, validate data quality, and track column-level lineageβ€”all without expensive enterprise tools.
10
+
11
+ **🌐 [Try the Live Demo (Vercel)](https://getdataguard.vercel.app/)** β€” Multi-Table Engine, SQL Lab, and interactive lineage. Your data never leaves your machine.
12
+
13
+ ---
14
+
15
+ ## ✨ Features
16
+
17
+ - **Schema Inference & Drift Detection** β€” Automatically detect when your data structure changes
18
+ - **Validation Rules Engine** β€” Define rules in YAML, get actionable failure reports
19
+ - **Lineage Tracking** β€” Track column-level data flow from source to output
20
+ - **Data Contracts** β€” Auto-generate contracts for cross-team agreements
21
+ - **Zero Cost** β€” DuckDB + SQLite, no cloud dependencies
22
+ - **Privacy First** β€” Browser demo processes files locally via WebAssembly
23
+
24
+ ---
25
+
26
+ ## πŸ—οΈ Architecture
27
+
28
+ ```
29
+ β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
30
+ β”‚ DataGuard β”‚
31
+ β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
32
+ β”‚ β”‚
33
+ β”‚ β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚
34
+ β”‚ β”‚ SOURCES β”‚ β”‚ PROCESSING β”‚ β”‚ OUTPUTS β”‚ β”‚
35
+ β”‚ β”‚ CSV/Parquet │───▢│ DuckDB │───▢│ Reports β”‚ β”‚
36
+ β”‚ β”‚ Databases β”‚ β”‚ Engine β”‚ β”‚ Alerts β”‚ β”‚
37
+ β”‚ β”‚ Excel β”‚ β”‚ β”‚ β”‚ Contracts β”‚ β”‚
38
+ β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚
39
+ β”‚ β”‚ β”‚ β”‚ β”‚
40
+ β”‚ β–Ό β–Ό β–Ό β”‚
41
+ β”‚ β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚
42
+ β”‚ β”‚ METADATA STORE (SQLite) β”‚ β”‚
43
+ β”‚ β”‚ β€’ Schema snapshots β€’ Validation history β”‚ β”‚
44
+ β”‚ β”‚ β€’ Lineage graph β€’ Data contracts β”‚ β”‚
45
+ β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚
46
+ β”‚ β”‚
47
+ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
48
+ ```
49
+
50
+ ---
51
+
52
+ ## πŸš€ Quick Start
53
+
54
+ ### Installation
55
+
56
+ ```bash
57
+ # Clone the repository
58
+ git clone https://github.com/ayushvarma7/DataGuard.git
59
+ cd DataGuard
60
+
61
+ # Create virtual environment
62
+ python -m venv venv
63
+ source venv/bin/activate # On Windows: venv\Scripts\activate
64
+
65
+ # Install dependencies
66
+ pip install -e .
67
+ ```
68
+
69
+ ### Install from PyPI
70
+
71
+ ```bash
72
+ pip install dataguard-drift # CLI + library
73
+ pip install "dataguard-drift[ui]" # + Streamlit dashboard
74
+ ```
75
+
76
+ The import name and command stay `dataguard`.
77
+
78
+ ### Basic Usage
79
+
80
+ ```bash
81
+ # Infer schema from a file
82
+ dataguard schema infer ./data/matches.csv --name matches
83
+
84
+ # Check for schema drift
85
+ dataguard schema diff matches
86
+
87
+ # Run validations
88
+ dataguard validate matches --rules ./rules/matches.yaml
89
+
90
+ # View lineage
91
+ dataguard lineage show revenue_report --format mermaid
92
+
93
+ # Generate data contract
94
+ dataguard contract generate matches
95
+
96
+ # Launch dashboard
97
+ dataguard ui
98
+ ```
99
+
100
+ ---
101
+
102
+ ## πŸ“ Project Structure
103
+
104
+ ```
105
+ dataguard/
106
+ β”œβ”€β”€ dataguard/
107
+ β”‚ β”œβ”€β”€ __init__.py
108
+ β”‚ β”œβ”€β”€ cli.py # Typer CLI application
109
+ β”‚ β”œβ”€β”€ core/
110
+ β”‚ β”‚ β”œβ”€β”€ __init__.py
111
+ β”‚ β”‚ β”œβ”€β”€ schema.py # Schema inference & drift detection
112
+ β”‚ β”‚ β”œβ”€β”€ validator.py # Validation rules engine
113
+ β”‚ β”‚ β”œβ”€β”€ lineage.py # Lineage tracking & DAG
114
+ β”‚ β”‚ └── contracts.py # Data contract generation
115
+ β”‚ β”œβ”€β”€ storage/
116
+ β”‚ β”‚ β”œβ”€β”€ __init__.py
117
+ β”‚ β”‚ β”œβ”€β”€ metadata.py # SQLite operations
118
+ β”‚ β”‚ └── models.py # Pydantic data models
119
+ β”‚ β”œβ”€β”€ engine/
120
+ β”‚ β”‚ β”œβ”€β”€ __init__.py
121
+ β”‚ β”‚ └── duckdb_engine.py # DuckDB query execution
122
+ β”‚ └── ui/
123
+ β”‚ β”œβ”€β”€ __init__.py
124
+ β”‚ └── dashboard.py # Streamlit dashboard
125
+ β”œβ”€β”€ web/ # Browser demo (React + DuckDB-WASM)
126
+ β”‚ β”œβ”€β”€ src/
127
+ β”‚ β”œβ”€β”€ public/
128
+ β”‚ └── package.json
129
+ β”œβ”€β”€ tests/
130
+ β”‚ β”œβ”€β”€ test_schema.py
131
+ β”‚ β”œβ”€β”€ test_validator.py
132
+ β”‚ └── test_lineage.py
133
+ β”œβ”€β”€ examples/
134
+ β”‚ β”œβ”€β”€ sports_tv/ # Sample SportsTV Germany dataset
135
+ β”‚ β”‚ β”œβ”€β”€ matches.csv
136
+ β”‚ β”‚ β”œβ”€β”€ leagues.csv
137
+ β”‚ β”‚ └── rules.yaml
138
+ β”‚ └── ecommerce/ # Additional example
139
+ β”œβ”€β”€ docs/
140
+ β”‚ β”œβ”€β”€ getting-started.md
141
+ β”‚ β”œβ”€β”€ validation-rules.md
142
+ β”‚ └── lineage-tracking.md
143
+ β”œβ”€β”€ pyproject.toml
144
+ β”œβ”€β”€ README.md
145
+ └── LICENSE
146
+ ```
147
+
148
+ ---
149
+
150
+ ## πŸ› οΈ Tech Stack
151
+
152
+ | Component | Technology | Why |
153
+ |-----------|------------|-----|
154
+ | Query Engine | DuckDB | Fast, in-process, handles CSV/Parquet natively |
155
+ | Metadata Store | SQLite | Simple, file-based, zero configuration |
156
+ | CLI Framework | Typer | Modern CLI with auto-generated help |
157
+ | Data Models | Pydantic | Validation & serialization |
158
+ | Dashboard | Streamlit | Rapid UI development |
159
+ | Web Demo | React + DuckDB-WASM | Browser-based, no server needed |
160
+ | Config Format | YAML | Human-readable rule definitions |
161
+ | Visualization | Mermaid | Lineage diagrams |
162
+
163
+ ---
164
+
165
+ ## πŸ“‹ Development Roadmap
166
+
167
+ ### Phase 1: Schema Inference & Drift Detection βœ…
168
+ - [x] Project setup & dependencies
169
+ - [x] DuckDB engine wrapper
170
+ - [x] Schema inference from CSV/Parquet
171
+ - [x] SQLite metadata store
172
+ - [x] Schema snapshot storage
173
+ - [x] Drift detection algorithm
174
+ - [x] CLI commands: `schema infer`, `schema diff`
175
+ - [x] Unit tests
176
+
177
+ ### Phase 2: Validation Rules Engine βœ…
178
+ - [x] YAML rule parser
179
+ - [x] Validation rule types (not_null, unique, range, etc.)
180
+ - [x] SQL query generator for each rule type
181
+ - [x] Validation executor
182
+ - [x] Report generator (JSON, terminal table)
183
+ - [x] CLI command: `validate`
184
+ - [x] Unit tests
185
+
186
+ ### Phase 3: Lineage Tracking βœ…
187
+ - [x] Lineage data model (DAG)
188
+ - [x] Decorator-based lineage capture (`@track_lineage`)
189
+ - [x] Lineage storage in SQLite
190
+ - [x] Mermaid diagram generator (CLI & Dashboard)
191
+ - [x] CLI commands: `lineage show`
192
+ - [x] Unit tests
193
+
194
+ ### Phase 4: Data Contracts & Polish βœ…
195
+ - [x] Contract schema definition (`DataContract`)
196
+ - [x] Auto-generate contracts from schema + rules (`contract generate`)
197
+ - [x] Contract verification (`contract verify`)
198
+ - [x] Streamlit dashboard (Schema, Drift, Lineage)
199
+ - [x] Documentation Polish
200
+
201
+ ### Phase 5: Browser-Native Dashboard βœ…
202
+ - [x] React + Next.js 16 setup
203
+ - [x] DuckDB-WASM Multi-Table Integration
204
+ - [x] Local-first Privacy Design
205
+ - [x] Visual Data Profiling (Histograms)
206
+ - [x] Full SQL Lab & Workbench
207
+ - [x] Multi-Source Lineage Tracking
208
+ - [x] Vercel Deployment Optimization
209
+
210
+ ---
211
+
212
+ ## πŸ“– Documentation
213
+
214
+ ### Validation Rule Types
215
+
216
+ ```yaml
217
+ # rules/matches.yaml
218
+ dataset: matches
219
+ validations:
220
+ - column: match_id
221
+ rules:
222
+ - type: not_null
223
+ - type: unique
224
+
225
+ - column: viewer_count
226
+ rules:
227
+ - type: not_null
228
+ - type: in_range
229
+ min: 0
230
+ max: 100000000
231
+
232
+ - column: broadcast_date
233
+ rules:
234
+ - type: not_null
235
+ - type: freshness
236
+ max_age_hours: 48
237
+
238
+ - column: league_id
239
+ rules:
240
+ - type: referential_integrity
241
+ parent_table: leagues
242
+ parent_column: id
243
+ ```
244
+
245
+ ### Available Rule Types
246
+
247
+ | Rule | Description | Parameters |
248
+ |------|-------------|------------|
249
+ | `not_null` | Column has no null values | β€” |
250
+ | `unique` | All values are unique | β€” |
251
+ | `in_range` | Numeric values within bounds | `min`, `max` |
252
+ | `in_set` | Values from allowed list | `values: [a, b, c]` |
253
+ | `regex_match` | String matches pattern | `pattern` |
254
+ | `freshness` | Data not older than threshold | `max_age_hours` |
255
+ | `referential_integrity` | FK exists in parent | `parent_table`, `parent_column` |
256
+ | `row_count` | Table has expected rows | `min`, `max` |
257
+
258
+ ## ☁️ Deployment (Vercel)
259
+
260
+ Deploying DataGuard is seamless. Since it's a static Next.js application, it can be hosted on Vercel with zero configuration.
261
+
262
+ 1. **Fork** this repository.
263
+ 2. **Connect** your fork to Vercel.
264
+ 3. Vercel will auto-detect Next.js and build using the optimized Webpack configuration.
265
+ 4. **Enjoy** your private, edge-distributed data quality platform!
266
+
267
+ > [!NOTE]
268
+ > We use the `--webpack` flag for production builds to ensure maximum stability and cross-browser compatibility for the DuckDB-WASM integration.
269
+
270
+ ---
271
+
272
+ ## πŸ§ͺ Running Tests
273
+
274
+ ```bash
275
+ # Run all tests
276
+ pytest
277
+
278
+ # Run with coverage
279
+ pytest --cov=dataguard
280
+
281
+ # Run specific test file
282
+ pytest tests/test_schema.py -v
283
+ ```
284
+
285
+ ---
286
+
287
+ ## 🀝 Contributing
288
+
289
+ Contributions are welcome! Please read our [issues](https://github.com/ayushvarma7/DataGuard/issues) for details.
290
+
291
+ 1. Fork the repository
292
+ 2. Create your feature branch (`git checkout -b feature/amazing-feature`)
293
+ 3. Commit your changes (`git commit -m 'Add amazing feature'`)
294
+ 4. Push to the branch (`git push origin feature/amazing-feature`)
295
+ 5. Open a Pull Request
296
+
297
+ ---
298
+
299
+ ## πŸ“„ License
300
+
301
+ This project is licensed under the MIT License - see the [LICENSE](https://github.com/ayushvarma7/DataGuard/blob/main/LICENSE) file for details.
302
+
303
+ ---
304
+
305
+ ## πŸ™ Acknowledgments
306
+
307
+ - [DuckDB](https://duckdb.org/) β€” The amazing in-process SQL engine
308
+ - [Great Expectations](https://greatexpectations.io/) β€” Inspiration for validation patterns
309
+ - [dbt](https://www.getdbt.com/) β€” Inspiration for lineage concepts
310
+
311
+ ---
312
+
313
+ <p align="center">
314
+ Built with ❀️ by <a href="https://github.com/yourusername">Ayush Varma</a>
315
+ </p>
@@ -0,0 +1,4 @@
1
+ """DataGuard - Data Quality Framework with Lineage Tracking"""
2
+
3
+ __version__ = "0.1.0"
4
+ __author__ = "Ayush Varma"