db-model-router 1.0.3 → 1.0.5

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 (97) hide show
  1. package/README.md +283 -25
  2. package/TODO.md +14 -0
  3. package/dbmr.schema.json +333 -0
  4. package/demo/.dockerignore +7 -0
  5. package/demo/.env.example +13 -0
  6. package/demo/Dockerfile +20 -0
  7. package/demo/app.js +37 -0
  8. package/demo/commons/add_migration.js +43 -0
  9. package/demo/commons/db.js +17 -0
  10. package/demo/commons/migrate.js +65 -0
  11. package/demo/commons/security.js +30 -0
  12. package/demo/commons/session.js +13 -0
  13. package/demo/dbmr.schema.json +362 -0
  14. package/demo/docs/llm.md +197 -0
  15. package/demo/llms.txt +70 -0
  16. package/demo/middleware/logger.js +67 -0
  17. package/demo/migrations/20260430155808_create_migrations_table.sql +6 -0
  18. package/demo/migrations/20260430155809_create_tables.sql +207 -0
  19. package/demo/models/addresses.js +22 -0
  20. package/demo/models/cart_items.js +18 -0
  21. package/demo/models/carts.js +16 -0
  22. package/demo/models/categories.js +20 -0
  23. package/demo/models/coupons.js +23 -0
  24. package/demo/models/order_items.js +21 -0
  25. package/demo/models/orders.js +25 -0
  26. package/demo/models/payments.js +21 -0
  27. package/demo/models/product_images.js +18 -0
  28. package/demo/models/product_reviews.js +20 -0
  29. package/demo/models/product_variants.js +20 -0
  30. package/demo/models/products.js +30 -0
  31. package/demo/models/shipments.js +19 -0
  32. package/demo/models/users.js +19 -0
  33. package/demo/models/wishlists.js +15 -0
  34. package/demo/openapi.json +5872 -0
  35. package/demo/package-lock.json +2810 -0
  36. package/demo/package.json +34 -0
  37. package/demo/routes/addresses.js +6 -0
  38. package/demo/routes/carts/cart_items.js +7 -0
  39. package/demo/routes/carts.js +6 -0
  40. package/demo/routes/categories.js +6 -0
  41. package/demo/routes/coupons.js +6 -0
  42. package/demo/routes/docs.js +18 -0
  43. package/demo/routes/health.js +35 -0
  44. package/demo/routes/index.js +39 -0
  45. package/demo/routes/orders/order_items.js +7 -0
  46. package/demo/routes/orders/payments.js +7 -0
  47. package/demo/routes/orders/shipments.js +7 -0
  48. package/demo/routes/orders.js +6 -0
  49. package/demo/routes/products/product_images.js +7 -0
  50. package/demo/routes/products/product_reviews.js +7 -0
  51. package/demo/routes/products/product_variants.js +7 -0
  52. package/demo/routes/products.js +6 -0
  53. package/demo/routes/users.js +6 -0
  54. package/demo/routes/wishlists.js +6 -0
  55. package/docker-compose.yml +1 -1
  56. package/package.json +16 -7
  57. package/scripts/demo-create.js +47 -0
  58. package/skill/SKILL.md +464 -0
  59. package/skill/references/cockroachdb.md +49 -0
  60. package/skill/references/dynamodb.md +53 -0
  61. package/skill/references/mongodb.md +56 -0
  62. package/skill/references/mssql.md +55 -0
  63. package/skill/references/oracle.md +52 -0
  64. package/skill/references/postgres.md +50 -0
  65. package/skill/references/redis.md +53 -0
  66. package/skill/references/sqlite3.md +43 -0
  67. package/src/cli/commands/generate.js +58 -17
  68. package/src/cli/commands/help.js +185 -0
  69. package/src/cli/commands/init.js +42 -14
  70. package/src/cli/commands/inspect.js +21 -3
  71. package/src/cli/diff-engine.js +52 -22
  72. package/src/cli/generate-docs-route.js +31 -0
  73. package/src/cli/generate-migration.js +356 -0
  74. package/src/cli/generate-model.js +5 -4
  75. package/src/cli/generate-route.js +79 -45
  76. package/src/cli/init/dependencies.js +17 -5
  77. package/src/cli/init/generators.js +1073 -64
  78. package/src/cli/init/prompt.js +37 -5
  79. package/src/cli/init.js +148 -25
  80. package/src/cli/main.js +90 -10
  81. package/src/cockroachdb/db.js +90 -59
  82. package/src/commons/route.js +20 -20
  83. package/src/commons/validator.js +58 -1
  84. package/src/dynamodb/db.js +50 -27
  85. package/src/index.js +2 -0
  86. package/src/mongodb/db.js +1 -0
  87. package/src/mssql/db.js +89 -61
  88. package/src/mysql/db.js +1 -0
  89. package/src/oracle/db.js +1 -0
  90. package/src/postgres/db.js +61 -41
  91. package/src/redis/db.js +1 -0
  92. package/src/schema/schema-parser.js +43 -1
  93. package/src/schema/schema-printer.js +8 -5
  94. package/src/schema/schema-to-meta.js +4 -0
  95. package/src/schema/schema-validator.js +20 -1
  96. package/src/sqlite3/db.js +1 -0
  97. package/docs/SKILL.md +0 -374
