Skip to content

Commit cc1410d

Browse files
committed
update doc
1 parent 97a8ed4 commit cc1410d

15 files changed

Lines changed: 13434 additions & 10727 deletions

content/configuration.md

Lines changed: 115 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
1+
# Configuration
2+
3+
**Damru** — sql2nosql is configured via a single JSON file at the **project root**: `sql2nosql.config.json`. Copy from `sql2nosql.config.example.json` and fill in your values.
4+
5+
## Config file reference
6+
7+
Example structure:
8+
9+
```json
10+
{
11+
"connection": "postgres://<username>:<password>@<host>:<port>/<database>",
12+
"schema": "public",
13+
"output": "./output",
14+
"llm": {
15+
"enabled": false,
16+
"apiKey": "<OPENAI_API_KEY>",
17+
"model": "gpt-4.1-mini"
18+
},
19+
"mongodb": {
20+
"uri": "mongodb://<username>:<password>@<host>:<port>",
21+
"database": "sql2nosql",
22+
"collectionPrefix": ""
23+
},
24+
"migration": {
25+
"batchSize": 0,
26+
"dryRun": false,
27+
"skipOnError": false,
28+
"progressEvery": 1000
29+
}
30+
}
31+
```
32+
33+
---
34+
35+
## Required for analysis
36+
37+
| Key | Description |
38+
|-----|-------------|
39+
| `connection` | Postgres connection string. Required for `yarn analyze`. |
40+
| `schema` | Postgres schema to introspect (default: `public`). |
41+
| `output` | Directory for generated JSON, HTML, and scripts (default: `./output`). |
42+
43+
---
44+
45+
## MongoDB (for running migrations)
46+
47+
| Key | Description |
48+
|-----|-------------|
49+
| `mongodb.uri` | MongoDB connection URI. Required when running migration scripts (unless `migration.dryRun` is `true`). |
50+
| `mongodb.database` | Target database name (default: `sql2nosql`). |
51+
| `mongodb.collectionPrefix` | Optional prefix for collection names (default: `""`). |
52+
53+
---
54+
55+
## Migration script options
56+
57+
Used by the generated `.migrate.js` scripts when you run them.
58+
59+
| Key | Description |
60+
|-----|-------------|
61+
| `migration.batchSize` | `0` = load all rows; `>0` = paginate with LIMIT/OFFSET (e.g. `5000`) to avoid loading huge tables. |
62+
| `migration.dryRun` | `true` = connect and process rows but **do not write** to MongoDB (safe to test). |
63+
| `migration.skipOnError` | `true` = log row errors and continue; `false` = fail on first error. |
64+
| `migration.progressEvery` | Log progress every N rows (e.g. `1000`); `0` = only final summary. |
65+
66+
---
67+
68+
## LLM (optional)
69+
70+
The **LLM** section enables AI-powered schema recommendations during `yarn analyze`. It is **optional** and **off by default**.
71+
72+
### Config fields
73+
74+
| Key | Description |
75+
|-----|-------------|
76+
| `llm.enabled` | Set `true` to enable LLM recommendations (default: `false`). You can also pass `--llm` on the CLI. |
77+
| `llm.apiKey` | OpenAI API key. Can be set here, or via `--llm-api-key` or the `OPENAI_API_KEY` environment variable. |
78+
| `llm.model` | Model name (e.g. `gpt-4.1-mini`, `gpt-4`). Default: `gpt-4`. |
79+
80+
### Advantages of using LLM
81+
82+
- **Embedding recommendations** — Suggests which relations to embed vs keep as references, with reasoning (e.g. “embed artist in album for read-heavy workloads”).
83+
- **Trade-off explanations** — Describes pros and cons (denormalization, indexing, sharding) in plain language.
84+
- **Optimized NoSQL layout** — Output in `output/recommend/` and the **view** HTML include an LLM-optimized schema and per-table insights you can compare to the deterministic analysis.
85+
- **Human-in-the-loop** — The tool never migrates data or changes schemas itself; it only proposes. You decide what to apply.
86+
87+
### When to enable
88+
89+
- Enable when you want **suggestions and rationale** for embedding strategy, indexing, or document shape.
90+
- Leave disabled if you only need **deterministic** SQL → NoSQL mapping and migration script generation (no API key required).
91+
92+
### Example with LLM enabled
93+
94+
```json
95+
"llm": {
96+
"enabled": true,
97+
"apiKey": "sk-...",
98+
"model": "gpt-4.1-mini"
99+
}
100+
```
101+
102+
Then run:
103+
104+
```bash
105+
yarn analyze --llm
106+
```
107+
108+
Results appear in `output/recommend/` and in the **view** pages (e.g. “LLM Optimization Recommendations” and “Additional Insights”).
109+
110+
---
111+
112+
## Security
113+
114+
- **Do not commit `sql2nosql.config.json`** — it contains credentials (Postgres, MongoDB, and optionally the LLM API key). It is listed in `.gitignore`.
115+
- Use `sql2nosql.config.example.json` (no secrets) as the template and document only the **shape** of the config in docs (as on this page).

content/index.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424

2525
## Documentation
2626

27+
- [Configuration](/configuration) — How to configure the project (`sql2nosql.config.json`), including LLM options and advantages
2728
- [Run migrations](/run-migrations) — How to run migration scripts with Node
2829
- [Generator checklist](/generator-checklist) — Migration script generator options and config
2930

docs-site/.vitepress/cache/deps/@theme_index.js

Lines changed: 275 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)