modscape 0.7.2 → 0.9.0
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.
- package/README.ja.md +81 -94
- package/README.md +84 -98
- package/package.json +1 -1
- package/src/dev.js +5 -3
- package/src/index.js +1 -1
- package/src/templates/rules.md +64 -68
- package/visualizer/package.json +1 -1
- package/visualizer-dist/assets/index-BQzAkOWB.js +40 -0
- package/visualizer-dist/assets/index-p_KeFJzm.css +1 -0
- package/visualizer-dist/index.html +2 -2
- package/visualizer-dist/assets/index-5OYvnvnP.css +0 -1
- package/visualizer-dist/assets/index-BbMnTGT9.js +0 -40
package/README.ja.md
CHANGED
|
@@ -6,25 +6,35 @@
|
|
|
6
6
|
[](https://github.com/yujikawa/modscape/actions/workflows/publish.yml)
|
|
7
7
|
[](https://opensource.org/licenses/MIT)
|
|
8
8
|
|
|
9
|
-
Modscape
|
|
9
|
+
**Modscape** は、モダンなデータ基盤(Modern Data Stack)に特化した、YAML駆動のデータモデリング・ビジュアライザーです。物理的なスキーマとビジネスロジックのギャップを埋め、データチームがデータを通じた「ストーリー」を設計、文書化、共有することを可能にします。
|
|
10
10
|
|
|
11
11
|
[ライブデモ](https://yujikawa.github.io/modscape/)
|
|
12
12
|
|
|
13
|
+
## なぜ Modscape なのか?
|
|
14
|
+
|
|
15
|
+
現代のデータ分析基盤において、データモデリングは単に図を描くだけの作業ではありません。バージョン管理が可能で、AIと親和性が高く、エンジニアとステークホルダーの双方が理解できる **「信頼できる唯一の情報源(SSOT)」** を維持することが不可欠です。
|
|
16
|
+
|
|
17
|
+
- **データエンジニア向け**: 物理テーブルと論理エンティティの明確なマッピングを維持。複雑な **Data Vault** や **スター・スキーマ** を視覚化。
|
|
18
|
+
- **アナリティクスエンジニア向け**: dbt などのツールに適した、モジュール性の高いモデルを設計。SQLを書く前に、データの粒度(Grain)や主キー、リレーションを定義。
|
|
19
|
+
- **データサイエンティスト向け**: **サンプルデータ「ストーリー」** によるデータ探索。クエリを叩くことなく、統合されたサンプルプレビューからテーブルの目的と内容を把握。
|
|
20
|
+
|
|
13
21
|
## 主な機能
|
|
14
22
|
|
|
15
|
-
- **YAML
|
|
16
|
-
-
|
|
17
|
-
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
-
|
|
21
|
-
-
|
|
22
|
-
-
|
|
23
|
-
|
|
24
|
-
-
|
|
25
|
-
-
|
|
26
|
-
-
|
|
27
|
-
-
|
|
23
|
+
- **YAML-as-Code**: データアーキテクチャ全体を人間が読みやすい単一のYAMLファイルで定義。Gitによる変更管理が可能。
|
|
24
|
+
- **ローカルYAMLの即時可視化**: Modscapeのスキーマに従ったYAMLファイルを指定するだけで、即座にビジュアライズ。データベース接続やクラウド設定は一切不要で、すぐにモデリング結果を確認できます。
|
|
25
|
+
- **データ分析特化のモデリング**: `fact`, `dimension`, `hub`, `link`, `satellite` などのエンティティタイプを標準サポート。
|
|
26
|
+
- **サンプルデータ「ストーリー」**: エンティティに現実的なサンプルデータを紐付け、データの背後にある「物語」を解説。
|
|
27
|
+
- **インタラクティブなビジュアルキャンバス**:
|
|
28
|
+
- **ドラッグで接続**: カラム間のリレーションを直感的に作成。
|
|
29
|
+
- **自動レイアウト永続化**: キャンバス上の配置は、即座に元のYAMLファイルの座標情報として保存。
|
|
30
|
+
- **ドメイン・グルーピング**: テーブルをビジネスドメインごとに整理。
|
|
31
|
+
- **分析メタデータ**:
|
|
32
|
+
- **ファクト・ストラテジー**: `transaction`, `periodic`, `accumulating`, `factless` といったデータの「粒度」を定義。
|
|
33
|
+
- **SCD(徐変ディメンション)管理**: `SCD Type 2` などの履歴管理方式を可視化。
|
|
34
|
+
- **加算規則(Additivity)**: カラムが合計可能か(`fully`, `semi`, `non`)を明示し、BI開発をガイド。
|
|
35
|
+
- **メタデータ/監査追跡**: 監査用カラムを専用アイコンで識別。
|
|
36
|
+
- **AIエージェント対応**: **Gemini, Claude, Codex** 用の雛形を内蔵。LLMを活用してモデリング作業を劇的に加速。
|
|
37
|
+
- **ドキュメント・エクスポート**: 社内WikiやGitHub/GitLab Pagesで利用可能な、Mermaid図入りのMarkdownを生成。
|
|
28
38
|
|
|
29
39
|
## インストール
|
|
30
40
|
|
|
@@ -38,30 +48,35 @@ npm install -g modscape
|
|
|
38
48
|
|
|
39
49
|
## はじめに
|
|
40
50
|
|
|
41
|
-
ワークフローに合わせて以下のいずれかの方法で開始してください。
|
|
42
|
-
|
|
43
51
|
### A: AI駆動のモデリング(推奨)
|
|
44
|
-
Gemini CLI, Claude Code,
|
|
52
|
+
Gemini CLI, Claude Code, Codex などのAIアシスタントを活用してモデルを構築します。
|
|
45
53
|
|
|
46
|
-
1. **初期化**:
|
|
54
|
+
1. **初期化**: 使用するAIエージェントに合わせてモデリングルールと手順書を生成します。
|
|
47
55
|
```bash
|
|
48
|
-
|
|
56
|
+
# Gemini CLI の場合
|
|
57
|
+
modscape init --gemini
|
|
58
|
+
|
|
59
|
+
# Claude Code の場合
|
|
60
|
+
modscape init --claude
|
|
61
|
+
|
|
62
|
+
# Codex の場合
|
|
63
|
+
modscape init --codex
|
|
49
64
|
```
|
|
50
|
-
2. **起動**:
|
|
65
|
+
2. **起動**: ビジュアライザーを起動します。
|
|
51
66
|
```bash
|
|
52
67
|
modscape dev model.yaml
|
|
53
68
|
```
|
|
54
|
-
3. **AIに指示**:
|
|
69
|
+
3. **AIに指示**: AIエージェントにこう伝えてください: *" .modscape/rules.md のルールに従って、model.yaml に新しい 'Marketing' ドメインと 'campaign_performance' ファクトテーブルを追加して。"*
|
|
55
70
|
|
|
56
71
|
### B: 手動モデリング
|
|
57
|
-
|
|
72
|
+
詳細な設計コントロールを行いたい場合に最適です。
|
|
58
73
|
|
|
59
|
-
1. **YAML作成**: `model.yaml` ファイルを作成します([
|
|
74
|
+
1. **YAML作成**: `model.yaml` ファイルを作成します([YAMLリファレンス](#モデルの定義-yaml)を参照)。
|
|
60
75
|
2. **起動**: ビジュアライザーを起動します。
|
|
61
76
|
```bash
|
|
62
77
|
modscape dev model.yaml
|
|
63
78
|
```
|
|
64
|
-
3. **サンプルを試す**:
|
|
79
|
+
3. **サンプルを試す**: 組み込みのパターンを確認できます:
|
|
65
80
|
```bash
|
|
66
81
|
modscape dev samples/
|
|
67
82
|
```
|
|
@@ -70,139 +85,111 @@ YAMLを直接編集して詳細なコントロールを行いたい場合に最
|
|
|
70
85
|
|
|
71
86
|
## モデルの定義 (YAML)
|
|
72
87
|
|
|
73
|
-
Modscape
|
|
74
|
-
|
|
75
|
-
### 完全なYAMLリファレンス
|
|
88
|
+
Modscapeは、データ分析のコンテキストに最適化されたスキーマを採用しています。この単一のファイルが、論理および物理データアーキテクチャの「信頼できる唯一の情報源(SSOT)」として機能します。
|
|
76
89
|
|
|
77
90
|
```yaml
|
|
78
91
|
# 1. Domains: 関連するテーブルをグループ化する視覚的なコンテナ
|
|
79
92
|
domains:
|
|
80
|
-
- id:
|
|
81
|
-
name:
|
|
82
|
-
description:
|
|
93
|
+
- id: core_sales
|
|
94
|
+
name: 主要売上
|
|
95
|
+
description: "ドメインの任意の説明"
|
|
83
96
|
color: "rgba(59, 130, 246, 0.05)" # コンテナの背景色
|
|
84
|
-
tables: [orders,
|
|
97
|
+
tables: [orders, products] # 所属するテーブルIDのリスト
|
|
85
98
|
|
|
86
|
-
# 2. Tables:
|
|
99
|
+
# 2. Tables: マルチレイヤーのメタデータを持つエンティティ定義
|
|
87
100
|
tables:
|
|
88
101
|
- id: orders
|
|
89
102
|
name: ORDERS
|
|
90
103
|
appearance:
|
|
91
104
|
type: fact # fact | dimension | hub | link | satellite
|
|
92
|
-
|
|
93
|
-
|
|
105
|
+
# --- 分析メタデータ ---
|
|
106
|
+
strategy: transaction # transaction | periodic | accumulating | factless
|
|
107
|
+
scd: null # type0 | type1 | type2 | type3 | type6 (Dimension用)
|
|
108
|
+
icon: 📦 # カスタム絵文字や文字
|
|
109
|
+
color: "#f87171" # エンティティのテーマカラー
|
|
94
110
|
|
|
95
111
|
conceptual:
|
|
96
|
-
description: "
|
|
97
|
-
tags: ["
|
|
112
|
+
description: "販売取引記録"
|
|
113
|
+
tags: ["WHO", "WHEN", "HOW MUCH"] # 粒度の識別子(BEAM*等)
|
|
98
114
|
|
|
99
115
|
physical:
|
|
100
|
-
name:
|
|
101
|
-
schema:
|
|
116
|
+
name: STG_ORDERS # 実際のDBテーブル名
|
|
117
|
+
schema: ANALYTICS_DB # DBスキーマ/名前空間
|
|
102
118
|
|
|
103
119
|
columns:
|
|
104
120
|
- id: order_id
|
|
105
121
|
logical:
|
|
106
122
|
name: ORDER_ID
|
|
107
|
-
type:
|
|
108
|
-
description: "
|
|
123
|
+
type: Int
|
|
124
|
+
description: "ユニークな識別子"
|
|
109
125
|
isPrimaryKey: true
|
|
126
|
+
isForeignKey: false
|
|
127
|
+
isPartitionKey: false
|
|
128
|
+
# --- 分析メタデータ ---
|
|
129
|
+
isMetadata: false # 監査用カラム等に true を設定 (🕒 アイコン)
|
|
130
|
+
additivity: fully # fully | semi | non (Σ アイコン)
|
|
110
131
|
physical:
|
|
111
132
|
name: O_ID
|
|
112
133
|
type: NUMBER(38,0)
|
|
113
134
|
constraints: ["NOT NULL"]
|
|
114
135
|
|
|
115
136
|
- id: customer_id
|
|
116
|
-
logical:
|
|
117
|
-
name: CUSTOMER_ID
|
|
118
|
-
type: Integer
|
|
119
|
-
isForeignKey: true # 外部キーであることを示す
|
|
137
|
+
logical: { name: CUSTOMER_ID, type: Int, isForeignKey: true }
|
|
120
138
|
|
|
121
|
-
# 3. Sample Data:
|
|
122
|
-
# (2次元配列を直接記述。論理カラムの定義順にマッピングされます)
|
|
139
|
+
# 3. Sample Data: データを通じたストーリーの提示
|
|
123
140
|
sampleData:
|
|
124
141
|
- [1001, 501]
|
|
125
142
|
- [1002, 502]
|
|
126
143
|
|
|
127
|
-
# 4. Relationships:
|
|
144
|
+
# 4. Relationships: カラムレベルの接続
|
|
128
145
|
relationships:
|
|
129
146
|
- from: { table: orders, column: customer_id }
|
|
130
147
|
to: { table: customers, column: id }
|
|
131
148
|
type: many-to-one # one-to-one | one-to-many | many-to-many
|
|
132
149
|
|
|
133
150
|
# 5. Layout: 座標情報 (自動管理)
|
|
134
|
-
# 手動で記述する必要はありません。ドラッグするとModscapeが自動更新します。
|
|
135
151
|
layout:
|
|
136
152
|
orders: { x: 100, y: 100, width: 320, height: 400 }
|
|
137
153
|
```
|
|
138
154
|
|
|
139
|
-
### スキーマの詳細解説
|
|
140
|
-
|
|
141
|
-
| セクション | フィールド | 説明 |
|
|
142
|
-
| :--- | :--- | :--- |
|
|
143
|
-
| **`domains`** | `color` | ビジュアライザー上でグループを囲むコンテナの背景色を定義します。 |
|
|
144
|
-
| **`appearance`**| `type` | 指定がない場合のヘッダーアイコンと色を決定します(標準: スター・スキーマまたはData Vault)。 |
|
|
145
|
-
| **`conceptual`**| `tags` | ビジネスコンテキストタグ。モデリングの粒度(WHO, WHAT, WHERE)の識別に役立ちます。 |
|
|
146
|
-
| **`physical`** | `name`/`schema` | 論理エンティティを実際のデータベースオブジェクトにマッピングします。 |
|
|
147
|
-
| **`columns`** | `isPrimaryKey` | 🔑 アイコンを表示し、テーブルの粒度を明示します。 |
|
|
148
|
-
| | `isForeignKey` | 🔩 アイコンを表示し、下流への接続を示します。 |
|
|
149
|
-
| **`sampleData`**| - | 2次元配列。論理カラムの定義順に値がマッピングされます。 |
|
|
150
|
-
| **`relationships`**| `type` | 接続線の矢印の形や視覚的なスタイルを制御します。 |
|
|
151
|
-
|
|
152
155
|
---
|
|
153
156
|
|
|
154
157
|
## 使い方
|
|
155
158
|
|
|
156
|
-
### 開発モード (
|
|
157
|
-
YAML
|
|
159
|
+
### 開発モード (インタラクティブ)
|
|
160
|
+
YAMLを編集し、エンティティを視覚的に配置します。
|
|
158
161
|
|
|
159
162
|
```bash
|
|
160
|
-
|
|
161
|
-
modscape dev models/
|
|
162
|
-
|
|
163
|
-
# または特定のファイルを指定
|
|
164
|
-
modscape dev my-model.yaml
|
|
163
|
+
modscape dev ./models
|
|
165
164
|
```
|
|
166
|
-
-
|
|
167
|
-
- **永続化**:
|
|
168
|
-
- **セキュアルーティング**: モデルはスラッグ経由でアクセスされ、ローカルの絶対パスは隠蔽されます。
|
|
165
|
+
- `http://localhost:5173` が開きます。
|
|
166
|
+
- **永続化**: レイアウトやメタデータの変更は、直接ファイルに書き戻されます。
|
|
169
167
|
|
|
170
|
-
### ビルドモード (
|
|
171
|
-
|
|
168
|
+
### ビルドモード (静的サイト)
|
|
169
|
+
チーム共有用のスタンドアロンなドキュメントサイトを生成します。
|
|
172
170
|
|
|
173
171
|
```bash
|
|
174
|
-
modscape build models
|
|
172
|
+
modscape build ./models -o docs-site
|
|
175
173
|
```
|
|
176
174
|
|
|
177
|
-
### エクスポートモード (
|
|
178
|
-
Mermaid図を含むMarkdown
|
|
175
|
+
### エクスポートモード (Markdown)
|
|
176
|
+
Mermaid図を含むMarkdownドキュメントを生成します。
|
|
179
177
|
|
|
180
178
|
```bash
|
|
181
|
-
|
|
182
|
-
modscape export models/ecommerce.yaml
|
|
183
|
-
|
|
184
|
-
# ファイルに保存
|
|
185
|
-
modscape export models/ -o docs/
|
|
179
|
+
modscape export ./models -o docs/ARCHITECTURE.md
|
|
186
180
|
```
|
|
187
181
|
|
|
188
182
|
## AIエージェントとの統合
|
|
189
183
|
|
|
190
|
-
ModscapeはAI
|
|
191
|
-
|
|
192
|
-
- **`.modscape/rules.md`**: モデリング規約の「信頼できる唯一の情報源(SSOT)」。
|
|
193
|
-
- **エージェント向け手順書**: Gemini, Claude, Cursor/Codex向けの事前定義プロンプト。
|
|
194
|
-
|
|
195
|
-
AIに対して:*"Follow the rules in .modscape/rules.md to add a new billing domain to my model.yaml."* と指示してください。
|
|
184
|
+
Modscapeは **AI-First** を掲げて設計されています。 `modscape init` を実行することで、 `.modscape/rules.md` を通じてAIエージェントと「契約」を結び、プロジェクト全体で一貫したモデリングパターン(命名規則、データ型など)を維持できます。
|
|
196
185
|
|
|
197
186
|
## クレジット
|
|
198
187
|
|
|
199
|
-
Modscape
|
|
200
|
-
|
|
201
|
-
- **
|
|
202
|
-
- **
|
|
203
|
-
- **
|
|
204
|
-
- **[shadcn/ui](https://ui.shadcn.com/)**: コンポーネントパターンとデザインインスピレーション。
|
|
205
|
-
- **[Express](https://expressjs.com/)**: ローカル開発環境のサーバー。
|
|
188
|
+
Modscapeは以下のプロジェクトによって支えられています:
|
|
189
|
+
- **React Flow**: インタラクティブなグラフエンジン。
|
|
190
|
+
- **Lucide**: 一貫性のあるアイコンセット。
|
|
191
|
+
- **Express**: ローカル開発サーバー。
|
|
192
|
+
- **Commander**: CLIフレームワーク。
|
|
206
193
|
|
|
207
194
|
## ライセンス
|
|
208
195
|
MIT
|
package/README.md
CHANGED
|
@@ -6,25 +6,35 @@
|
|
|
6
6
|
[](https://github.com/yujikawa/modscape/actions/workflows/publish.yml)
|
|
7
7
|
[](https://opensource.org/licenses/MIT)
|
|
8
8
|
|
|
9
|
-
Modscape is a YAML-driven data modeling visualizer
|
|
9
|
+
**Modscape** is a YAML-driven data modeling visualizer specialized for **Modern Data Stack** architectures. It bridges the gap between raw physical schemas and high-level business logic, empowering data teams to design, document, and share their data stories.
|
|
10
10
|
|
|
11
11
|
[Live Demo](https://yujikawa.github.io/modscape/)
|
|
12
12
|
|
|
13
|
-
##
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
- **
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
- **
|
|
26
|
-
- **
|
|
27
|
-
- **
|
|
13
|
+
## Why Modscape?
|
|
14
|
+
|
|
15
|
+
In modern data analysis platforms, data modeling is no longer just about drawing boxes. It's about maintaining a **Single Source of Truth (SSOT)** that is version-controllable, AI-friendly, and understandable by both engineers and stakeholders.
|
|
16
|
+
|
|
17
|
+
- **For Data Engineers**: Maintain clear mappings between physical tables and logical entities. Visualize complex **Data Vault** or **Star Schema** structures.
|
|
18
|
+
- **For Analytics Engineers**: Design modular dbt-ready models. Document table grains, primary keys, and relationships before writing a single line of SQL.
|
|
19
|
+
- **For Data Scientists**: Discover data through **Sample Stories**. Understand the purpose and content of a table through integrated sample data previews without running a single query.
|
|
20
|
+
|
|
21
|
+
## Key Features
|
|
22
|
+
|
|
23
|
+
- **YAML-as-Code**: Define your entire data architecture in a single, human-readable YAML file. Track changes via Git.
|
|
24
|
+
- **Instant Local Visualization**: Visualize your YAML models (following the Modscape schema) instantly on your machine. No database connections or cloud infrastructure required—just point to your file and start exploring.
|
|
25
|
+
- **Specialized Modeling Types**: Native support for entity types like `fact`, `dimension`, `hub`, `link`, and `satellite`.
|
|
26
|
+
- **Sample Data Stories**: Attach real-world data samples to your entities to explain the "Story" behind the data.
|
|
27
|
+
- **Interactive Visual Canvas**:
|
|
28
|
+
- **Drag-to-Connect**: Create relationships between columns intuitively.
|
|
29
|
+
- **Auto-Layout Persistence**: Arrange nodes on the canvas; coordinates are saved directly back to your YAML.
|
|
30
|
+
- **Domain Grouping**: Organize tables into visual business domains.
|
|
31
|
+
- **Analytics Metadata**:
|
|
32
|
+
- **Fact Strategies**: Define `transaction`, `periodic`, `accumulating`, or `factless` grains.
|
|
33
|
+
- **SCD Management**: Visualize `SCD Type 2` and other history-tracking dimensions.
|
|
34
|
+
- **Additivity Rules**: Mark columns as `fully`, `semi`, or `non-additive` to guide BI development.
|
|
35
|
+
- **Metadata/Audit Tracking**: Identify audit columns with specialized visual cues.
|
|
36
|
+
- **AI-Agent Ready**: Built-in scaffolding for **Gemini, Claude, and Codex** to accelerate your modeling workflow using LLMs.
|
|
37
|
+
- **Documentation Export**: Generate Mermaid-compatible Markdown for your internal wikis or GitHub/GitLab pages.
|
|
28
38
|
|
|
29
39
|
## Installation
|
|
30
40
|
|
|
@@ -38,32 +48,36 @@ npm install -g modscape
|
|
|
38
48
|
|
|
39
49
|
## Getting Started
|
|
40
50
|
|
|
41
|
-
Choose the path that fits your workflow.
|
|
42
|
-
|
|
43
51
|
### Path A: AI-Driven Modeling (Recommended)
|
|
44
|
-
|
|
52
|
+
Leverage AI coding assistants (**Gemini CLI, Claude Code, or Codex**) to build your models.
|
|
45
53
|
|
|
46
|
-
1. **Initialize**: Scaffold modeling rules and
|
|
54
|
+
1. **Initialize**: Scaffold modeling rules and instructions for your preferred agent.
|
|
47
55
|
```bash
|
|
48
|
-
|
|
56
|
+
# For Gemini CLI
|
|
57
|
+
modscape init --gemini
|
|
58
|
+
|
|
59
|
+
# For Claude Code
|
|
60
|
+
modscape init --claude
|
|
61
|
+
|
|
62
|
+
# For Codex
|
|
63
|
+
modscape init --codex
|
|
49
64
|
```
|
|
50
|
-
2. **Start Dev**: Launch the visualizer
|
|
65
|
+
2. **Start Dev**: Launch the visualizer.
|
|
51
66
|
```bash
|
|
52
67
|
modscape dev model.yaml
|
|
53
68
|
```
|
|
54
|
-
3. **Prompt Your AI**: Tell your agent
|
|
69
|
+
3. **Prompt Your AI**: Tell your agent: *"Use the rules in .modscape/rules.md to add a new 'Marketing' domain with a 'campaign_performance' fact table to my model.yaml."*
|
|
55
70
|
|
|
56
71
|
### Path B: Manual Modeling
|
|
57
|
-
Best for direct
|
|
72
|
+
Best for direct architectural control.
|
|
58
73
|
|
|
59
|
-
1. **Create YAML**: Create a file named `model.yaml` (see [
|
|
74
|
+
1. **Create YAML**: Create a file named `model.yaml` (see [YAML Reference](#defining-your-model-yaml)).
|
|
60
75
|
2. **Start Dev**: Launch the visualizer.
|
|
61
76
|
```bash
|
|
62
77
|
modscape dev model.yaml
|
|
63
78
|
```
|
|
64
|
-
3. **Explore Samples**: Try
|
|
79
|
+
3. **Explore Samples**: Try the built-in patterns:
|
|
65
80
|
```bash
|
|
66
|
-
# Clone the repo or download the samples directory
|
|
67
81
|
modscape dev samples/
|
|
68
82
|
```
|
|
69
83
|
|
|
@@ -71,139 +85,111 @@ Best for direct YAML editing and architectural control.
|
|
|
71
85
|
|
|
72
86
|
## Defining Your Model (YAML)
|
|
73
87
|
|
|
74
|
-
Modscape uses a
|
|
75
|
-
|
|
76
|
-
### Complete YAML Reference
|
|
88
|
+
Modscape uses a schema designed for data analysis contexts. This single file acts as the **Single Source of Truth** for your logical and physical data architecture.
|
|
77
89
|
|
|
78
90
|
```yaml
|
|
79
|
-
# 1. Domains: Visual containers
|
|
91
|
+
# 1. Domains: Visual containers for grouping business logic
|
|
80
92
|
domains:
|
|
81
|
-
- id:
|
|
82
|
-
name: Sales
|
|
83
|
-
description:
|
|
84
|
-
color: "rgba(59, 130, 246, 0.05)" # Container background
|
|
85
|
-
tables: [orders,
|
|
93
|
+
- id: core_sales
|
|
94
|
+
name: Core Sales
|
|
95
|
+
description: "Optional description of the domain"
|
|
96
|
+
color: "rgba(59, 130, 246, 0.05)" # Container background color
|
|
97
|
+
tables: [orders, products] # List of table IDs
|
|
86
98
|
|
|
87
|
-
# 2. Tables: Entity definitions
|
|
99
|
+
# 2. Tables: Entity definitions with multi-layer metadata
|
|
88
100
|
tables:
|
|
89
101
|
- id: orders
|
|
90
102
|
name: ORDERS
|
|
91
103
|
appearance:
|
|
92
104
|
type: fact # fact | dimension | hub | link | satellite
|
|
93
|
-
|
|
105
|
+
# --- Analytics Metadata ---
|
|
106
|
+
strategy: transaction # transaction | periodic | accumulating | factless
|
|
107
|
+
scd: null # type0 | type1 | type2 | type3 | type6 (for Dimensions)
|
|
108
|
+
icon: 📦 # Custom emoji or character
|
|
94
109
|
color: "#f87171" # Custom theme color for this entity
|
|
95
110
|
|
|
96
111
|
conceptual:
|
|
97
|
-
description: "
|
|
98
|
-
tags: ["
|
|
112
|
+
description: "Sales transaction records"
|
|
113
|
+
tags: ["WHO", "WHEN", "HOW MUCH"] # BEAM* or Grain identifiers
|
|
99
114
|
|
|
100
115
|
physical:
|
|
101
|
-
name:
|
|
102
|
-
schema:
|
|
116
|
+
name: STG_ORDERS # Actual table name in DB
|
|
117
|
+
schema: ANALYTICS_DB # DB schema/namespace
|
|
103
118
|
|
|
104
119
|
columns:
|
|
105
120
|
- id: order_id
|
|
106
121
|
logical:
|
|
107
122
|
name: ORDER_ID
|
|
108
|
-
type:
|
|
109
|
-
description: "Unique identifier
|
|
123
|
+
type: Int
|
|
124
|
+
description: "Unique identifier"
|
|
110
125
|
isPrimaryKey: true
|
|
126
|
+
isForeignKey: false
|
|
127
|
+
isPartitionKey: false
|
|
128
|
+
# --- Analytics Metadata ---
|
|
129
|
+
isMetadata: false # Set true for audit columns (🕒 icon)
|
|
130
|
+
additivity: fully # fully | semi | non (Σ icon)
|
|
111
131
|
physical:
|
|
112
132
|
name: O_ID
|
|
113
133
|
type: NUMBER(38,0)
|
|
114
134
|
constraints: ["NOT NULL"]
|
|
115
135
|
|
|
116
136
|
- id: customer_id
|
|
117
|
-
logical:
|
|
118
|
-
name: CUSTOMER_ID
|
|
119
|
-
type: Integer
|
|
120
|
-
isForeignKey: true
|
|
137
|
+
logical: { name: CUSTOMER_ID, type: Int, isForeignKey: true }
|
|
121
138
|
|
|
122
|
-
# 3. Sample Data:
|
|
123
|
-
# (Direct 2D array, mapped to logical columns by index)
|
|
139
|
+
# 3. Sample Data: Storytelling through data
|
|
124
140
|
sampleData:
|
|
125
141
|
- [1001, 501]
|
|
126
142
|
- [1002, 502]
|
|
127
143
|
|
|
128
|
-
# 4. Relationships:
|
|
144
|
+
# 4. Relationships: Column-level connectivity
|
|
129
145
|
relationships:
|
|
130
146
|
- from: { table: orders, column: customer_id }
|
|
131
147
|
to: { table: customers, column: id }
|
|
132
148
|
type: many-to-one # one-to-one | one-to-many | many-to-many
|
|
133
149
|
|
|
134
150
|
# 5. Layout: Visual coordinates (Auto-managed)
|
|
135
|
-
# You don't need to write this manually; Modscape updates it on drag.
|
|
136
151
|
layout:
|
|
137
152
|
orders: { x: 100, y: 100, width: 320, height: 400 }
|
|
138
153
|
```
|
|
139
154
|
|
|
140
|
-
### Schema Breakdown
|
|
141
|
-
|
|
142
|
-
| Section | Field | Description |
|
|
143
|
-
| :--- | :--- | :--- |
|
|
144
|
-
| **`domains`** | `color` | Defines the background of the grouping container in the visualizer. |
|
|
145
|
-
| **`appearance`**| `type` | Determines the header icon/color if not specified (Standard: Star Schema or Data Vault). |
|
|
146
|
-
| **`conceptual`**| `tags` | Business context tags. Great for identifying key modeling grains (WHO, WHAT, WHERE). |
|
|
147
|
-
| **`physical`** | `name`/`schema` | Maps the logical entity to your real database objects. |
|
|
148
|
-
| **`columns`** | `isPrimaryKey` | Adds a 🔑 icon and marks the grain of the table. |
|
|
149
|
-
| | `isForeignKey` | Adds a 🔩 icon to indicate a downstream connection. |
|
|
150
|
-
| **`sampleData`**| - | A direct 2D array of rows. Values are mapped to logical columns by index. |
|
|
151
|
-
| **`relationships`**| `type` | Controls the arrowheads and visual style of the connection lines. |
|
|
152
|
-
|
|
153
155
|
---
|
|
154
156
|
|
|
155
157
|
## Usage
|
|
156
158
|
|
|
157
|
-
### Development Mode (Interactive
|
|
158
|
-
|
|
159
|
+
### Development Mode (Interactive)
|
|
160
|
+
Edit your YAML and arrange entities visually.
|
|
159
161
|
|
|
160
162
|
```bash
|
|
161
|
-
|
|
162
|
-
modscape dev models/
|
|
163
|
-
|
|
164
|
-
# Or point to a specific file
|
|
165
|
-
modscape dev my-model.yaml
|
|
163
|
+
modscape dev ./models
|
|
166
164
|
```
|
|
167
|
-
- Opens `http://localhost:5173
|
|
168
|
-
- **Persistence**:
|
|
169
|
-
- **Secure Routing**: Models are accessed via safe slugs, keeping your local paths private.
|
|
165
|
+
- Opens `http://localhost:5173`.
|
|
166
|
+
- **Persistence**: Layout and metadata changes are saved directly to your files.
|
|
170
167
|
|
|
171
|
-
### Build Mode (Static Site
|
|
172
|
-
Generate a standalone
|
|
168
|
+
### Build Mode (Static Site)
|
|
169
|
+
Generate a standalone documentation site for your team.
|
|
173
170
|
|
|
174
171
|
```bash
|
|
175
|
-
modscape build models
|
|
172
|
+
modscape build ./models -o docs-site
|
|
176
173
|
```
|
|
177
174
|
|
|
178
|
-
### Export Mode (
|
|
179
|
-
Generate
|
|
175
|
+
### Export Mode (Markdown)
|
|
176
|
+
Generate documentation with Mermaid diagrams.
|
|
180
177
|
|
|
181
178
|
```bash
|
|
182
|
-
|
|
183
|
-
modscape export models/ecommerce.yaml
|
|
184
|
-
|
|
185
|
-
# Save to a file
|
|
186
|
-
modscape export models/ -o docs/
|
|
179
|
+
modscape export ./models -o docs/ARCHITECTURE.md
|
|
187
180
|
```
|
|
188
181
|
|
|
189
182
|
## AI Agent Integration
|
|
190
183
|
|
|
191
|
-
Modscape is designed to
|
|
192
|
-
|
|
193
|
-
- **`.modscape/rules.md`**: The Single Source of Truth for your modeling conventions.
|
|
194
|
-
- **Agent Instructions**: Pre-configured prompts for Gemini, Claude, and Cursor/Codex.
|
|
195
|
-
|
|
196
|
-
Tell your AI: *"Follow the rules in .modscape/rules.md to add a new billing domain to my model.yaml."*
|
|
184
|
+
Modscape is designed to be **AI-First**. By running `modscape init`, you establish a contract with your AI agent via `.modscape/rules.md`, ensuring consistent modeling patterns (naming conventions, data types, etc.) across your entire project.
|
|
197
185
|
|
|
198
186
|
## Credits
|
|
199
187
|
|
|
200
|
-
Modscape is built upon
|
|
201
|
-
|
|
202
|
-
- **
|
|
203
|
-
- **
|
|
204
|
-
- **
|
|
205
|
-
- **[shadcn/ui](https://ui.shadcn.com/)**: Component patterns and design inspiration.
|
|
206
|
-
- **[Express](https://expressjs.com/)**: Serving the local development environment.
|
|
188
|
+
Modscape is built upon:
|
|
189
|
+
- **React Flow**: Interactive graph engine.
|
|
190
|
+
- **Lucide**: Consistent iconography.
|
|
191
|
+
- **Express**: Local dev server.
|
|
192
|
+
- **Commander**: CLI framework.
|
|
207
193
|
|
|
208
194
|
## License
|
|
209
195
|
MIT
|
package/package.json
CHANGED
package/src/dev.js
CHANGED
|
@@ -45,7 +45,8 @@ export async function startDevServer(paths, visualizerPath) {
|
|
|
45
45
|
const app = express();
|
|
46
46
|
app.use(express.json());
|
|
47
47
|
|
|
48
|
-
const
|
|
48
|
+
const inputPaths = Array.isArray(paths) ? paths : [paths];
|
|
49
|
+
let modelMap = scanFiles(inputPaths);
|
|
49
50
|
const distPath = path.resolve(__dirname, '../visualizer-dist');
|
|
50
51
|
|
|
51
52
|
if (modelMap.size === 0) {
|
|
@@ -66,8 +67,9 @@ export async function startDevServer(paths, visualizerPath) {
|
|
|
66
67
|
return modelMap.values().next().value;
|
|
67
68
|
};
|
|
68
69
|
|
|
69
|
-
// API to list all available models
|
|
70
|
+
// API to list all available models - re-scans on every request
|
|
70
71
|
app.get('/api/files', (req, res) => {
|
|
72
|
+
modelMap = scanFiles(inputPaths);
|
|
71
73
|
const files = Array.from(modelMap.entries()).map(([slug, fullPath]) => ({
|
|
72
74
|
slug,
|
|
73
75
|
name: slug.charAt(0).toUpperCase() + slug.slice(1).replace(/[-_]/g, ' '),
|
|
@@ -148,7 +150,7 @@ export async function startDevServer(paths, visualizerPath) {
|
|
|
148
150
|
open(url);
|
|
149
151
|
});
|
|
150
152
|
|
|
151
|
-
chokidar.watch(
|
|
153
|
+
chokidar.watch(inputPaths).on('change', (changedPath) => {
|
|
152
154
|
console.log(` File changed: ${path.relative(process.cwd(), changedPath)}. Please refresh the browser.`);
|
|
153
155
|
});
|
|
154
156
|
}
|