package/README.md CHANGED
@@ -14,13 +14,18 @@ Scaffold the project, write the migrations, generate models and routes with pare
14
14
  relationships for projects.tasks, and make sure everything runs.
15
15
  ```
16
16
 
17
- For the LLM skill reference, see [SKILL.md](./docs/SKILL.md).
17
+ For the LLM skill reference, see [SKILL.md](./skill/SKILL.md). You can also add it directly to your AI assistant:
18
+
19
+ ```bash
20
+ npx skills add https://github.com/AvinashSKaranth/db-model-router/skill
21
+ ```
18
22
 
19
23
  ## Supported Adapters
20
24
 
21
25
  | Adapter | Module Key | Driver | Install |
22
26
  | --------------------------------------------- | ------------- | ------------------------ | ---------------------------------------------------------------------- |
23
27
  | [MySQL](#mysql-example) | `mysql` | mysql2 | `npm i db-model-router mysql2` |
28
+ | MariaDB | `mariadb` | mysql2 | `npm i db-model-router mysql2` |
24
29
  | [PostgreSQL](./docs/adapters/postgres.md) | `postgres` | pg | `npm i db-model-router pg` |
25
30
  | [SQLite3](./docs/adapters/sqlite3.md) | `sqlite3` | better-sqlite3 | `npm i db-model-router better-sqlite3` |
26
31
  | [MongoDB](./docs/adapters/mongodb.md) | `mongodb` | mongodb | `npm i db-model-router mongodb` |
@@ -96,7 +101,31 @@ Instead of running multiple CLI commands manually, you can define your entire pr
96
101
 
97
102
  ### The Schema File
98
103
 
99
- `dbmr.schema.json` is a declarative JSON file that describes your adapter, framework, tables, columns, relationships, and options — all in one place:
104
+ `dbmr.schema.json` is a declarative JSON file that describes your adapter, framework, tables, columns, module hierarchy, and options — all in one place.
105
+
106
+ #### Modules and the `parent` Field
107
+
108
+ Each table in the schema represents a **module**. Modules are either top-level or nested under a parent module using the `parent` field:
109
+
110
+ - `"parent": null` — top-level module, routes mount at `/<table>/`
111
+ - `"parent": "posts"` — child module, routes mount at `/posts/:post_id/comments/:comment_id`
112
+
113
+ When a table has `parent` set, the CLI automatically:
114
+
115
+ 1. Creates a child route file scoped by the parent's PK as a URL parameter
116
+ 2. Mounts the child routes under the parent path
117
+ 3. Also mounts the child as a top-level route for direct access
118
+
119
+ #### Best Practice: Don't Use System Tables as Parents
120
+
121
+ Tables like `users`, `tenants`, `roles`, `permissions`, `sessions`, and `role_permissions` are cross-cutting concerns — they are referenced by almost every feature module via foreign key columns (e.g. `user_id`, `tenant_id`). Making them route parents would nest every feature module under them, which is not the intent.
122
+
123
+ Keep system tables as top-level modules (`"parent": null`) and reference them via FK columns in your feature tables. Only use `parent` for true domain hierarchies like `posts → comments`, `orders → order_items`, or `projects → tasks`.
124
+
125
+ Examples of tables that should stay top-level (not be parents of feature modules):
126
+ `users`, `tenants`, `roles`, `role_permissions`, `permissions`, `sessions`, `accounts`, `auth_tokens`
127
+
128
+ #### Example Schema
100
129
 
101
130
  ```json
102
131
  {
@@ -106,51 +135,93 @@ Instead of running multiple CLI commands manually, you can define your entire pr
106
135
  "session": "redis",
107
136
  "rateLimiting": true,
108
137
  "helmet": true,
109
- "logger": true
138
+ "logger": true,
139
+ "loki": false
110
140
  },
