modscape 0.4.3 → 0.6.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 ADDED
@@ -0,0 +1,209 @@
1
+ # <img src="./visualizer/public/favicon.svg" width="32" height="32" align="center" /> Modscape
2
+
3
+ [![npm version](https://img.shields.io/npm/v/modscape.svg?style=flat-square)](https://www.npmjs.com/package/modscape)
4
+ [![npm downloads](https://img.shields.io/npm/dm/modscape.svg?style=flat-square)](https://www.npmjs.com/package/modscape)
5
+ [![Deploy Demo](https://github.com/yujikawa/modscape/actions/workflows/deploy.yml/badge.svg)](https://github.com/yujikawa/modscape/actions/workflows/deploy.yml)
6
+ [![Publish to NPM](https://github.com/yujikawa/modscape/actions/workflows/publish.yml/badge.svg)](https://github.com/yujikawa/modscape/actions/workflows/publish.yml)
7
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg?style=flat-square)](https://opensource.org/licenses/MIT)
8
+
9
+ Modscapeは、YAMLベースのデータモデリング・ビジュアライザーです。データエンジニアやアーキテクトが、概念・論理・物理モデルのギャップを埋め、サンプルデータに基づいた「ストーリー」を共有しながら設計を進めることを支援します。
10
+
11
+ [ライブデモ](https://yujikawa.github.io/modscape/)
12
+
13
+ ## 主な機能
14
+
15
+ - **YAMLファースト**: 単一のシンプルなYAMLファイルでデータモデル全体を定義。
16
+ - **統合サイドバー**: ナビゲーション、検索、YAML編集機能を備えた高機能サイドバー。
17
+ - **インタラクティブ・モデリング**:
18
+ - **ドラッグで接続**: カラムから別のテーブルへドラッグするだけでリレーションを作成。
19
+ - **プロパティ・エディタ**: テーブルやリレーションのメタデータをUIから直接編集。
20
+ - **インタラクティブ削除**: クリック一つでテーブルやリレーションを削除。
21
+ - **サンプルデータ「ストーリー」**: エンティティにサンプルデータを紐付け、データの目的を具体的に解説。
22
+ - **スマート・レイアウト**:
23
+ - **自動位置保存**: ドラッグ&ドロップで配置を調整。座標はYAMLに即座に反映。
24
+ - **適応型サイジング**: カラム数が多いテーブル(10行以上)は自動でリミットがかかり、スクロール表示に。
25
+ - **マルチファイル・サポート**: ディレクトリ内の複数のモデルをシームレスに切り替え。
26
+ - **ドキュメント・エクスポート**: Mermaid互換のMarkdownドキュメント(ER図、ドメインカタログを含む)を生成。
27
+ - **AIエージェント対応**: Gemini, Claude, Codex向けのプロンプトを用意。AIとの共同モデリングを支援。
28
+
29
+ ## インストール
30
+
31
+ npm経由でグローバルにインストールします:
32
+
33
+ ```bash
34
+ npm install -g modscape
35
+ ```
36
+
37
+ ---
38
+
39
+ ## はじめに
40
+
41
+ ワークフローに合わせて以下のいずれかの方法で開始してください。
42
+
43
+ ### A: AI駆動のモデリング(推奨)
44
+ Gemini CLI, Claude Code, Cursor/CodexなどのAIアシスタントを使用する場合に最適です。
45
+
46
+ 1. **初期化**: モデリングルールとAIエージェント用手順書を生成します。
47
+ ```bash
48
+ modscape init
49
+ ```
50
+ 2. **起動**: モデルファイルを指定してビジュアライザーを起動します。
51
+ ```bash
52
+ modscape dev model.yaml
53
+ ```
54
+ 3. **AIに指示**: `.modscape/rules.md` のルールに従って `model.yaml` にテーブルやカラムを追加するようAIに伝えてください。
55
+
56
+ ### B: 手動モデリング
57
+ YAMLを直接編集して詳細なコントロールを行いたい場合に最適です。
58
+
59
+ 1. **YAML作成**: `model.yaml` ファイルを作成します([モデルの定義](#モデルの定義-yaml)を参照)。
60
+ 2. **起動**: ビジュアライザーを起動します。
61
+ ```bash
62
+ modscape dev model.yaml
63
+ ```
64
+ 3. **サンプルを試す**: 付属のサンプルディレクトリを読み込むことも可能です:
65
+ ```bash
66
+ modscape dev samples/
67
+ ```
68
+
69
+ ---
70
+
71
+ ## モデルの定義 (YAML)
72
+
73
+ Modscapeは、包括的でありながら人間が読みやすいYAMLスキーマを採用しています。この単一のファイルが、概念・論理・物理データモデルの「信頼できる唯一の情報源(SSOT)」として機能します。
74
+
75
+ ### 完全なYAMLリファレンス
76
+
77
+ ```yaml
78
+ # 1. Domains: 関連するテーブルをグループ化する視覚的なコンテナ
79
+ domains:
80
+ - id: sales_domain
81
+ name: 売上と注文
82
+ description: 主要な商取引
83
+ color: "rgba(59, 130, 246, 0.05)" # コンテナの背景色
84
+ tables: [orders, order_items] # 所属するテーブルIDのリスト
85
+
86
+ # 2. Tables: エンティティの定義
87
+ tables:
88
+ - id: orders
89
+ name: ORDERS
90
+ appearance:
91
+ type: fact # fact | dimension | hub | link | satellite
92
+ icon: 📦 # 絵文字や任意の文字
93
+ color: "#f87171" # このエンティティのカスタムテーマカラー
94
+
95
+ conceptual:
96
+ description: "顧客の購入記録"
97
+ tags: ["WHAT", "WHEN"] # BEAM* メソドロジーのタグ
98
+
99
+ physical:
100
+ name: T_ORDERS # データベース上の実際のテーブル名
101
+ schema: RAW_SALES # データベースのスキーマ名
102
+
103
+ columns:
104
+ - id: order_id
105
+ logical:
106
+ name: ORDER_ID
107
+ type: Integer
108
+ description: "注文のユニークな識別子"
109
+ isPrimaryKey: true
110
+ physical:
111
+ name: O_ID
112
+ type: NUMBER(38,0)
113
+ constraints: ["NOT NULL"]
114
+
115
+ - id: customer_id
116
+ logical:
117
+ name: CUSTOMER_ID
118
+ type: Integer
119
+ isForeignKey: true # 外部キーであることを示す
120
+
121
+ # 3. Sample Data: ストーリーを伝えるための現実的なデータ
122
+ sampleData:
123
+ columns: [order_id, customer_id]
124
+ rows:
125
+ - [1001, 501]
126
+ - [1002, 502]
127
+
128
+ # 4. Relationships: テーブル間の接続
129
+ relationships:
130
+ - from: { table: orders, column: customer_id }
131
+ to: { table: customers, column: id }
132
+ type: many-to-one # one-to-one | one-to-many | many-to-many
133
+
134
+ # 5. Layout: 座標情報 (自動管理)
135
+ # 手動で記述する必要はありません。ドラッグするとModscapeが自動更新します。
136
+ layout:
137
+ orders: { x: 100, y: 100, width: 320, height: 400 }
138
+ ```
139
+
140
+ ### スキーマの詳細解説
141
+
142
+ | セクション | フィールド | 説明 |
143
+ | :--- | :--- | :--- |
144
+ | **`domains`** | `color` | ビジュアライザー上でグループを囲むコンテナの背景色を定義します。 |
145
+ | **`appearance`**| `type` | 指定がない場合のヘッダーアイコンと色を決定します(標準: スター・スキーマまたはData Vault)。 |
146
+ | **`conceptual`**| `tags` | ビジネスコンテキストタグ。モデリングの粒度(WHO, WHAT, WHERE)の識別に役立ちます。 |
147
+ | **`physical`** | `name`/`schema` | 論理エンティティを実際のデータベースオブジェクトにマッピングします。 |
148
+ | **`columns`** | `isPrimaryKey` | 🔑 アイコンを表示し、テーブルの粒度を明示します。 |
149
+ | | `isForeignKey` | 🔩 アイコンを表示し、下流への接続を示します。 |
150
+ | **`sampleData`**| `rows` | 2次元配列。これを入れることで、詳細パネルに「生きたデータ」が表示されます。 |
151
+ | **`relationships`**| `type` | 接続線の矢印の形や視覚的なスタイルを制御します。 |
152
+
153
+ ---
154
+
155
+ ## 使い方
156
+
157
+ ### 開発モード (Interactive Editor)
158
+ YAMLを編集し、エンティティを視覚的に配置するためのローカルセッションを開始します。
159
+
160
+ ```bash
161
+ # ディレクトリを指定して、中のすべてのモデルを管理
162
+ modscape dev models/
163
+
164
+ # または特定のファイルを指定
165
+ modscape dev my-model.yaml
166
+ ```
167
+ - 自動的に `http://localhost:5173` が開きます。
168
+ - **永続化**: エンティティの配置変更はYAMLファイルに即座に保存されます。
169
+ - **セキュアルーティング**: モデルはスラッグ経由でアクセスされ、ローカルの絶対パスは隠蔽されます。
170
+
171
+ ### ビルドモード (Static Site Generation)
172
+ ドキュメントを共有するための静的ウェブサイトを生成します(GitHub Pagesなどに最適)。
173
+
174
+ ```bash
175
+ modscape build models/ -o dist-site
176
+ ```
177
+
178
+ ### エクスポートモード (Static Documentation)
179
+ Mermaid図を含むMarkdownドキュメントを一括生成します。
180
+
181
+ ```bash
182
+ # 標準出力に書き出し
183
+ modscape export models/ecommerce.yaml
184
+
185
+ # ファイルに保存
186
+ modscape export models/ -o docs/
187
+ ```
188
+
189
+ ## AIエージェントとの統合
190
+
191
+ ModscapeはAIアシスタントとの連携を前提に設計されています。`modscape init` を実行すると以下のファイルが生成されます:
192
+
193
+ - **`.modscape/rules.md`**: モデリング規約の「信頼できる唯一の情報源(SSOT)」。
194
+ - **エージェント向け手順書**: Gemini, Claude, Cursor/Codex向けの事前定義プロンプト。
195
+
196
+ AIに対して:*"Follow the rules in .modscape/rules.md to add a new billing domain to my model.yaml."* と指示してください。
197
+
198
+ ## クレジット
199
+
200
+ Modscapeは以下の素晴らしいオープンソースプロジェクトによって支えられています:
201
+
202
+ - **[React Flow](https://reactflow.dev/)**: インタラクティブなグラフエンジン。
203
+ - **[Radix UI](https://www.radix-ui.com/)**: アクセシブルなUIプリミティブ。
204
+ - **[Lucide](https://lucide.dev/)**: 美しく一貫性のあるアイコン。
205
+ - **[shadcn/ui](https://ui.shadcn.com/)**: コンポーネントパターンとデザインインスピレーション。
206
+ - **[Express](https://expressjs.com/)**: ローカル開発環境のサーバー。
207
+
208
+ ## ライセンス
209
+ MIT
package/README.md CHANGED
@@ -14,8 +14,14 @@ Modscape is a YAML-driven data modeling visualizer. It helps data engineers and
14
14
 
15
15
  - **YAML-First**: Define your entire data model in a single, simple YAML file.
16
16
  - **Unified Sidebar**: A feature-rich sidebar for navigation, search, and YAML editing.
17
+ - **Interactive Modeling**:
18
+ - **Drag-to-Connect**: Create relationships by dragging from a column handle to another table.
19
+ - **Property Editor**: Edit table and relationship metadata directly in the UI.
20
+ - **Interactive Deletion**: Remove tables or relationships with a single click.
17
21
  - **Sample Data "Stories"**: Attach sample data to entities to explain the data's purpose.
18
- - **Interactive Layout**: Arrange entities via drag-and-drop; positions are saved directly back to your YAML.
22
+ - **Smart Layout**:
23
+ - **Auto-Positioning**: Arrange entities via drag-and-drop; positions are saved directly back to your YAML.
24
+ - **Adaptive Sizing**: Tables with many columns are automatically capped at 10 rows with scrolling for better canvas visibility.
19
25
  - **Multi-file Support**: Manage multiple models in a single directory and switch between them seamlessly.
20
26
  - **Documentation Export**: Generate Mermaid-compatible Markdown documentation including ER diagrams and domain catalogs.
21
27
  - **AI-Agent Ready**: Scaffolding for Gemini, Claude, and Codex to help you model via AI.
@@ -65,40 +71,85 @@ Best for direct YAML editing and architectural control.
65
71
 
66
72
  ## Defining Your Model (YAML)
67
73
 
68
- Modscape uses a human-readable YAML schema. While you can write it manually, we **highly recommend using an AI coding assistant** (like Gemini, Claude, or Cursor) to handle the boilerplate.
74
+ Modscape uses a comprehensive yet human-readable YAML schema. This single file acts as the **Single Source of Truth** for your conceptual, logical, and physical data models.
69
75
 
70
- ### Manual Definition Reference
71
- Here is the basic structure for your `model.yaml`:
76
+ ### Complete YAML Reference
72
77
 
73
78
  ```yaml
79
+ # 1. Domains: Visual containers to group related tables
80
+ domains:
81
+ - id: sales_domain
82
+ name: Sales & Orders
83
+ description: Core commerce transactions
84
+ color: "rgba(59, 130, 246, 0.05)" # Container background
85
+ tables: [orders, order_items] # List of table IDs
86
+
87
+ # 2. Tables: Entity definitions
74
88
  tables:
75
- - id: users
76
- name: USERS
89
+ - id: orders
90
+ name: ORDERS
77
91
  appearance:
78
- type: dimension # dimension | fact | hub | link | satellite
79
- icon: 👤
92
+ type: fact # fact | dimension | hub | link | satellite
93
+ icon: 📦 # Any emoji or character
94
+ color: "#f87171" # Custom theme color for this entity
95
+
96
+ conceptual:
97
+ description: "Records of customer purchases"
98
+ tags: ["WHAT", "WHEN"] # BEAM* methodology tags
99
+
100
+ physical:
101
+ name: T_ORDERS # Actual table name in database
102
+ schema: RAW_SALES # Database schema name
103
+
80
104
  columns:
81
- - id: user_id
82
- logical: { name: USER_ID, type: UUID, isPrimaryKey: true }
83
- - id: email
84
- logical: { name: EMAIL, type: String }
85
-
86
- # Data Vault Example
87
- - id: hub_customer
88
- name: HUB_CUSTOMER
89
- appearance: { type: hub, icon: 🔑 }
90
- columns:
91
- - id: hk_customer
92
- logical: { name: HK_CUSTOMER, type: Binary, isPrimaryKey: true }
105
+ - id: order_id
106
+ logical:
107
+ name: ORDER_ID
108
+ type: Integer
109
+ description: "Unique identifier for an order"
110
+ isPrimaryKey: true
111
+ physical:
112
+ name: O_ID
113
+ type: NUMBER(38,0)
114
+ constraints: ["NOT NULL"]
115
+
93
116
  - id: customer_id
94
- logical: { name: CUSTOMER_ID, type: String }
117
+ logical:
118
+ name: CUSTOMER_ID
119
+ type: Integer
120
+ isForeignKey: true
121
+
122
+ # 3. Sample Data: Realistic data for storytelling
123
+ sampleData:
124
+ columns: [order_id, customer_id]
125
+ rows:
126
+ - [1001, 501]
127
+ - [1002, 502]
128
+
129
+ # 4. Relationships: Connections between tables
130
+ relationships:
131
+ - from: { table: orders, column: customer_id }
132
+ to: { table: customers, column: id }
133
+ type: many-to-one # one-to-one | one-to-many | many-to-many
134
+
135
+ # 5. Layout: Visual coordinates (Auto-managed)
136
+ # You don't need to write this manually; Modscape updates it on drag.
137
+ layout:
138
+ orders: { x: 100, y: 100, width: 320, height: 400 }
95
139
  ```
96
140
 
97
- - **Appearance Types**:
98
- - `dimension` / `fact`: For Star Schema / Dimensional modeling.
99
- - `hub` / `link` / `satellite`: For Data Vault 2.0 modeling.
100
- - **IDs**: Use lowercase, snake_case for `id` fields (used for internal linking).
101
- - **Layout**: Don't worry about the `layout:` section. Modscape will automatically add and update coordinates when you drag entities in the browser.
141
+ ### Schema Breakdown
142
+
143
+ | Section | Field | Description |
144
+ | :--- | :--- | :--- |
145
+ | **`domains`** | `color` | Defines the background of the grouping container in the visualizer. |
146
+ | **`appearance`**| `type` | Determines the header icon/color if not specified (Standard: Star Schema or Data Vault). |
147
+ | **`conceptual`**| `tags` | Business context tags. Great for identifying key modeling grains (WHO, WHAT, WHERE). |
148
+ | **`physical`** | `name`/`schema` | Maps the logical entity to your real database objects. |
149
+ | **`columns`** | `isPrimaryKey` | Adds a 🔑 icon and marks the grain of the table. |
150
+ | | `isForeignKey` | Adds a 🔩 icon to indicate a downstream connection. |
151
+ | **`sampleData`**| `rows` | A 2D array. This is what makes your model "alive" in the Detail Panel. |
152
+ | **`relationships`**| `type` | Controls the arrowheads and visual style of the connection lines. |
102
153
 
103
154
  ---
104
155
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "modscape",
3
- "version": "0.4.3",
3
+ "version": "0.6.0",
4
4
  "description": "Modscape: A YAML-driven data modeling visualizer CLI",
5
5
  "repository": {
6
6
  "type": "git",
package/src/index.js CHANGED
@@ -15,7 +15,7 @@ const program = new Command();
15
15
  program
16
16
  .name('modscape')
17
17
  .description('A YAML-driven data modeling visualizer CLI')
18
- .version('0.4.3');
18
+ .version('0.6.0');
19
19
 
20
20
  program
21
21
  .command('init')
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "visualizer",
3
3
  "private": true,
4
- "version": "0.4.3",
4
+ "version": "0.6.0",
5
5
  "type": "module",
6
6
  "scripts": {
7
7
  "dev": "vite",