111
141
  "tables": {
112
142
  "users": {
113
143
  "columns": {
144
+ "user_id": "auto_increment",
114
145
  "name": "required|string",
115
146
  "email": "required|string",
116
147
  "age": "integer",
117
- "is_deleted": "boolean"
148
+ "is_deleted": "boolean",
149
+ "created_at": "datetime",
150
+ "updated_at": "datetime"
118
151
  },
119
- "pk": "id",
152
+ "pk": "user_id",
120
153
  "unique": ["email"],
121
154
  "softDelete": "is_deleted",
122
155
  "timestamps": {
123
156
  "created_at": "created_at",
124
157
  "modified_at": "updated_at"
125
- }
158
+ },
159
+ "parent": null
126
160
  },
127
161
  "posts": {
128
162
  "columns": {
163
+ "post_id": "auto_increment",
129
164
  "title": "required|string",
130
165
  "body": "string",
131
- "user_id": "required|integer"
166
+ "user_id": "required|integer",
167
+ "created_at": "datetime",
168
+ "modified_at": "datetime"
169
+ },
170
+ "pk": "post_id",
171
+ "unique": ["post_id"],
172
+ "parent": null
173
+ },
174
+ "comments": {
175
+ "columns": {
176
+ "comment_id": "auto_increment",
177
+ "post_id": "required|integer",
178
+ "user_id": "required|integer",
179
+ "body": "required|string",
180
+ "created_at": "datetime"
132
181
  },
133
- "pk": "id",
134
- "unique": ["id"]
182
+ "pk": "comment_id",
183
+ "unique": ["comment_id"],
184
+ "parent": "posts"
135
185
  }
136
- },
137
- "relationships": [
138
- { "parent": "users", "child": "posts", "foreignKey": "user_id" }
139
- ]
186
+ }
140
187
  }
141
188
  ```
142
189
 
143
- Table entries support these fields:
190
+ This generates routes:
191
+
192
+ - `GET /users/`, `GET /users/:user_id` — top-level
193
+ - `GET /posts/`, `GET /posts/:post_id` — top-level
194
+ - `GET /posts/:post_id/comments/`, `GET /posts/:post_id/comments/:comment_id` — nested under posts
195
+ - `GET /comments/`, `GET /comments/:comment_id` — also available as top-level
196
+
197
+ Note: `comments` has `user_id` as a foreign key column but `users` is NOT its parent — `posts` is. The `user_id` is just a data reference, not a route hierarchy.
198
+
199
+ #### Table Fields
200
+
201
+ | Field | Required | Description |
202
+ | ------------ | -------- | ------------------------------------------------------------------------ |
203
+ | `columns` | Yes | Object mapping column names to Column_Rule strings (include ALL columns) |
204
+ | `pk` | Yes | Primary key column name (convention: `<table>_id`) |
205
+ | `unique` | No | Array of unique constraint columns (defaults to `[pk]`) |
206
+ | `softDelete` | No | Column name used for soft-delete |
207
+ | `timestamps` | No | Object with `created_at` and `modified_at` column name mapping |
208
+ | `parent` | No | Parent table name for route nesting, or `null` for top-level |
144
209
 
145
- | Field | Required | Description |
146
- | ------------ | -------- | -------------------------------------------------------------- |
147
- | `columns` | Yes | Object mapping column names to Column_Rule strings |
148
- | `pk` | No | Primary key column name (defaults to `"id"`) |
149
- | `unique` | No | Array of unique constraint columns (defaults to `[pk]`) |
150
- | `softDelete` | No | Column name used for soft-delete |
151
- | `timestamps` | No | Object with `created_at` and `modified_at` column name mapping |
210
+ #### Column Rules
152
211
 
153
- Column rules use the format `(required|)?(string|integer|numeric|boolean|object)` — e.g. `"required|string"`, `"integer"`, `"object"`.
212
+ Format: `(required|)?(string|integer|numeric|boolean|object|datetime|auto_increment)`
213
+
214
+ | Type | Description |
215
+ | ---------------- | ------------------------------------------------------------------ |
216
+ | `auto_increment` | Auto-incrementing PK (SERIAL in Postgres, AUTO_INCREMENT in MySQL) |
217
+ | `datetime` | Date/time columns (TIMESTAMP, DATETIME, DATE) |
218
+ | `string` | Text columns (VARCHAR, TEXT, CHAR, UUID) |
219
+ | `integer` | Integer columns (INT, BIGINT, SMALLINT) |
220
+ | `numeric` | Decimal columns (DECIMAL, FLOAT, DOUBLE, MONEY) |
221
+ | `boolean` | Boolean columns (BOOLEAN, BIT) |
222
+ | `object` | JSON columns (JSON, JSONB) |
223
+
224
+ Prefix with `required|` for NOT NULL constraint (e.g. `"required|string"`).
154
225
 
155
226
  ### Unified CLI: `db-model-router`
156
227
 
@@ -206,6 +277,158 @@ db-model-router init --from dbmr.schema.json --yes --no-install
206
277
  db-model-router generate --from dbmr.schema.json
207
278
  ```
208
279
 
280
+ ### Command Reference
281
+
282
+ #### `init`
283
+
284
+ Scaffold a new project from a schema file or interactively. Generates an ESM-based project (`"type": "module"` in package.json) with Docker support.
285
+
286
+ | Flag / Arg | Description |
287
+ | -------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
288
+ | `--from <path>` | Read adapter, framework, and options from a `dbmr.schema.json` file |
289
+ | `--framework <name>` | Express framework: `express` or `ultimate-express` |
290
+ | `--database <name>` | Database adapter: `mysql`, `mariadb`, `postgres`, `sqlite3`, `mongodb`, `mssql`, `cockroachdb`, `oracle`, `redis`, `dynamodb` |
291
+ | `--db <name>` | Alias for `--database` |
292
+ | `--session <type>` | Session store: `memory`, `redis`, `database` |
293
+ | `--output <dir>` | Directory for backend source files (relative to cwd). `package.json` and `app.js` stay in root; `commons/`, `route/`, `middleware/`, `migrations/` go inside this folder. |
294
+ | `--rateLimiting` | Enable rate limiting via `express-rate-limit` (default: yes) |
295
+ | `--helmet` | Enable Helmet security headers (default: yes) |
296
+ | `--logger` | Enable Winston request logger (default: yes) |
297
+ | `--loki` | Enable Grafana Loki log transport + Loki/Grafana in docker-compose (default: no, only asked when `--logger` is enabled) |
298
+
299
+ ```bash
300
+ # Non-interactive with output directory
301
+ db-model-router init --framework express --database postgres --output backend --yes
302
+
303
+ # With Loki logging
304
+ db-model-router init --database postgres --logger --loki --yes
305
+
306
+ # From schema, skip install
307
+ db-model-router init --from dbmr.schema.json --yes --no-install
308
+
309
+ # Dry run to preview files
310
+ db-model-router init --from dbmr.schema.json --dry-run
311
+ ```
312
+
313
+ Generated project structure (with `--output backend`):
314
+
315
+ ```
316
+ ├── package.json # root (type: "module")
317
+ ├── app.js # ESM entry point
318
+ ├── .env / .env.example
319
+ ├── .gitignore
320
+ ├── Dockerfile # node:alpine production image
321
+ ├── .dockerignore
322
+ ├── docker-compose.yml # database + CloudBeaver + optional Loki/Grafana
323
+ ├── .cloudbeaver/
324
+ │ └── data-sources.json # auto-connects CloudBeaver to your DB
325
+ ├── .grafana/ # (only when --loki)
326
+ │ └── datasources.yml # auto-connects Grafana to Loki
327
+ └── backend/
328
+ ├── commons/
329
+ │ ├── db.js # database init, connect, global.db
330
+ │ ├── session.js # session configuration
331
+ │ ├── security.js # helmet, rate limiting, custom headers
332
+ │ ├── migrate.js # migration runner (importable + standalone script)
333
+ │ └── add_migration.js # migration creator (importable + standalone script)
334
+ ├── middleware/
335
+ │ └── logger.js # Winston logger (+ Loki transport when LOKI_HOST is set)
336
+ ├── route/
337
+ │ ├── index.js # central route mounting
338
+ │ └── health.js # GET /health with DB connectivity check
339
+ └── migrations/
340
+ └── <timestamp>_create_migrations_table.sql
341
+ ```
342
+
343
+ Docker services included automatically:
344
+
345
+ | Service | When | Port | Description |
346
+ | ----------- | ------------------------------------- | ------ | -------------------------------------- |
347
+ | Database | Always (except sqlite3) | Varies | Selected database with random password |
348
+ | Redis | `--session redis` (if DB isn't redis) | 6379 | Session store |
349
+ | CloudBeaver | SQL/MongoDB databases | 8978 | Web-based DB admin, auto-connected |
350
+ | Loki | `--loki` | 3100 | Log aggregation |
351
+ | Grafana | `--loki` | 3001 | Log visualization, Loki pre-configured |
352
+
353
+ npm scripts added: `start`, `dev`, `test`, `migrate`, `add_migration`, `docker:build`, `docker:up`, `docker:down`.
354
+
355
+ #### `inspect`
356
+
357
+ Introspect a live database and produce a `dbmr.schema.json` file.
358
+
359
+ | Flag / Arg | Description |
360
+ | ------------------ | ---------------------------------------------------------------------------------------------------------------------- |
361
+ | `--type <adapter>` | Database adapter to introspect (required): `mysql`, `mariadb`, `postgres`, `sqlite3`, `mssql`, `oracle`, `cockroachdb` |
362
+ | `--env <path>` | Path to `.env` file for database connection parameters |
363
+ | `--out <path>` | Output file path (default: `dbmr.schema.json`) |
364
+ | `--tables <list>` | Comma-separated list of tables to include (omit for all) |
365
+
366
+ ```bash
367
+ db-model-router inspect --type postgres --env .env
368
+ db-model-router inspect --type sqlite3 --out schema.json --tables users,posts
369
+ db-model-router inspect --type mysql --json
370
+ ```
371
+
372
+ #### `generate`
373
+
374
+ Generate models, routes, tests, OpenAPI spec, and LLM docs from a schema file. All generated code is ESM (`import`/`export`).
375
+
376
+ | Flag / Arg | Description |
377
+ | --------------- | ------------------------------------------------------------ |
378
+ | `--from <path>` | Path to schema file (default: `dbmr.schema.json`) |
379
+ | `--models` | Generate only model files |
380
+ | `--routes` | Generate only route files (including child routes and index) |
381
+ | `--openapi` | Generate only OpenAPI spec |
382
+ | `--tests` | Generate only test files |
383
+ | `--llm-docs` | Generate only LLM documentation (`llms.txt` + `docs/llm.md`) |
384
+
385
+ When no artifact flags are provided, all artifact types are generated.
386
+
387
+ ```bash
388
+ db-model-router generate --from dbmr.schema.json
389
+ db-model-router generate --models --dry-run
390
+ db-model-router generate --routes --tests
391
+ db-model-router generate --from dbmr.schema.json --json
392
+ ```
393
+
394
+ #### `doctor`
395
+
396
+ Validate schema, check adapter driver dependencies, and verify generated files are in sync.
397
+
398
+ | Flag / Arg | Description |
399
+ | --------------- | ------------------------------------------------- |
400
+ | `--from <path>` | Path to schema file (default: `dbmr.schema.json`) |
401
+
402
+ ```bash
403
+ db-model-router doctor --from dbmr.schema.json
404
+ db-model-router doctor --json
405
+ ```
406
+
407
+ Reports three checks: schema validation, dependency check, sync check.
408
+
409
+ #### `diff`
410
+
411
+ Preview changes between the current generated files and what the schema would produce. Read-only.
412
+
413
+ | Flag / Arg | Description |
414
+ | --------------- | ------------------------------------------------- |
415
+ | `--from <path>` | Path to schema file (default: `dbmr.schema.json`) |
416
+
417
+ ```bash
418
+ db-model-router diff --from dbmr.schema.json
419
+ db-model-router diff --json
420
+ ```
421
+
422
+ #### `help`
423
+
424
+ Show help for any command.
425
+
426
+ ```bash
427
+ db-model-router help # general overview with per-command flags
428
+ db-model-router help init # detailed help for init
429
+ db-model-router init --help # same as above
430
+ ```
431
+
209
432
  ## MySQL Example
210
433
 
211
434
  ### 1. Connect
@@ -272,7 +495,7 @@ This creates 9 endpoints:
272
495
  | GET | `/users/` | List with pagination |
273
496
  | POST | `/users/` | Bulk insert (`{ data: [...] }`) |
274
497
  | PUT | `/users/` | Bulk update (`{ data: [...] }`) |
275
- | DELETE | `/users/` | Bulk delete |
498
+ | DELETE | `/users/` | Bulk delete `{ name: "Bob" }` |
276
499
 
277
500
  ### 4. Payload Override
278
501
 
@@ -379,7 +602,7 @@ await users.remove({ name: "Bob" });
379
602
 
380
603
  Filters use a nested array structure: `[OR_groups[AND_conditions[column, operator, value]]]`
381
604
 
382
- Supported operators: `=`, `like`, `not like`, `in`, `not in`, `<`, `>`, `<=`, `>=`, `!=`
605
+ Supported operators: `=`, `!=`, `<`, `>`, `<=`, `>=`, `LIKE`, `NOT LIKE`, `IN`, `NOT IN`
383
606
 
384
607
  ```js
385
608
  // Find users named Alice OR aged > 30
@@ -397,6 +620,31 @@ const result = await db.get("users", [
397
620
  ]);
398
621
  ```
399
622
 
623
+ ### Query Parameter Filter Operators
624
+
625
+ When using `GET /` (list endpoint), query parameters are automatically parsed into filter conditions. Special value prefixes and patterns control the SQL operator used:
626
+
627
+ | Query Param Value | Operator | Example URL | Resulting Filter |
628
+ | ---------------------- | ---------- | ----------------------------- | ------------------------------------ |
629
+ | `value` | `=` | `?name=john` | `name = 'john'` |
630
+ | `!value` | `!=` | `?name=!john` | `name != 'john'` |
631
+ | `>value` | `>` | `?age=>25` | `age > 25` |
632
+ | `>=value` (use `>%3D`) | `>=` | `?age=>%3D25` | `age >= 25` |
633
+ | `<value` | `<` | `?age=<25` | `age < 25` |
634
+ | `<=value` (use `<%3D`) | `<=` | `?age=<%3D25` | `age <= 25` |
635
+ | `%value%` (use `%25`) | `LIKE` | `?name=%25john%25` | `name LIKE '%john%'` |
636
+ | `!%value%` | `NOT LIKE` | `?name=!%25john%25` | `name NOT LIKE '%john%'` |
637
+ | `in(a,b,c)` | `IN` | `?status=in(active,pending)` | `status IN ('active','pending')` |
638
+ | `!in(a,b,c)` | `NOT IN` | `?status=!in(active,pending)` | `status NOT IN ('active','pending')` |
639
+
640
+ **Notes:**
641
+
642
+ - `%` must be URL-encoded as `%25` in query strings. After URL decoding, the `%` character triggers `LIKE` detection.
643
+ - `=` in `>=` and `<=` must be URL-encoded as `%3D` (e.g. `>%3D25` for `>=25`).
644
+ - `LIKE` patterns follow SQL conventions: `%25john%25` → contains "john", `%25john` → ends with "john", `john%25` → starts with "john".
645
+ - `IN` and `NOT IN` values are comma-separated inside parentheses.
646
+ Operators are detected in order of specificity: `!in(...)` → `in(...)` → `!%...%` → `%...%` → `>=` → `<=` → `>` → `<` → `!value` → `=` (default).
647
+
400
648
  ## Switching Adapters
401
649
 
402
650
  To use a different database, call `init()` before `db.connect()`:
@@ -453,4 +701,14 @@ Apache-2.0
453
701
 
454
702
  ## LLM Skill Reference
455
703
 
456
- For AI/LLM integration, see the [Skill Reference](./docs/SKILL.md) — a structured document covering the full API surface, patterns, constraints, and connection configs for all adapters.
704
+ For AI/LLM integration, see the [Skill Reference](./skill/SKILL.md) — a structured document covering the full API surface, patterns, constraints, and connection configs for all adapters.
705
+
706
+ ### Add the Skill to Your AI Assistant
707
+
708
+ You can install the db-model-router skill directly into any compatible AI assistant using:
709
+
710
+ ```bash
711
+ npx skills add https://github.com/AvinashSKaranth/db-model-router/skill
712
+ ```
713
+
714
+ Once installed, your AI assistant will automatically know how to scaffold projects, generate models and routes, write migrations, and work with all 10 supported database adapters.
package/TODO.md ADDED
@@ -0,0 +1,14 @@
1
+ in generate --db-manager should generate
2
+ DB manager using ejs db manager in the generated codebase (dark theme)
3
+ There is login page with just password -> Needs to login status in session (req.session["db-manager"])
4
+ the password will be in .env as DATABASE_MANAGER_PASSWORD
5
+ Then db manager page
6
+ Left sidebar will have list of tables with local search
7
+ Main page will have 3 tabs
8
+
9
+ 1. Table Structure
10
+ 2. Data top 30 rows with filter,sort,pagenation
11
+ 3. Query page where user can type the raw query
12
+ This needs to added in route like /database
13
+
14
+ The api that this will use is POST /database/login, GET /database/tables, GET /database/tables/:table_name?sort=1&size=30&post_name=%title%